Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CancelledFailureValue = func() statemachine.Value { failure := pbinternal.Failure{} failure.SetCode(409) failure.SetMessage("Cancelled") return statemachine.ValueFailure{Failure: &failure} }()
Functions ¶
func ExecuteInvocation ¶
Types ¶
type AfterFuture ¶
type AfterFuture interface {
// Done blocks waiting on the remaining duration of the sleep.
// It is *not* safe to call this in a goroutine - use Context.Select if you want to wait on multiple
// results at once. Can return a terminal error in the case where the invocation was cancelled mid-sleep,
// hence Done() should always be called, even afterFuture using Context.Select.
Done() error
Selectable
}
After is a coreHandle on a Sleep operation which allows you to do other work concurrently with the sleep.
type AttachFuture ¶
type AttachFuture interface {
Selectable
Response(output any) error
}
type AwakeableFuture ¶
type AwakeableFuture interface {
Selectable
Id() string
Result(output any) error
}
type Client ¶
type Client interface {
RequestFuture(input any, opts ...options.RequestOption) ResponseFuture
Request(input any, output any, opts ...options.RequestOption) error
Send(input any, opts ...options.SendOption) Invocation
}
type Context ¶
type Context interface {
context.Context
Log() *slog.Logger
Request() *Request
// available outside of .Run()
Rand() rand.Rand
Sleep(d time.Duration, opts ...options.SleepOption) error
After(d time.Duration, opts ...options.SleepOption) AfterFuture
Service(service, method string, options ...options.ClientOption) Client
Object(service, key, method string, options ...options.ClientOption) Client
Workflow(seservice, workflowID, method string, options ...options.ClientOption) Client
CancelInvocation(invocationId string)
AttachInvocation(invocationId string, opts ...options.AttachOption) AttachFuture
Awakeable(options ...options.AwakeableOption) AwakeableFuture
ResolveAwakeable(id string, value any, options ...options.ResolveAwakeableOption)
RejectAwakeable(id string, reason error)
Select(futs ...Selectable) Selector
Run(fn func(ctx RunContext) (any, error), output any, options ...options.RunOption) error
// available on all keyed handlers
Get(key string, output any, options ...options.GetOption) (bool, error)
Keys() ([]string, error)
Key() string
// available on non-shared keyed handlers
Set(key string, value any, options ...options.SetOption)
Clear(key string)
ClearAll()
// available on workflow handlers
Promise(name string, options ...options.PromiseOption) DurablePromise
}
type DurablePromise ¶
type Handler ¶
type Handler interface {
GetOptions() *options.HandlerOptions
InputPayload() *encoding.InputPayload
OutputPayload() *encoding.OutputPayload
HandlerType() *internal.ServiceHandlerType
Call(ctx Context, request []byte) (output []byte, err error)
}
Handler is implemented by all Restate handlers
type Invocation ¶
type Invocation interface {
GetInvocationId() string
}
type Request ¶
type Request struct {
// The unique id that identifies the current function invocation. This id is guaranteed to be
// unique across invocations, but constant across reties and suspensions.
ID string
// Request headers - the following headers capture the original invocation headers, as provided to
// the ingress.
Headers map[string]string
// Attempt headers - the following headers are sent by the restate runtime.
// These headers are attempt specific, generated by the restate runtime uniquely for each attempt.
// These headers might contain information such as the W3C trace context, and attempt specific information.
AttemptHeaders map[string][]string
// Raw unparsed request body
Body []byte
}
type ResponseFuture ¶
type ResponseFuture interface {
Selectable
Invocation
Response(output any) error
}
type RunContext ¶
type RunContext interface {
context.Context
// Log obtains a coreHandle on a slog.Logger which already has some useful fields (invocationID and method)
// By default, this logger will not output messages if the invocation is currently replaying
// The log handler can be set with `.WithLogger()` on the server object
Log() *slog.Logger
// Request gives extra information about the request that started this invocation
Request() *Request
}
RunContext is passed to [Run] closures and provides the limited set of Restate operations that are safe to use there.
type Selectable ¶
type Selectable interface {
// contains filtered or unexported methods
}
type Selector ¶
type Selector interface {
// Remaining returns whether there are still operations that haven't been returned by Select().
// There will always be exactly the same number of results as there were operations
// given to Context.Select
Remaining() bool
// Select blocks on the next completed operation or returns nil if there are none left
Select() Selectable
}
Selector is an iterator over a list of blocking Restate operations that are running in the background.
Click to show internal directories.
Click to hide internal directories.