채널이름 고정으로 계산

This commit is contained in:
2023-07-10 11:43:52 +09:00
parent 27a3f2f08c
commit c859aeb75f

View File

@ -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