dispatchcoro

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Await

func Await(strategy AwaitStrategy, calls ...dispatchproto.Call) ([]dispatchproto.CallResult, error)

Await awaits the results of calls.

func Deserialize

func Deserialize(coro Coroutine, state dispatchproto.Any) error

Deserialize deserializes a coroutine.

func Gather

func Gather[O any](calls ...dispatchproto.Call) ([]O, error)

Gather awaits the results of calls. It waits until all results are available, or any call fails. It unpacks the output value from the call result when all calls succeed.

func Serialize

func Serialize(coro Coroutine) (dispatchproto.Any, error)

Serialize serializes a coroutine.

func Yield

Yield yields control to Dispatch.

The coroutine is suspended while the Response is sent to Dispatch. If the Response carries a directive to perform work, Dispatch will send the results back in a Request and resume execution from this point.

Types

type AwaitStrategy

type AwaitStrategy int

AwaitStrategy controls an Await operation.

const (
	// AwaitAll instructs Await to wait until all results are available,
	// or any call fails.
	AwaitAll AwaitStrategy = iota

	// AwaitAny instructs Await to wait until any result is available,
	// or all calls fail.
	AwaitAny
)

type Coroutine

Coroutine is the flavour of coroutine supported by Dispatch and the SDK.

func New

func New(fn func() dispatchproto.Response) Coroutine

New creates a Coroutine.

type InstanceID

type InstanceID = uint64

InstanceID is a unique identifier for a coroutine instance.

type VolatileCoroutines

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

VolatileCoroutines is a set of volatile coroutine instances.

"Instances" are only applicable when coroutines are running in volatile mode, since suspended coroutines must be kept in memory. In durable mode, there's no need to keep instances around, since they can be serialized and later recreated.

func (*VolatileCoroutines) Close

func (f *VolatileCoroutines) Close() error

Close closes the set of coroutine instances.

func (*VolatileCoroutines) Delete

func (f *VolatileCoroutines) Delete(id InstanceID)

Delete deletes a coroutine instance.

func (*VolatileCoroutines) Find

Find finds the coroutine instance with the specified ID.

func (*VolatileCoroutines) Register

func (f *VolatileCoroutines) Register(coro Coroutine) InstanceID

Register registers a coroutine instance and returns a unique identifier.

Jump to

Keyboard shortcuts

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