From c859aeb75fe97b977092010a0f3f379f75a6e71d Mon Sep 17 00:00:00 2001 From: mountain Date: Mon, 10 Jul 2023 11:43:52 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B1=84=EB=84=90=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EA=B3=A0=EC=A0=95=EC=9C=BC=EB=A1=9C=20=EA=B3=84=EC=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rpc/rpc.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rpc/rpc.go b/rpc/rpc.go index d39ada6..08b49f6 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -3,7 +3,9 @@ package rpc import ( "bytes" "context" + "crypto/md5" "encoding/gob" + "encoding/hex" "errors" "fmt" "path" @@ -55,7 +57,12 @@ func Start(ctx context.Context, redisClient *redis.Client) { return } - pubsubName := primitive.NewObjectID().Hex()[6:] + hash := md5.New() + for k := range engine.receivers { + hash.Write([]byte(k)) + } + pubsubName := hex.EncodeToString(hash.Sum(nil))[:16] + engine.publish = func(s []byte) error { _, err := redisClient.Publish(ctx, pubsubName, s).Result() return err