synchronousproxy

package
v0.0.0-...-94a9b73 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

Synchronous Proxy Sample

This sample demonstrates how to achieve synchronous interaction with a main workflow.

We call this pattern a proxy workflow. The proxy workflow sends a signal to the main workflow and then blocks waiting for a signal in response.

This mimics a synchronous SendAndReceiveSignal feature which Temporal does not currently provide natively.

The flow of calls is outlined in the diagram below.

Flow Diagram

Steps to run this sample:

  1. You need a Temporal service running. See details in README.md
  2. Run the following command to start the worker
go run worker/main.go
  1. Run the following command to start the simple UI
go run ui/main.go

Once the UI has exited you will be able to see delivery details in the worker output, as might have been emailed to you in a real implementation.

Documentation

Index

Constants

View Source
const (
	RegisterStage = "register"
	SizeStage     = "size"
	ColorStage    = "color"
	ShippingStage = "shipping"
)

Variables

View Source
var (
	TShirtSizes = []string{
		"small",
		"medium",
		"large",
	}

	TShirtColors = []string{
		"red",
		"blue",
		"black",
	}
)

Functions

func OrderWorkflow

func OrderWorkflow(ctx workflow.Context) error

Workflow is a workflow driven by interaction from a UI.

func RegisterEmail

func RegisterEmail(ctx context.Context, email string) error

func ScheduleDelivery

func ScheduleDelivery(ctx context.Context, order TShirtOrder) (time.Time, error)

func SendDeliveryEmail

func SendDeliveryEmail(ctx context.Context, order TShirtOrder, deliveryDate time.Time) error

func ShippingWorkflow

func ShippingWorkflow(ctx workflow.Context, order TShirtOrder) error

func ValidateColor

func ValidateColor(ctx context.Context, color string) error

func ValidateSize

func ValidateSize(ctx context.Context, size string) error

Types

type OrderStatus

type OrderStatus struct {
	OrderID string
	Stage   string
}

func UpdateOrderWorkflow

func UpdateOrderWorkflow(ctx workflow.Context, orderWorkflowID string, stage string, value string) (OrderStatus, error)

type TShirtOrder

type TShirtOrder struct {
	Email string
	Size  string
	Color string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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