Documentation
¶
Index ¶
- Variables
- func CustomErrorDecoder(ctx context.Context, resp *http.Response) error
- func CustomResponseDecoder(ctx context.Context, resp *http.Response, v any) error
- type ActivityFunction
- type ActivityTaskRuntime
- type ActivityWorker
- type Client
- func (client *Client) Close() error
- func (client *Client) CreateOrUpdateActivity(ctx context.Context, req *apiV1.CreateActivityRequest) (*apiV1.CreateActivityResponse, error)
- func (client *Client) CreateOrUpdateNamespace(ctx context.Context, req *apiV1.CreateNamespaceRequest) (*apiV1.CreateNamespaceResponse, error)
- func (client *Client) CreateOrUpdateStateMachine(ctx context.Context, req *apiV1.CreateStateMachineRequest) (*apiV1.CreateStateMachineResponse, error)
- func (client *Client) GetActivityTask(ctx context.Context, req *apiV1.GetActivityTaskRequest) (*apiV1.GetActivityTaskResponse, error)
- func (client *Client) GetClient() apiV1.SkyflowV1ServiceHTTPClient
- func (client *Client) SendTaskFailure(ctx context.Context, req *apiV1.SendTaskFailureRequest) error
- func (client *Client) SendTaskHeartbeat(ctx context.Context, req *apiV1.SendTaskHeartbeatRequest) error
- func (client *Client) SendTaskSuccess(ctx context.Context, req *apiV1.SendTaskSuccessRequest) error
- func (client *Client) StartExecution(ctx context.Context, req StartExecutionRequest) (*apiV1.StartExecutionResponse, error)
- type Context
- type CustomResponse
- type ResourceWorker
- type ResponseMessage
- type StartExecutionRequest
- type WorkerActivity
- type WorkerNamespace
- type WorkerStatusType
Constants ¶
This section is empty.
Variables ¶
var ActivityRunError = "ActivityRunError"
ActivityRunError 运行时错误类型
var DefaultGetActivityTaskTimeout = 10 * time.Second
var DefaultPollErrorInterval = 1 * time.Second
var DefaultPollInterval = 200 * time.Millisecond
var WorkerStatus = struct { Init WorkerStatusType Stop WorkerStatusType StopFinish WorkerStatusType Running WorkerStatusType Close WorkerStatusType }{ Init: "Init", Stop: "Stop", StopFinish: "StopFinish", Running: "Running", Close: "Close", }
WorkerStatus worker的状态分布
Functions ¶
func CustomErrorDecoder ¶
CustomErrorDecoder 自定义错误解码器
Types ¶
type ActivityFunction ¶
ActivityFunction activity callback function
type ActivityTaskRuntime ¶
type ActivityTaskRuntime struct {
Activity *WorkerActivity
Data *pbv1.GetActivityTaskResponse
}
ActivityTaskRuntime 一个具体的Activity 运行时实例
type ActivityWorker ¶
type ActivityWorker struct {
Namespaces []*WorkerNamespace
GetActivityTaskTimeout time.Duration // 获取活动任务超时时间
PollInterval time.Duration // 正常轮询间隔
PollErrorInterval time.Duration //轮询错误间隔
// contains filtered or unexported fields
}
ActivityWorker Worker for activity model
func NewActivityWorker ¶
func NewActivityWorker(client *Client, poolsize int, namespaces ...*WorkerNamespace) (*ActivityWorker, error)
NewActivityWorker new activity worker
func (*ActivityWorker) Register ¶
func (w *ActivityWorker) Register() error
Register register statemachine / activities to skyflow server
func (*ActivityWorker) Run ¶
func (w *ActivityWorker) Run() error
Run Start Monitor skyflow and execute function when need
func (*ActivityWorker) Status ¶
func (w *ActivityWorker) Status() WorkerStatusType
Status 返回worker的状态
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CreateOrUpdateActivity ¶
func (client *Client) CreateOrUpdateActivity(ctx context.Context, req *apiV1.CreateActivityRequest, ) (*apiV1.CreateActivityResponse, error)
func (*Client) CreateOrUpdateNamespace ¶
func (client *Client) CreateOrUpdateNamespace(ctx context.Context, req *apiV1.CreateNamespaceRequest, ) (*apiV1.CreateNamespaceResponse, error)
func (*Client) CreateOrUpdateStateMachine ¶
func (client *Client) CreateOrUpdateStateMachine(ctx context.Context, req *apiV1.CreateStateMachineRequest, ) (*apiV1.CreateStateMachineResponse, error)
func (*Client) GetActivityTask ¶
func (client *Client) GetActivityTask(ctx context.Context, req *apiV1.GetActivityTaskRequest) (*apiV1.GetActivityTaskResponse, error)
func (*Client) GetClient ¶
func (client *Client) GetClient() apiV1.SkyflowV1ServiceHTTPClient
func (*Client) SendTaskFailure ¶
func (*Client) SendTaskHeartbeat ¶
func (*Client) SendTaskSuccess ¶
func (*Client) StartExecution ¶
func (client *Client) StartExecution(ctx context.Context, req StartExecutionRequest, ) (*apiV1.StartExecutionResponse, error)
type Context ¶
type Context struct {
Context context.Context
Client *Client
Runtime *ActivityTaskRuntime
}
Context Skyflow Worker Context Context 上下文信息,用于传递给Activity 的参数
func NewContext ¶
func NewContext(ctx context.Context, client *Client, task *ActivityTaskRuntime) *Context
NewContext create a new context
func (*Context) SendTaskFailure ¶
func (*Context) SendTaskHeartbeat ¶
func (*Context) SendTaskSuccess ¶
func (*Context) UnmarshalInput ¶
type CustomResponse ¶
type CustomResponse struct {
Success bool `json:"success"`
ErrorCode string `json:"error_code"`
ReturnCode int `json:"return_code"`
ErrorMessage string `json:"error_message"`
Data json.RawMessage `json:"data"`
}
CustomResponse 对应服务端的 Response 结构
type ResponseMessage ¶
type ResponseMessage struct {
ErrorCode string `json:"ErrorCode"`
ErrorMessage string `json:"ErrorMessage"`
Success bool `json:"Success"`
Data interface{} `json:"Data"`
}
ResponseMessage 返回结构体
type StartExecutionRequest ¶
type WorkerActivity ¶
type WorkerActivity struct {
Name string // 活动名称
Function ActivityFunction // 指定的函数
Description string // 活动说明
URI string // 活动URI
}
WorkerActivity Activity in worker
func NewWorkerActivity ¶
func NewWorkerActivity(name string, f ActivityFunction, comment string) *WorkerActivity
NewWorkerActivity New Worker Activity
type WorkerNamespace ¶
type WorkerNamespace struct {
Name string
Description string
Activities []*WorkerActivity
StateMachinePaths []string
StateMachines map[string]string
}
WorkerNamespace repository in worker
func NewWorkerNamespace ¶
func NewWorkerNamespace(name string, description string, paths []string, activities ...*WorkerActivity) *WorkerNamespace
NewWorkerNamespace New worker namespace
func (*WorkerNamespace) ScanStateMachinePath ¶
func (wr *WorkerNamespace) ScanStateMachinePath() error
ScanStateMachinePath add statemachine search path