Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client encapsulates a GRPC connection to a Conductor server and the different services it exposes.
func NewClient ¶
func NewClient(address string, options ...grpc.DialOption) (*Client, error)
NewClient returns a new Client with a GRPC connection to the given address, and any optional grpc.Dialoption settings.
func (*Client) Metadata ¶
func (client *Client) Metadata() metadata.MetadataServiceClient
Metadata returns the Metadata service for this client
func (*Client) Shutdown ¶
func (client *Client) Shutdown()
Shutdown closes the underlying GRPC connection for this client.
type Executor ¶
type Executor interface { // Execute attempt to resolve the given Task and returns a TaskResult // with its output. The given Context carries a deadline which must be // enforced by the implementation. // This function will be called by the Worker for each incoming Task, // and must be threadsafe as it can be called by several goroutines // concurrently. Execute(context.Context, *model.Task) (*model.TaskResult, error) // ConnectionError is called by a Worker whenever there's an error with // a GRPC connection. The GRPC error is passed in as its only argument. // If this function returns nil, the Worker will continue retrying the // connection; if it returns a non-nill error, the Worker will stop its // execution and return the given error as the result of the Worker.Run // function. ConnectionError(error) error }
An Executor is a struct that executes the logic required to resolve a task. Each Worker instance uses an Executor to run the polled tasks.
type MetadataClient ¶
type MetadataClient interface { Metadata() metadata.MetadataServiceClient Shutdown() }
MetadataClient is a Conductor client that exposes the Conductor Metadata API.
type TasksClient ¶
type TasksClient interface { Tasks() tasks.TaskServiceClient Shutdown() }
TasksClient is a Conductor client that exposes the Conductor Tasks API.
type Worker ¶
type Worker struct { // TaskType is the identifier for the type of tasks that this worker can // execute. This will be send to Conductor when polling for new tasks. TaskType string // TaskTimeout is the total duration that a task will be executed for. This // includes the time required to poll, execute and return the task's results. // If not set, tasks will not timeout. TaskTimeout time.Duration // Identifier is an unique identifier for this worker. If not set, it defaults // to the local hostname. Identifier string // Concurrency is the amount of goroutines that wil poll for tasks and execute // them concurrently. If not set, it defaults to GOMAXPROCS, a sensible default. Concurrency int // Executor is an instance of an Executor that will actually run the logic required // for each task. See conductor.Executor. Executor Executor // Client is an instance of a conductor.Client that implements a Task service. // See conductor.Client Client TasksClient // contains filtered or unexported fields }
A Worker uses a TaskClient to poll the Conductor server for new tasks and executes them using an Executor instance, returning the result of the task to the upstream server. The Worker struct must be created manually with the desired settings, and then ran with Worker.Run. Client implementations usually run a single Worker per process, or one worker per Task Type if a process needs to execute tasks of different types. The Concurrency field allows the worker to execute tasks concurrently in several goroutines.
func (*Worker) Run ¶
Run executes the main loop of the Worker, spawning several gorutines to poll and resolve tasks from a Conductor server. This is a blocking call that will not return until Worker.Shutdown is called from another goroutine. When shutting down cleanly, this function returns nil; otherwise an error is returned if there's been a problem with the GRPC connection and the Worker cannot continue running.
type WorkflowsClient ¶
type WorkflowsClient interface { Workflows() workflows.WorkflowServiceClient Shutdown() }
WorkflowsClient is a Conductor client that exposes the Conductor Workflows API.