client

package
v0.0.0-...-5861b17 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package client provides access to the workflow service. You can use this client to:

Submit a *pb.WorkReq to the service
Execute a *pb.WorkReq previously submitted
Get the status of a *pb.WorkReq

See the README.md in the root workflow/ directory for more information.

SECURITY NOTICE: As this is an example for a book and is meant to be run in a secure environment, we use grpc.WithInsecure(). Aka, not production ready.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Workflow

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

Workflow represents our Workflow client. It uses a builtin circuit breaker wrapping an exponential backoff. The context passed to any method should be the maximum time you are willing to wait including all retries. If a call returns an error because the context expires, the circuit breaker will trip. Errors without gRPC status codes or with status codes of DeadlineExceeded or ResourceExhausted are considered fatal errors. Fatal errors do not get retries and do not trip the circuit breaker.

func New

func New(addr string) (*Workflow, error)

New creates a new Workflow instance.

func (*Workflow) Exec

func (w *Workflow) Exec(ctx context.Context, id string) error

Exec causes the server to execute a pb.WorkReq that was previously accepted by the server via a Submit() call.

func (*Workflow) Status

func (w *Workflow) Status(ctx context.Context, id string) (*pb.StatusResp, error)

Status returns the status of a pb.WorkReq that was submitted to the server via the Submit() call.

func (*Workflow) Submit

func (w *Workflow) Submit(ctx context.Context, req *pb.WorkReq) (string, error)

Submit submits a pb.WorkReq to the server. If successful an ID will be returned that represents the pb.WorkReq on the server. This can be used in an Exec() call to execute the pb.WorkReq.

Jump to

Keyboard shortcuts

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