diff --git a/contrib/codecs/redis/codec_test.go b/contrib/codecs/redis/codec_test.go index 000a9137faf619c3551772fbfcfd9435164cfd72..5e5c8363832ad7119c5c08fb9c772d587f25555e 100644 --- a/contrib/codecs/redis/codec_test.go +++ b/contrib/codecs/redis/codec_test.go @@ -1,7 +1,6 @@ package redis import ( - "context" "testing" "gfx.cafe/open/jrpc/pkg/codec" @@ -14,16 +13,15 @@ import ( ) func TestBasicSuite(t *testing.T) { - redisServer := miniredis.RunT(t) - _ = redisServer - connOpts := &redis.UniversalOptions{ - Addrs: []string{"localhost:6379"}, - } domain := "jrpc" jrpctest.RunBasicTestSuite(t, jrpctest.BasicTestSuiteArgs{ ServerMaker: func() (*server.Server, jrpctest.ClientMaker, func()) { - ctx, cn := context.WithCancel(context.Background()) + redisServer := miniredis.RunT(t) + connOpts := &redis.UniversalOptions{ + Addrs: []string{redisServer.Addr()}, + } + ctx := redisServer.Ctx ss, err := CreateServerStream(ctx, domain, connOpts) require.NoError(t, err) s := jrpctest.NewServer() @@ -32,7 +30,7 @@ func TestBasicSuite(t *testing.T) { conn := NewClient(redis.NewUniversalClient(connOpts), domain) return conn }, func() { - cn() + redisServer.CtxCancel() } }, }) diff --git a/contrib/codecs/redis/redis.go b/contrib/codecs/redis/redis.go index 656a9a45779aba8bd1af70c18b1ed95e7f6c180f..281af544ffd5738600bfe478fa5a7a5b5387cdf7 100644 --- a/contrib/codecs/redis/redis.go +++ b/contrib/codecs/redis/redis.go @@ -3,7 +3,6 @@ package redis import ( "context" "encoding/json" - "log" "time" "unsafe" @@ -48,10 +47,8 @@ func (s *ServerStream) ReadRequest(ctx context.Context) (*RedisRequest, func(jso if err != nil { return nil, nil, err } - log.Println("got req", redisReq.ReplyChannel, string(redisReq.Message)) return redisReq, func(rm json.RawMessage) error { target := s.domain + "." + redisReq.ReplyChannel - log.Println("replying", target, string(rm)) return s.client.Publish(context.Background(), target, string(rm)).Err() }, nil }