redis pubsub 채널 이름에 디비 인덱스 추가
This commit is contained in:
@ -30,7 +30,7 @@ type Authinfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
sessionSyncChannelName = "session-sync-channel2"
|
sessionSyncChannelNamePrefix = "session-sync-channel2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthinfoCell interface {
|
type AuthinfoCell interface {
|
||||||
@ -99,6 +99,8 @@ func (ac *redisAuthCell) ToBytes() []byte {
|
|||||||
func newAuthCollectionWithRedis(redisClient *redis.Client, subctx context.Context, maingateURL string, apiToken string) *AuthCollection {
|
func newAuthCollectionWithRedis(redisClient *redis.Client, subctx context.Context, maingateURL string, apiToken string) *AuthCollection {
|
||||||
sessionTTL := int64(3600)
|
sessionTTL := int64(3600)
|
||||||
ac := MakeAuthCollection(time.Duration(sessionTTL * int64(time.Second)))
|
ac := MakeAuthCollection(time.Duration(sessionTTL * int64(time.Second)))
|
||||||
|
|
||||||
|
sessionSyncChannelName := fmt.Sprintf("%s-%d", sessionSyncChannelNamePrefix, redisClient.Options().DB)
|
||||||
pubsub := redisClient.Subscribe(subctx, sessionSyncChannelName)
|
pubsub := redisClient.Subscribe(subctx, sessionSyncChannelName)
|
||||||
ctx, cancel := context.WithCancel(context.TODO())
|
ctx, cancel := context.WithCancel(context.TODO())
|
||||||
go func(ctx context.Context, sub *redis.PubSub, authCache *AuthCollection) {
|
go func(ctx context.Context, sub *redis.PubSub, authCache *AuthCollection) {
|
||||||
|
|||||||
@ -68,6 +68,7 @@ func Start(ctx context.Context, redisClient *redis.Client) {
|
|||||||
hash.Write([]byte(inName))
|
hash.Write([]byte(inName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
hash.Write([]byte(fmt.Sprintf("%d", redisClient.Options().DB)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pubsubName := hex.EncodeToString(hash.Sum(nil))[:16]
|
pubsubName := hex.EncodeToString(hash.Sum(nil))[:16]
|
||||||
|
|||||||
@ -177,8 +177,8 @@ func NewWebsocketHandler() (*WebsocketHandler, error) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
sh := &subhandler{
|
sh := &subhandler{
|
||||||
redisMsgChanName: fmt.Sprintf("_wsh_msg_%s", region),
|
redisMsgChanName: fmt.Sprintf("_wsh_msg_%s_%d", region, redisSync.Options().DB),
|
||||||
redisCmdChanName: fmt.Sprintf("_wsh_cmd_%s", region),
|
redisCmdChanName: fmt.Sprintf("_wsh_cmd_%s_%d", region, redisSync.Options().DB),
|
||||||
redisSync: redisSync,
|
redisSync: redisSync,
|
||||||
connInOutChan: make(chan *wsconn),
|
connInOutChan: make(chan *wsconn),
|
||||||
deliveryChan: make(chan any, 1000),
|
deliveryChan: make(chan any, 1000),
|
||||||
|
|||||||
Reference in New Issue
Block a user