mirror of https://github.com/tidwall/redcon.git
prepare for PR
This commit is contained in:
parent
ea500d3d6b
commit
250feb7729
|
@ -22,7 +22,7 @@ Installing
|
||||||
----------
|
----------
|
||||||
|
|
||||||
```
|
```
|
||||||
go get -u github.com/tidwall/redcon
|
go get -u github.com/tidwall/redcon/v2
|
||||||
```
|
```
|
||||||
|
|
||||||
Example
|
Example
|
||||||
|
@ -52,7 +52,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/tidwall/redcon"
|
"github.com/tidwall/redcon/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var addr = ":6380"
|
var addr = ":6380"
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nathanhack/redcon"
|
"github.com/tidwall/redcon/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var addr = ":6380"
|
var addr = ":6380"
|
||||||
|
@ -16,7 +17,7 @@ func main() {
|
||||||
var ps redcon.PubSub
|
var ps redcon.PubSub
|
||||||
go log.Printf("started server at %s", addr)
|
go log.Printf("started server at %s", addr)
|
||||||
|
|
||||||
err := redcon.ListenAndServe(addr,
|
err := redcon.ListenAndServe(context.Background(), addr,
|
||||||
func(conn redcon.Conn, cmd redcon.Command) {
|
func(conn redcon.Conn, cmd redcon.Command) {
|
||||||
switch strings.ToLower(string(cmd.Args[0])) {
|
switch strings.ToLower(string(cmd.Args[0])) {
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/nathanhack/redcon"
|
"github.com/tidwall/redcon/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var addr = ":6380"
|
var addr = ":6380"
|
||||||
|
@ -21,7 +22,7 @@ func main() {
|
||||||
mux.HandleFunc("get", handler.get)
|
mux.HandleFunc("get", handler.get)
|
||||||
mux.HandleFunc("del", handler.delete)
|
mux.HandleFunc("del", handler.delete)
|
||||||
|
|
||||||
err := redcon.ListenAndServe(addr,
|
err := redcon.ListenAndServe(context.Background(), addr,
|
||||||
mux.ServeRESP,
|
mux.ServeRESP,
|
||||||
func(conn redcon.Conn) bool {
|
func(conn redcon.Conn) bool {
|
||||||
// use this function to accept or deny the connection.
|
// use this function to accept or deny the connection.
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nathanhack/redcon"
|
"github.com/tidwall/redcon/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nathanhack/redcon"
|
"github.com/tidwall/redcon/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const serverKey = `-----BEGIN EC PARAMETERS-----
|
const serverKey = `-----BEGIN EC PARAMETERS-----
|
||||||
|
@ -47,7 +48,7 @@ func main() {
|
||||||
var items = make(map[string][]byte)
|
var items = make(map[string][]byte)
|
||||||
|
|
||||||
go log.Printf("started server at %s", addr)
|
go log.Printf("started server at %s", addr)
|
||||||
err = redcon.ListenAndServeTLS(addr,
|
err = redcon.ListenAndServeTLS(context.Background(), addr,
|
||||||
func(conn redcon.Conn, cmd redcon.Command) {
|
func(conn redcon.Conn, cmd redcon.Command) {
|
||||||
switch strings.ToLower(string(cmd.Args[0])) {
|
switch strings.ToLower(string(cmd.Args[0])) {
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue