From 1a6a9a352cea47c07378f6a75cc6af5e55cc9d61 Mon Sep 17 00:00:00 2001 From: re Date: Mon, 12 Dec 2022 14:17:30 +0300 Subject: [PATCH] fix paths --- README.md | 6 +++--- example/clone.go | 4 ++-- example/mux/clone.go | 2 +- example/mux/handler.go | 2 +- example/tls/clone.go | 4 ++-- go.mod | 4 ++-- licenses.txt | 3 +++ redcon.go | 43 ++++++++++++++++++++++++++---------------- 8 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 licenses.txt diff --git a/README.md b/README.md index 7633c51..f30183f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ src="logo.png" width="336" border="0" alt="REDCON">
-GoDoc +GoDoc

Redis compatible server framework for Go

@@ -22,7 +22,7 @@ Installing ---------- ``` -go get -u github.com/tidwall/redcon +go get -u git.internal/re/redcon ``` Example @@ -52,7 +52,7 @@ import ( "strings" "sync" - "github.com/tidwall/redcon" + "git.internal/re/redcon" ) var addr = ":6380" diff --git a/example/clone.go b/example/clone.go index f7615d7..300ec4b 100644 --- a/example/clone.go +++ b/example/clone.go @@ -5,14 +5,14 @@ import ( "strings" "sync" - "github.com/tidwall/redcon" + "git.internal/re/redcon" ) var addr = ":6380" func main() { var mu sync.RWMutex - var items = make(map[string][]byte) + items := make(map[string][]byte) var ps redcon.PubSub go log.Printf("started server at %s", addr) diff --git a/example/mux/clone.go b/example/mux/clone.go index bc47d65..fba4f00 100644 --- a/example/mux/clone.go +++ b/example/mux/clone.go @@ -3,7 +3,7 @@ package main import ( "log" - "github.com/tidwall/redcon" + "git.internal/re/redcon" ) var addr = ":6380" diff --git a/example/mux/handler.go b/example/mux/handler.go index dd5e616..aa4e90c 100644 --- a/example/mux/handler.go +++ b/example/mux/handler.go @@ -4,7 +4,7 @@ import ( "log" "sync" - "github.com/tidwall/redcon" + "git.internal/re/redcon" ) type Handler struct { diff --git a/example/tls/clone.go b/example/tls/clone.go index 8d1b67c..b07c398 100644 --- a/example/tls/clone.go +++ b/example/tls/clone.go @@ -6,7 +6,7 @@ import ( "strings" "sync" - "github.com/tidwall/redcon" + "git.internal/re/redcon" ) const serverKey = `-----BEGIN EC PARAMETERS----- @@ -44,7 +44,7 @@ func main() { config := &tls.Config{Certificates: []tls.Certificate{cer}} var mu sync.RWMutex - var items = make(map[string][]byte) + items := make(map[string][]byte) go log.Printf("started server at %s", addr) err = redcon.ListenAndServeTLS(addr, diff --git a/go.mod b/go.mod index 602094a..e044eaa 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ -module github.com/tidwall/redcon +module git.internal/re/redcon -go 1.15 +go 1.19 require ( github.com/tidwall/btree v1.1.0 diff --git a/licenses.txt b/licenses.txt new file mode 100644 index 0000000..5a5a9a0 --- /dev/null +++ b/licenses.txt @@ -0,0 +1,3 @@ +git.internal/re/redcon,Unknown,MIT +github.com/tidwall/btree,https://github.com/tidwall/btree/blob/v1.1.0/LICENSE,MIT +github.com/tidwall/match,https://github.com/tidwall/match/blob/v1.1.1/LICENSE,MIT diff --git a/redcon.go b/redcon.go index 9c069bc..b37ec33 100644 --- a/redcon.go +++ b/redcon.go @@ -296,7 +296,9 @@ func (s *Server) ListenServeAndSignal(signal chan error) error { } return err } + s.mu.Lock() s.ln = ln + s.mu.Unlock() if signal != nil { signal <- nil } @@ -321,7 +323,9 @@ func (s *TLSServer) ListenServeAndSignal(signal chan error) error { } return err } + s.mu.Lock() s.ln = ln + s.mu.Unlock() if signal != nil { signal <- nil } @@ -350,7 +354,7 @@ func serve(s *Server) error { return nil } if errors.Is(err, net.ErrClosed) { - // see https://github.com/tidwall/redcon/issues/46 + // see https://git.internal/re/redcon/issues/46 return nil } if s.AcceptError != nil { @@ -480,9 +484,11 @@ func (c *conn) ReadPipeline() []Command { c.cmds = nil return cmds } + func (c *conn) PeekPipeline() []Command { return c.cmds } + func (c *conn) NetConn() net.Conn { return c.conn } @@ -602,9 +608,9 @@ func (w *Writer) WriteNull() { // sub-responses to the client to complete the response. // For example to write two strings: // -// c.WriteArray(2) -// c.WriteBulkString("item 1") -// c.WriteBulkString("item 2") +// c.WriteArray(2) +// c.WriteBulkString("item 1") +// c.WriteBulkString("item 2") func (w *Writer) WriteArray(count int) { if w.err != nil { return @@ -709,17 +715,18 @@ func (w *Writer) WriteRaw(data []byte) { } // WriteAny writes any type to client. -// nil -> null -// error -> error (adds "ERR " when first word is not uppercase) -// string -> bulk-string -// numbers -> bulk-string -// []byte -> bulk-string -// bool -> bulk-string ("0" or "1") -// slice -> array -// map -> array with key/value pairs -// SimpleString -> string -// SimpleInt -> integer -// everything-else -> bulk-string representation using fmt.Sprint() +// +// nil -> null +// error -> error (adds "ERR " when first word is not uppercase) +// string -> bulk-string +// numbers -> bulk-string +// []byte -> bulk-string +// bool -> bulk-string ("0" or "1") +// slice -> array +// map -> array with key/value pairs +// SimpleString -> string +// SimpleInt -> integer +// everything-else -> bulk-string representation using fmt.Sprint() func (w *Writer) WriteAny(v interface{}) { if w.err != nil { return @@ -1020,7 +1027,6 @@ func Parse(raw []byte) (Command, error) { return Command{}, errTooMuchData } return cmds[0], nil - } // A Handler responds to an RESP request. @@ -1105,6 +1111,11 @@ func (ps *PubSub) Psubscribe(conn Conn, channel string) { ps.subscribe(conn, true, channel) } +// Unsubscribe a connection from PubSub +func (ps *PubSub) Unsubscribe(conn Conn, pattern, all bool, channel string) { + ps.unsubscribe(conn, pattern, all, channel) +} + // Publish a message to subscribers func (ps *PubSub) Publish(channel, message string) int { ps.mu.RLock()