first commit

This commit is contained in:
2024-10-02 00:57:17 +08:00
commit 6773f86bc5
312 changed files with 19169 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
package config
import (
"github.com/zeromicro/go-queue/kq"
"github.com/zeromicro/go-zero/rest"
)
type Config struct {
rest.RestConf
KqConsumerLog kq.KqConf
KqConsumerCharge kq.KqConf
}

View File

@@ -0,0 +1,24 @@
package apirequest
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"tianyuan-api/apps/mqs/internal/svc"
)
type Charge struct {
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCharge(ctx context.Context, svcCtx *svc.ServiceContext) *Charge {
return &Charge{
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *Charge) Consume(ctx context.Context, key, val string) error {
logx.Infof("Charge key :%s , val :%s", key, val)
return nil
}

View File

@@ -0,0 +1,24 @@
package apirequest
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"tianyuan-api/apps/mqs/internal/svc"
)
type Log struct {
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewLog(ctx context.Context, svcCtx *svc.ServiceContext) *Log {
return &Log{
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *Log) Consume(ctx context.Context, key, val string) error {
logx.Infof("log key :%s , val :%s", key, val)
return nil
}

View File

@@ -0,0 +1,18 @@
package mqs
import (
"context"
"tianyuan-api/apps/mqs/internal/config"
"tianyuan-api/apps/mqs/internal/mqs/apirequest"
"tianyuan-api/apps/mqs/internal/svc"
"github.com/zeromicro/go-queue/kq"
"github.com/zeromicro/go-zero/core/service"
)
func Consumers(c config.Config, ctx context.Context, svcContext *svc.ServiceContext) []service.Service {
return []service.Service{
kq.MustNewQueue(c.KqConsumerLog, apirequest.NewLog(ctx, svcContext)),
kq.MustNewQueue(c.KqConsumerCharge, apirequest.NewCharge(ctx, svcContext)),
}
}

View File

@@ -0,0 +1,13 @@
package svc
import "tianyuan-api/apps/mqs/internal/config"
type ServiceContext struct {
Config config.Config
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
}
}