add: anowflake email kafka, refa: redis connectg

This commit is contained in:
wwweww
2026-02-25 01:16:13 +08:00
parent fdbcde13b2
commit 300058ad01
67 changed files with 3596 additions and 139 deletions
@@ -0,0 +1,37 @@
package logic
import (
"context"
"errors"
"juwan-backend/app/snowflake/rpc/internal/svc"
"juwan-backend/app/snowflake/rpc/snowflake"
"github.com/zeromicro/go-zero/core/logx"
)
type NextIdsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewNextIdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NextIdsLogic {
return &NextIdsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *NextIdsLogic) NextIds(in *snowflake.NextIdsReq) (*snowflake.NextIdsResp, error) {
if in.Count <= 0 || in.Count > 1000 {
return nil, errors.New("count must be between 1 and 1000")
}
ids, err := l.svcCtx.Generator.NextIDs(int(in.Count))
if err != nil {
l.Errorf("generate snowflake ids failed: %v", err)
return nil, err
}
return &snowflake.NextIdsResp{Ids: ids}, nil
}