Skip to content

Commit 1d8ad6f

Browse files
committed
schedule
1 parent 694e2ad commit 1d8ad6f

13 files changed

Lines changed: 497 additions & 12 deletions

File tree

backend/api/handler/coze/loop/apis/wire.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ import (
4242
evaluationapp "github.com/coze-dev/coze-loop/backend/modules/evaluation/application"
4343
"github.com/coze-dev/coze-loop/backend/modules/evaluation/infra/rpc/data"
4444
"github.com/coze-dev/coze-loop/backend/modules/evaluation/infra/rpc/prompt"
45+
"github.com/coze-dev/coze-loop/backend/modules/evaluation/infra/rpc/schedule"
4546
"github.com/coze-dev/coze-loop/backend/modules/evaluation/infra/rpc/trajectory"
4647
foundationapp "github.com/coze-dev/coze-loop/backend/modules/foundation/application"
4748
llmapp "github.com/coze-dev/coze-loop/backend/modules/llm/application"
4849
obapp "github.com/coze-dev/coze-loop/backend/modules/observability/application"
4950
"github.com/coze-dev/coze-loop/backend/modules/observability/domain/component/storage"
51+
taskhook "github.com/coze-dev/coze-loop/backend/modules/observability/domain/component/task"
5052
task_processor "github.com/coze-dev/coze-loop/backend/modules/observability/domain/task/service/taskexe/processor"
5153
promptapp "github.com/coze-dev/coze-loop/backend/modules/prompt/application"
5254
"github.com/coze-dev/coze-loop/backend/pkg/conf"
@@ -82,6 +84,7 @@ var (
8284
NewEvaluationHandler,
8385
data.NewDatasetRPCAdapter,
8486
prompt.NewPromptRPCAdapter,
87+
schedule.ExptScheduleRPCSet,
8588
trajectory.TrajectoryRPCSet,
8689
evaluationapp.InitExperimentApplication,
8790
evaluationapp.InitEvaluatorApplication,
@@ -104,6 +107,7 @@ var (
104107
obapp.InitOpenAPIApplication,
105108
obapp.InitTaskApplication,
106109
obapp.InitMetricApplication,
110+
taskhook.NewNoopTaskHookProvider,
107111
)
108112
)
109113

backend/api/handler/coze/loop/apis/wire_gen.go

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAx
473473
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
474474
github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM=
475475
github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA=
476+
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
476477
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
477478
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
478479
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=

backend/modules/evaluation/application/wire.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func InitExperimentApplication(
162162
plainLimiterFactory limiter.IPlainRateLimiterFactory,
163163
trajectoryAdapter rpc.ITrajectoryAdapter,
164164
fileClient fileservice.Client,
165+
scheduleAdapter rpc.IExptScheduleAdapter,
165166
) (IExperimentApplication, error) {
166167
wire.Build(
167168
experimentSet,
@@ -255,6 +256,7 @@ func InitEvalOpenAPIApplication(
255256
trajectoryAdapter rpc.ITrajectoryAdapter,
256257
fileClient fileservice.Client,
257258
taskClient taskservice.Client,
259+
scheduleAdapter rpc.IExptScheduleAdapter,
258260
) (IEvalOpenAPIApplication, error) {
259261
wire.Build(
260262
evalOpenAPISet,

backend/modules/evaluation/application/wire_gen.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (c) 2025 coze-dev Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package rpc
5+
6+
import (
7+
"context"
8+
"time"
9+
)
10+
11+
// IExptScheduleAdapter 实验模块周期调度任务适配器(通用)
12+
//
13+
// 该接口屏蔽底层调度平台(如 ByteScheduler)的差异,仅提供注册/关闭/查询周期任务的能力,
14+
// 不感知任何业务语义。BizKey 命名、调度时机、回调方法名、回调 payload 等均由调用方决定,
15+
// 业务侧(如"基于实验模板创建实验")的逻辑应放在 backend evaluation 模块的 service 层实现。
16+
//
17+
//go:generate mockgen -destination=mocks/expt_schedule.go -package=mocks . IExptScheduleAdapter
18+
type IExptScheduleAdapter interface {
19+
// CreatePeriodicJob 创建/更新周期任务
20+
// 同 BizKey 重复调用支持 upsert 语义(若任务已关闭,可用相同 BizKey 重新创建)
21+
CreatePeriodicJob(ctx context.Context, param *CreatePeriodicJobParam) error
22+
23+
// CloseJob 关闭周期任务
24+
// 任务已关闭或不存在时返回 nil,保持幂等
25+
CloseJob(ctx context.Context, bizKey string) error
26+
27+
// GetJob 查询任务详情
28+
// 任务不存在时返回 (nil, nil)
29+
GetJob(ctx context.Context, bizKey string) (*ScheduleJobDetail, error)
30+
}
31+
32+
// CreatePeriodicJobParam 创建周期任务的参数
33+
type CreatePeriodicJobParam struct {
34+
// BizKey 业务唯一标识;命名规则由调用方决定,同值重复调用为 upsert
35+
BizKey string
36+
// Crontab 标准 5 段 crontab 表达式(minute hour day-of-month month day-of-week);
37+
// 实现方负责将其转换为底层调度平台所需格式
38+
Crontab string
39+
// StartedAt 首次执行时间;nil 表示按 Crontab 自然触发
40+
StartedAt *time.Time
41+
// EndedAt 截止时间;nil 时由实现方使用默认值(不超过实现方约定的最大有效期)
42+
EndedAt *time.Time
43+
// CallbackMethod 触发时回调的方法名(语义由实现方解释,如 RPC 方法名)
44+
CallbackMethod string
45+
// CallbackPayload 触发时回调的请求体(已由调用方序列化)
46+
CallbackPayload string
47+
}
48+
49+
// ScheduleJobDetail 周期任务详情
50+
type ScheduleJobDetail struct {
51+
BizKey string
52+
Enabled bool
53+
Crontab string
54+
NextRunAt *time.Time
55+
FirstRunAt *time.Time
56+
Deadline *time.Time
57+
}

0 commit comments

Comments
 (0)