ing
This commit is contained in:
15
subscribe/redis.go
Normal file
15
subscribe/redis.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package subscribe
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
ofs_redis "git.loafle.net/overflow/overflow_subscriber/redis"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
)
|
||||
|
||||
func Subscribe(ctx context.Context, redisConn redis.Conn) {
|
||||
s := ofs_redis.New(ctx, redisConn)
|
||||
webS := newWebSubscriberHandler(ctx, "web")
|
||||
|
||||
s.Subscribe(webS)
|
||||
}
|
||||
31
subscribe/web_subscriber_handlers.go
Normal file
31
subscribe/web_subscriber_handlers.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package subscribe
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.loafle.net/commons_go/logging"
|
||||
ofs "git.loafle.net/overflow/overflow_subscriber"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func newWebSubscriberHandler(ctx context.Context, channel string) ofs.SubscriberHandler {
|
||||
h := &webSubscriberHandlers{
|
||||
ctx: ctx,
|
||||
logger: logging.WithContext(ctx),
|
||||
}
|
||||
h.Channel = channel
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
type webSubscriberHandlers struct {
|
||||
ofs.SubscriberHandlers
|
||||
ctx context.Context
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func (h *webSubscriberHandlers) OnSubscribe(payload string) {
|
||||
h.logger.Info("Subscriber:Web",
|
||||
zap.String("payload", payload),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user