client

package
v0.15.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 23 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultActionListenerRetryInterval = 5 * time.Second
	DefaultActionListenerRetryCount    = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	// the worker id
	WorkerId string

	// the tenant id
	TenantId string

	// the workflow run id
	WorkflowRunId string

	// the get group key run id
	GetGroupKeyRunId string

	// the job id
	JobId string

	// the job name
	JobName string

	// the job run id
	JobRunId string

	// the step id
	StepId string

	// the step run id
	StepRunId string

	// the action id
	ActionId string

	// the action payload
	ActionPayload []byte

	// the action type
	ActionType ActionType
}

type ActionEvent

type ActionEvent struct {
	*Action

	// the event timestamp
	EventTimestamp *time.Time

	// the step event type
	EventType ActionEventType

	// The event payload. This must be JSON-compatible as it gets marshalled to a JSON string.
	EventPayload interface{}
}

type ActionEventResponse

type ActionEventResponse struct {
	// the tenant id
	TenantId string

	// the id of the worker
	WorkerId string
}

type ActionEventType

type ActionEventType string
const (
	ActionEventTypeUnknown   ActionEventType = "STEP_EVENT_TYPE_UNKNOWN"
	ActionEventTypeStarted   ActionEventType = "STEP_EVENT_TYPE_STARTED"
	ActionEventTypeCompleted ActionEventType = "STEP_EVENT_TYPE_COMPLETED"
	ActionEventTypeFailed    ActionEventType = "STEP_EVENT_TYPE_FAILED"
)

type ActionPayload

type ActionPayload func(target interface{}) error

ActionPayload unmarshals the action payload into the target. It also validates the resulting target.

type ActionType

type ActionType string
const (
	ActionTypeStartStepRun     ActionType = "START_STEP_RUN"
	ActionTypeCancelStepRun    ActionType = "CANCEL_STEP_RUN"
	ActionTypeStartGetGroupKey ActionType = "START_GET_GROUP_KEY"
)

type AdminClient

type AdminClient interface {
	PutWorkflow(workflow *types.Workflow, opts ...PutOptFunc) error
	ScheduleWorkflow(workflowName string, opts ...ScheduleOptFunc) error

	// RunWorkflow triggers a workflow run and returns the run id
	RunWorkflow(workflowName string, input interface{}) (string, error)
}

type Client

type Client interface {
	Admin() AdminClient
	Dispatcher() DispatcherClient
	Event() EventClient
	Run() RunClient
}

func New

func New(fs ...ClientOpt) (Client, error)

New creates a new client instance.

func NewFromConfigFile added in v0.11.0

func NewFromConfigFile(cf *client.ClientConfigFile, fs ...ClientOpt) (Client, error)

type ClientEventListener added in v0.9.0

type ClientEventListener interface {
	OnStepRunEvent(ctx context.Context, event *StepRunEvent) error
}

type ClientOpt

type ClientOpt func(*ClientOpts)

func InitWorkflows

func InitWorkflows() ClientOpt

func WithHostPort

func WithHostPort(host string, port int) ClientOpt

func WithTenantId

func WithTenantId(tenantId string) ClientOpt

func WithToken added in v0.11.0

func WithToken(token string) ClientOpt

func WithWorkflows

func WithWorkflows(files []*types.Workflow) ClientOpt

WithWorkflows sets the workflow files to use for the worker. If this is not passed in, the workflows files will be loaded from the .hatchet folder in the current directory.

type ClientOpts

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

type DispatcherClient

type DispatcherClient interface {
	GetActionListener(ctx context.Context, req *GetActionListenerRequest) (WorkerActionListener, error)

	SendStepActionEvent(ctx context.Context, in *ActionEvent) (*ActionEventResponse, error)

	SendGroupKeyActionEvent(ctx context.Context, in *ActionEvent) (*ActionEventResponse, error)
}

type EventClient

type EventClient interface {
	Push(ctx context.Context, eventKey string, payload interface{}) error
}

type GetActionListenerRequest

type GetActionListenerRequest struct {
	WorkerName string
	Services   []string
	Actions    []string
	MaxRuns    *int
}

TODO: add validator to client side

type PutOptFunc

type PutOptFunc func(*putOpts)

type RunClient added in v0.9.0

type RunClient interface {
	On(ctx context.Context, workflowRunId string, handler RunHandler) error
}

type RunHandler added in v0.9.0

type RunHandler func(event *StepRunEvent) error

type ScheduleOptFunc

type ScheduleOptFunc func(*scheduleOpts)

func WithInput

func WithInput(input any) ScheduleOptFunc

func WithSchedules

func WithSchedules(schedules ...time.Time) ScheduleOptFunc

type StepRunEvent added in v0.9.0

type StepRunEvent struct {
	Type StepRunEventType

	Payload []byte
}

type StepRunEventType added in v0.9.0

type StepRunEventType string
const (
	StepRunEventTypeStarted   StepRunEventType = "STEP_RUN_EVENT_TYPE_STARTED"
	StepRunEventTypeCompleted StepRunEventType = "STEP_RUN_EVENT_TYPE_COMPLETED"
	StepRunEventTypeFailed    StepRunEventType = "STEP_RUN_EVENT_TYPE_FAILED"
	StepRunEventTypeCancelled StepRunEventType = "STEP_RUN_EVENT_TYPE_CANCELLED"
	StepRunEventTypeTimedOut  StepRunEventType = "STEP_RUN_EVENT_TYPE_TIMED_OUT"
)

type WorkerActionListener

type WorkerActionListener interface {
	Actions(ctx context.Context) (<-chan *Action, error)

	Unregister() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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