Documentation ¶
Index ¶
- Variables
- func GetWorkflowHistoriesBundle(ctx context.Context, client *Client, w WorkflowDeclaration) ([]byte, error)
- func ReplayWorkflow(historiesBytes []byte, fn any) error
- type Activity
- type ActivityWithImpl
- type Client
- type Namespace
- type QueryHandler
- type Queue
- type Registerable
- type UpdateHandler
- func (q *UpdateHandler[Param, Return]) SetHandler(ctx workflow.Context, fn func(workflow.Context, Param) (Return, error))
- func (q *UpdateHandler[Param, Return]) SetHandlerWithValidator(ctx workflow.Context, fn func(workflow.Context, Param) (Return, error), ...)
- func (q *UpdateHandler[Param, Return]) Update(ctx context.Context, temporalClient *Client, workflowID, runID string, p Param) (Return, error)
- type Worker
- type Workflow
- func (w Workflow[Param, Return]) Execute(ctx context.Context, temporalClient *Client, opts client.StartWorkflowOptions, ...) (client.WorkflowRun, error)
- func (w Workflow[Param, Return]) ExecuteChild(ctx workflow.Context, opts workflow.ChildWorkflowOptions, param Param) workflow.ChildWorkflowFuture
- func (w Workflow[Param, Return]) Name() string
- func (w Workflow[Param, Return]) Run(ctx context.Context, temporalClient *Client, opts client.StartWorkflowOptions, ...) (Return, error)
- func (w Workflow[Param, Return]) RunChild(ctx workflow.Context, opts workflow.ChildWorkflowOptions, param Param) (Return, error)
- func (w Workflow[Param, Return]) SetSchedule(ctx context.Context, temporalClient *Client, opts client.ScheduleOptions, ...) error
- func (w Workflow[Param, Return]) WithImplementation(fn func(workflow.Context, Param) (Return, error)) *WorkflowWithImpl[Param, Return]
- type WorkflowDeclaration
- type WorkflowWithImpl
Constants ¶
This section is empty.
Variables ¶
var DefaultNamespace = NewNamespace(client.DefaultNamespace)
DefaultNamespace a convenient way to refer to temporal's default namespace.
Functions ¶
func GetWorkflowHistoriesBundle ¶
func GetWorkflowHistoriesBundle(ctx context.Context, client *Client, w WorkflowDeclaration) ([]byte, error)
GetWorkflowHistoriesBundle connects to the temporal server and fetches the most recent 10 open and 10 closed executions. It returns a byte seralized piece of data that can be used immediately or in the future to call ReplayWorkflow.
func ReplayWorkflow ¶
ReplayWorkflow is meant to be used in tests with the output of GetWorkflowHistoriesBundle to check if the given workflow implementation (fn) is compatible with previous executions captured at the time when GetWorkflowHistoriesBundle was run.
Types ¶
type Activity ¶
Activity is used for interacting with activities in a safe way that takes into account the input and output types, queue name and other properties.
func NewActivity ¶
NewActivity declares the existence of an activity on a given queue with a given name.
func (Activity[Param, Return]) Execute ¶
Execute asynchnronously executes the activity and returns a promise.
func (Activity[Param, Return]) Run ¶
Run executes the activity and synchronously returns the output.
func (Activity[Param, Return]) WithImplementation ¶
func (a Activity[Param, Return]) WithImplementation(fn func(context.Context, Param) (Return, error)) *ActivityWithImpl
WithImplementation should be called to create the parameters for NewWorker(). It declares which function implements the activity.
type ActivityWithImpl ¶
type ActivityWithImpl struct {
// contains filtered or unexported fields
}
ActivityWithImpl is a temporary struct that implements Registerable. It's meant to be passed into `tempts.NewWorker`.
type Client ¶
Client is a wrapper for the temporal SDK client that keeps track of which namepace the client is connected to to return more useful errors if the wrong namespace is used.
func NewFromSDK ¶
NewFromSDK allows the caller to pass in an existing temporal SDK client and manually specify which name that client was connected to.
func NewLazyClient ¶
NewLazyClient is equivalent to Dial, but doesn't conect to the server until necessary.
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace declares the name of a namespace for use later. This is a pre-requisite for defining any other resource such as workflows or activities.
func NewNamespace ¶
NewNamespace is used for declaring namespaces. Unless using namespaces in your application, you can use `tempts.DefaultNamespace` instead of defining one.
type QueryHandler ¶
type QueryHandler[Param, Return any] struct { // contains filtered or unexported fields }
QueryHandler is used for interacting with queries on workflows. Currently there's no way to enforce the connection between the query and the workflow it should be valid on.
func NewQueryHandler ¶
func NewQueryHandler[Param, Return any](queryName string) *QueryHandler[Param, Return]
NewQueryHandler declares the name and types for a query to a workflow.
func (*QueryHandler[Param, Return]) Query ¶
func (q *QueryHandler[Param, Return]) Query(ctx context.Context, temporalClient *Client, workflowID, runID string, p Param) (Return, error)
Query executes the query and returns the response.
func (*QueryHandler[Param, Return]) SetHandler ¶
func (q *QueryHandler[Param, Return]) SetHandler(ctx workflow.Context, fn func(Param) (Return, error))
SetHandler should be called by a workflow to define how the query should be handled when sent to this workflow to execute.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is the declaration of a temporal, queue, which is used for routing workflows and activities to workers.
type Registerable ¶
type Registerable interface {
// contains filtered or unexported methods
}
Registerable can be created by calling WithImplementation() on activity or workflow definitions. It's a parameter to `tempts.NewWorker()`.
type UpdateHandler ¶
type UpdateHandler[Param, Return any] struct { // contains filtered or unexported fields }
UpdateHandler is used for interacting with updates on workflows. Currently there's no way to enforce the connection between the update and the workflow it should be valid on.
func NewUpdateHandler ¶
func NewUpdateHandler[Param, Return any](updateName string) *UpdateHandler[Param, Return]
NewUpdateHandler declares the name and types for an update to a workflow.
func (*UpdateHandler[Param, Return]) SetHandler ¶
func (q *UpdateHandler[Param, Return]) SetHandler(ctx workflow.Context, fn func(workflow.Context, Param) (Return, error))
SetHandler should be called by a workflow to define how the update should be handled when sent to this workflow to execute.
func (*UpdateHandler[Param, Return]) SetHandlerWithValidator ¶
func (q *UpdateHandler[Param, Return]) SetHandlerWithValidator(ctx workflow.Context, fn func(workflow.Context, Param) (Return, error), validator func(workflow.Context, Param) error)
SetHandlerWithValidator should be called by a workflow to define how the query should be handled when sent to this workflow to execute. This is the same as SetHandler, except that it gives access to the experimental Validator function which can be used to validate the request before it's executed.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker represents a temporal worker that connects to the temporal server to execute activities and workflows.
func NewWorker ¶
func NewWorker(queue *Queue, registerables []Registerable) (*Worker, error)
NewWorker defines a worker along with all of the workflows and activities. Example usage:
wrk, err := tempts.NewWorker(queueMain, []tempts.Registerable{ activityTypeFormatName.WithImplementation(activityFormatName), activityTypeGreet.WithImplementation(activityGreet), workflowTypeFormatAndGreet.WithImplementation(workflowFormatAndGreet), workflowTypeJustGreet.WithImplementation(workflowJustGreet), })
type Workflow ¶
Workflow is used for interacting with workflows in a safe way that takes into account the input and output types, queue name and other properties. Workflows are resumable functions registered on workers that execute activities.
func NewWorkflow ¶
NewWorkflow declares the existence of a workflow on a given queue with a given name.
func (Workflow[Param, Return]) Execute ¶
func (w Workflow[Param, Return]) Execute(ctx context.Context, temporalClient *Client, opts client.StartWorkflowOptions, param Param) (client.WorkflowRun, error)
Execute asynchnronously executes the workflow and returns a promise.
func (Workflow[Param, Return]) ExecuteChild ¶
func (w Workflow[Param, Return]) ExecuteChild(ctx workflow.Context, opts workflow.ChildWorkflowOptions, param Param) workflow.ChildWorkflowFuture
Execute asynchnronously executes the workflow from another parent workflow and returns a promise.
func (Workflow[Param, Return]) Run ¶
func (w Workflow[Param, Return]) Run(ctx context.Context, temporalClient *Client, opts client.StartWorkflowOptions, param Param) (Return, error)
Run executes the workflow and synchronously returns the output.
func (Workflow[Param, Return]) RunChild ¶
func (w Workflow[Param, Return]) RunChild(ctx workflow.Context, opts workflow.ChildWorkflowOptions, param Param) (Return, error)
Run executes the workflow from another parent workflow and synchronously returns the output.
func (Workflow[Param, Return]) SetSchedule ¶
func (w Workflow[Param, Return]) SetSchedule(ctx context.Context, temporalClient *Client, opts client.ScheduleOptions, param Param) error
SetSchedule creates or updates the schedule to match the given definition. WARNING: This feature is not as seamless as it could be because of the complex API exposed by temporal. In some cases, when the schedule has been modified in some non-updateable way, this method can't update the schedule and it returns an error.
func (Workflow[Param, Return]) WithImplementation ¶
func (w Workflow[Param, Return]) WithImplementation(fn func(workflow.Context, Param) (Return, error)) *WorkflowWithImpl[Param, Return]
WithImplementation should be called to create the parameters for NewWorker(). It declares which function implements the workflow.
type WorkflowDeclaration ¶
type WorkflowDeclaration interface { Name() string // contains filtered or unexported methods }
WorkflowDeclaration always contains Workflow but doesn't have type parameters, so it can be passed into non-generic functions.
type WorkflowWithImpl ¶
WorkflowWithImpl is a temporary struct that implements Registerable. It's meant to be passed into `tempts.NewWorker`.
func (WorkflowWithImpl[Param, Return]) ExecuteInTest ¶
func (w WorkflowWithImpl[Param, Return]) ExecuteInTest(e testEnvironment, p Param) (Return, error)
ExecuteInTest executes the given workflow implementation in a unit test and returns the output of the workflow.
func (WorkflowWithImpl[Param, Return]) Name ¶
func (w WorkflowWithImpl[Param, Return]) Name() string
Name returns the name of the workflow being implemented.