add: anowflake email kafka, refa: redis connectg
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-queue/kq"
|
||||
"github.com/zeromicro/go-zero/core/service"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
service.ServiceConf
|
||||
Kmq kq.KqConf
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package consumer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"juwan-backend/app/email/mq/internal/config"
|
||||
|
||||
"juwan-backend/app/email/mq/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/service"
|
||||
)
|
||||
|
||||
func Mqs(c config.Config) []service.Service {
|
||||
//svcContext := NewServiceContext
|
||||
ctx := context.Background()
|
||||
svcCtx := svc.NewServiceContext(c)
|
||||
|
||||
var services []service.Service
|
||||
services = append(services, Kqs(ctx, c, svcCtx)...)
|
||||
|
||||
return services
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package consumer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"juwan-backend/app/email/mq/internal/config"
|
||||
"juwan-backend/app/email/mq/internal/logic"
|
||||
"juwan-backend/app/email/mq/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-queue/kq"
|
||||
"github.com/zeromicro/go-zero/core/service"
|
||||
)
|
||||
|
||||
func Kqs(ctx context.Context, c config.Config, svcCtx *svc.ServiceContext) []service.Service {
|
||||
return []service.Service{kq.MustNewQueue(c.Kmq, logic.NewSendVerificationCodeMq(ctx, c, svcCtx))}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"juwan-backend/app/email/mq/internal/config"
|
||||
"juwan-backend/app/email/mq/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type SendVerificationCodeMq struct {
|
||||
c config.Config
|
||||
ctx context.Context
|
||||
svcCxt *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewSendVerificationCodeMq(ctx context.Context, c config.Config, svcCtx *svc.ServiceContext) *SendVerificationCodeMq {
|
||||
return &SendVerificationCodeMq{
|
||||
c: c,
|
||||
ctx: ctx,
|
||||
svcCxt: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *SendVerificationCodeMq) Consume(ctx context.Context, key, value string) error {
|
||||
_ = ctx
|
||||
_ = key
|
||||
_ = value
|
||||
logx.Infof("Consume get message key: %s, value: %s", key, value)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package svc
|
||||
|
||||
import "juwan-backend/app/email/mq/internal/config"
|
||||
|
||||
type ServiceContext struct {
|
||||
c config.Config
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
c: c,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user