This commit is contained in:
crusader
2017-09-01 15:42:23 +09:00
parent d3f40ec6be
commit 1e1e212954
15 changed files with 365 additions and 288 deletions

15
subscribe/redis.go Normal file
View 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)
}

View 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),
)
}