feat: update the redis reference to cache.Cmdable instead (#535)
This commit is contained in:
@@ -21,14 +21,13 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
type cancelSignalStoreImpl struct {
|
||||
redis *redis.Client
|
||||
redis cache.Cmdable
|
||||
}
|
||||
|
||||
const workflowExecutionCancelStatusKey = "workflow:cancel:status:%d"
|
||||
|
||||
@@ -23,13 +23,13 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
|
||||
@@ -40,7 +40,7 @@ import (
|
||||
|
||||
type executeHistoryStoreImpl struct {
|
||||
query *query.Query
|
||||
redis *redis.Client
|
||||
redis cache.Cmdable
|
||||
}
|
||||
|
||||
func (e *executeHistoryStoreImpl) CreateWorkflowExecution(ctx context.Context, execution *entity.WorkflowExecution) (err error) {
|
||||
@@ -457,7 +457,7 @@ func (e *executeHistoryStoreImpl) loadNodeExecutionFromRedis(ctx context.Context
|
||||
|
||||
result, err := e.redis.Get(ctx, key).Result()
|
||||
if err != nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
if errors.Is(err, cache.Nil) {
|
||||
return nil
|
||||
}
|
||||
return vo.WrapError(errno.ErrRedisError, err)
|
||||
@@ -523,7 +523,7 @@ func (e *executeHistoryStoreImpl) GetTestRunLatestExeID(ctx context.Context, wfI
|
||||
key := fmt.Sprintf(testRunLastExeKey, wfID, uID)
|
||||
exeIDStr, err := e.redis.Get(ctx, key).Result()
|
||||
if err != nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
if errors.Is(err, cache.Nil) {
|
||||
return 0, nil
|
||||
}
|
||||
return 0, vo.WrapError(errno.ErrRedisError, err)
|
||||
@@ -548,7 +548,7 @@ func (e *executeHistoryStoreImpl) GetNodeDebugLatestExeID(ctx context.Context, w
|
||||
key := fmt.Sprintf(nodeDebugLastExeKey, wfID, nodeID, uID)
|
||||
exeIDStr, err := e.redis.Get(ctx, key).Result()
|
||||
if err != nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
if errors.Is(err, cache.Nil) {
|
||||
return 0, nil
|
||||
}
|
||||
return 0, vo.WrapError(errno.ErrRedisError, err)
|
||||
|
||||
@@ -22,16 +22,15 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
type interruptEventStoreImpl struct {
|
||||
redis *redis.Client
|
||||
redis cache.Cmdable
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -81,7 +80,7 @@ func (i *interruptEventStoreImpl) SaveInterruptEvents(ctx context.Context, wfExe
|
||||
|
||||
previousEventStr, err := i.redis.Get(ctx, previousResumedEventKey).Result()
|
||||
if err != nil {
|
||||
if !errors.Is(err, redis.Nil) {
|
||||
if !errors.Is(err, cache.Nil) {
|
||||
return fmt.Errorf("failed to get previous resumed event for wfExeID %d: %w", wfExeID, err)
|
||||
}
|
||||
}
|
||||
@@ -154,7 +153,7 @@ func (i *interruptEventStoreImpl) GetFirstInterruptEvent(ctx context.Context, wf
|
||||
|
||||
eventJSON, err := i.redis.LIndex(ctx, listKey, 0).Result()
|
||||
if err != nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
if errors.Is(err, cache.Nil) {
|
||||
return nil, false, nil // List is empty or key does not exist
|
||||
}
|
||||
return nil, false, fmt.Errorf("failed to get first interrupt event from Redis list for wfExeID %d: %w", wfExeID, err)
|
||||
@@ -203,7 +202,7 @@ func (i *interruptEventStoreImpl) PopFirstInterruptEvent(ctx context.Context, wf
|
||||
|
||||
eventJSON, err := i.redis.LPop(ctx, listKey).Result()
|
||||
if err != nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
if errors.Is(err, cache.Nil) {
|
||||
return nil, false, nil // List is empty or key does not exist
|
||||
}
|
||||
return nil, false, vo.WrapError(errno.ErrRedisError,
|
||||
@@ -227,7 +226,7 @@ func (i *interruptEventStoreImpl) ListInterruptEvents(ctx context.Context, wfExe
|
||||
|
||||
eventJSONs, err := i.redis.LRange(ctx, listKey, 0, -1).Result()
|
||||
if err != nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
if errors.Is(err, cache.Nil) {
|
||||
return nil, nil // List is empty or key does not exist
|
||||
}
|
||||
return nil, vo.WrapError(errno.ErrRedisError,
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
|
||||
einoCompose "github.com/cloudwego/eino/compose"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"golang.org/x/exp/maps"
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
@@ -41,6 +40,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
cm "github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
@@ -61,7 +61,7 @@ const (
|
||||
type RepositoryImpl struct {
|
||||
idgen.IDGenerator
|
||||
query *query.Query
|
||||
redis *redis.Client
|
||||
redis cache.Cmdable
|
||||
tos storage.Storage
|
||||
einoCompose.CheckPointStore
|
||||
workflow.InterruptEventStore
|
||||
@@ -70,7 +70,7 @@ type RepositoryImpl struct {
|
||||
builtinModel cm.BaseChatModel
|
||||
}
|
||||
|
||||
func NewRepository(idgen idgen.IDGenerator, db *gorm.DB, redis *redis.Client, tos storage.Storage,
|
||||
func NewRepository(idgen idgen.IDGenerator, db *gorm.DB, redis cache.Cmdable, tos storage.Storage,
|
||||
cpStore einoCompose.CheckPointStore, chatModel cm.BaseChatModel) workflow.Repository {
|
||||
return &RepositoryImpl{
|
||||
IDGenerator: idgen,
|
||||
|
||||
Reference in New Issue
Block a user