skyflowclient

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

README

SkyFlow Client SDK

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActivityRunError = "ActivityRunError"

ActivityRunError 运行时错误类型

View Source
var DefaultGetActivityTaskTimeout = 10 * time.Second
View Source
var DefaultPollErrorInterval = 1 * time.Second
View Source
var DefaultPollInterval = 200 * time.Millisecond
View Source
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

func CustomErrorDecoder(ctx context.Context, resp *http.Response) error

CustomErrorDecoder 自定义错误解码器

func CustomResponseDecoder

func CustomResponseDecoder(ctx context.Context, resp *http.Response, v any) error

CustomResponseDecoder 自定义响应解码器

Types

type ActivityFunction

type ActivityFunction func(ctx *Context) error

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的状态

func (*ActivityWorker) Stop

func (w *ActivityWorker) Stop() error

Stop Stop Monitor skyflow

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(address string) (*Client, error)

func (*Client) Close

func (client *Client) Close() error

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 *Client) SendTaskFailure(ctx context.Context, req *apiV1.SendTaskFailureRequest) error

func (*Client) SendTaskHeartbeat

func (client *Client) SendTaskHeartbeat(ctx context.Context, req *apiV1.SendTaskHeartbeatRequest) error

func (*Client) SendTaskSuccess

func (client *Client) SendTaskSuccess(ctx context.Context, req *apiV1.SendTaskSuccessRequest) error

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 (ctx *Context) SendTaskFailure(errorname string, cause string) error

func (*Context) SendTaskHeartbeat

func (ctx *Context) SendTaskHeartbeat(message string) error

func (*Context) SendTaskSuccess

func (ctx *Context) SendTaskSuccess(output any) error

func (*Context) UnmarshalInput

func (ctx *Context) UnmarshalInput(v interface{}) error

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 ResourceWorker

type ResourceWorker struct {
}

ResourceWorker resource worker use api

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 StartExecutionRequest struct {
	StatemachineUri string `json:"state_machine_uri"`
	Input           any    `json:"input"`
	Title           string `json:"title"`
	Description     string `json:"description"`
	ExecutionName   string `json:"execution_name"`
	Definition      string `json:"definition"`
}

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

type WorkerStatusType

type WorkerStatusType string

WorkerStatusType worker 状态类型

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL