Documentation
¶
Index ¶
- Variables
- func ExecuteInvocation(ctx context.Context, logger *slog.Logger, ...) error
- type AfterFuture
- type AttachFuture
- type AwakeableFuture
- type Client
- type Context
- type DurablePromise
- type Future
- type Handler
- type Invocation
- type Request
- type ResponseFuture
- type RunAsyncFuture
- type RunContext
- type SignalFuture
- type WaitIterator
Constants ¶
This section is empty.
Variables ¶
View Source
var BufPool sync.Pool
View Source
var CancelledFailureValue = func() statemachine.Value { failure := pbinternal.TerminalFailure{} failure.SetCode(409) failure.SetMessage("Cancelled") return statemachine.ValueFailure{Failure: &failure} }()
Functions ¶
func ExecuteInvocation ¶
func ExecuteInvocation(ctx context.Context, logger *slog.Logger, stateMachine *statemachine.StateMachine, stream io.ReadWriter, handler Handler, dropReplayLogs bool, logHandler slog.Handler, attemptHeaders map[string][]string) error
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() errors.TerminalError
Future
}
After is a coreHandle on a Sleep operation which allows you to do other work concurrently with the sleep.
type AttachFuture ¶
type AttachFuture interface {
Future
Response(output any) errors.TerminalError
}
type AwakeableFuture ¶
type AwakeableFuture interface {
Future
Id() string
Result(output any) errors.TerminalError
}
type Client ¶
type Client interface {
RequestFuture(input any, opts ...options.RequestOption) ResponseFuture
Request(input any, output any, opts ...options.RequestOption) errors.TerminalError
Send(input any, opts ...options.SendOption) Invocation
}
type Context ¶
type Context interface {
context.Context
Log() *slog.Logger
Request() *Request
Wrap(wrappedCtx context.Context) Context
// available outside of .Run()
RandInstance() *rand2.Rand
RandUUID() uuid.UUID
RandSource() rand2.Source
Sleep(d time.Duration, opts ...options.SleepOption) errors.TerminalError
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)
Signal(name string, options ...options.SignalOption) SignalFuture
ResolveSignal(invocationID string, name string, value any, options ...options.ResolveSignalOption)
RejectSignal(invocationID string, name string, reason error)
WaitIter(futs ...Future) WaitIterator
Run(fn func(ctx RunContext) (any, error), output any, options ...options.RunOption) errors.TerminalError
RunAsync(fn func(ctx RunContext) (any, error), options ...options.RunOption) RunAsyncFuture
// available on all keyed handlers
Get(key string, output any, options ...options.GetOption) (bool, errors.TerminalError)
Keys() ([]string, errors.TerminalError)
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 DurablePromise interface {
Future
Result(output any) errors.TerminalError
Peek(output any) (ok bool, err errors.TerminalError)
Resolve(value any) errors.TerminalError
Reject(reason error) errors.TerminalError
}
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
// Scope is the invocation scope supplied by the runtime.
Scope string
// LimitKey is the invocation concurrency limit key supplied by the runtime.
LimitKey string
// IdempotencyKey is the idempotency key supplied by the runtime.
IdempotencyKey string
// Request headers - the following headers capture the original invocation headers, as provided to
// the ingress.
Headers stringmap.Map
// 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 {
Future
Invocation
Response(output any) errors.TerminalError
}
type RunAsyncFuture ¶ added in v0.17.0
type RunAsyncFuture interface {
Future
Result(output any) errors.TerminalError
}
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 SignalFuture ¶ added in v0.25.0
type SignalFuture interface {
Future
Result(output any) errors.TerminalError
}
type WaitIterator ¶ added in v0.21.0
type WaitIterator interface {
// Next returns whether there are still operations that haven't been returned by Value().
// If returns false, no more operations will be completed. After returning false, Err() should be checked.
Next() bool
// Err returns an error if the waiter was canceled using Restate's cancellation feature.
Err() errors.TerminalError
// Value returns the current value of this iterator, or nil if the iterator returned Next previously.
// Panics if called before the first Next
Value() Future
}
WaitIterator lets you
Click to show internal directories.
Click to hide internal directories.