Documentation ¶
Index ¶
- func Await(strategy AwaitStrategy, calls ...dispatchproto.Call) ([]dispatchproto.CallResult, error)
- func Deserialize(coro Coroutine, state dispatchproto.Any) error
- func Gather[O any](calls ...dispatchproto.Call) ([]O, error)
- func Serialize(coro Coroutine) (dispatchproto.Any, error)
- func Yield(res dispatchproto.Response) dispatchproto.Request
- type AwaitStrategy
- type Coroutine
- type InstanceID
- type VolatileCoroutines
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 ¶
func Yield(res dispatchproto.Response) dispatchproto.Request
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 ¶
type Coroutine = coroutine.Coroutine[dispatchproto.Response, dispatchproto.Request]
Coroutine is the flavour of coroutine supported by Dispatch and the SDK.
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 ¶
func (f *VolatileCoroutines) Find(id InstanceID) (Coroutine, error)
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.