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