Documentation
¶
Index ¶
- func TypedRun[T any](ctx restate.Context, fn func(restate.RunContext) (T, error)) (T, error)
- func WorkflowRun[T any](ctx restate.WorkflowContext, fn func(restate.RunContext) (T, error)) (T, error)
- func WrapAgentExecution[I any, O any](ctx context.Context, executor core.DurableExecutor, input I, ...) (O, error)
- type RestateExecutor
- func (e *RestateExecutor) Checkpoint(ctx context.Context, name string) error
- func (e *RestateExecutor) Get(ctx context.Context, key string) (any, bool, error)
- func (e *RestateExecutor) Run(ctx context.Context, name string, fn func(ctx context.Context) (any, error)) (any, error)
- func (e *RestateExecutor) Set(ctx context.Context, key string, value any) error
- type RestateObjectExecutor
- func (e *RestateObjectExecutor) Checkpoint(ctx context.Context, name string) error
- func (e *RestateObjectExecutor) Get(ctx context.Context, key string) (any, bool, error)
- func (e *RestateObjectExecutor) Run(ctx context.Context, name string, fn func(ctx context.Context) (any, error)) (any, error)
- func (e *RestateObjectExecutor) Set(ctx context.Context, key string, value any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TypedRun ¶
TypedRun executes a typed function with Restate durability. This avoids the any type assertion at the call site.
func WorkflowRun ¶
func WorkflowRun[T any](ctx restate.WorkflowContext, fn func(restate.RunContext) (T, error)) (T, error)
WorkflowRun executes a typed function in a workflow context.
func WrapAgentExecution ¶
func WrapAgentExecution[I any, O any]( ctx context.Context, executor core.DurableExecutor, input I, executeFn func(ctx context.Context, input I, executor core.DurableExecutor) (O, error), ) (O, error)
WrapAgentExecution wraps an agent execution function with Restate durability. This is useful for integrating existing agent code with Restate.
Example:
func (w MyWorkflow) Run(ctx restate.WorkflowContext, input AgentInput) (AgentOutput, error) {
executor := restate.NewRestateExecutor(ctx)
return WrapAgentExecution(ctx, executor, input, myAgent.Execute)
}
Types ¶
type RestateExecutor ¶
type RestateExecutor struct {
// contains filtered or unexported fields
}
RestateExecutor implements core.DurableExecutor using Restate. It wraps a Restate WorkflowContext to provide durable execution.
func NewRestateExecutor ¶
func NewRestateExecutor(ctx restate.WorkflowContext) *RestateExecutor
NewRestateExecutor creates a new Restate-backed durable executor. Pass the WorkflowContext from your Restate handler.
func (*RestateExecutor) Checkpoint ¶
func (e *RestateExecutor) Checkpoint(ctx context.Context, name string) error
Checkpoint creates an explicit checkpoint in Restate.
func (*RestateExecutor) Run ¶
func (e *RestateExecutor) Run(ctx context.Context, name string, fn func(ctx context.Context) (any, error)) (any, error)
Run executes a function with Restate durability. If the process crashes after fn() completes, Restate will restore the result from its checkpoint instead of re-executing fn().
type RestateObjectExecutor ¶
type RestateObjectExecutor struct {
// contains filtered or unexported fields
}
RestateObjectExecutor implements core.DurableExecutor for Restate ObjectContext. Use this for Virtual Objects (stateful, keyed services).
func NewRestateObjectExecutor ¶
func NewRestateObjectExecutor(ctx restate.ObjectContext) *RestateObjectExecutor
NewRestateObjectExecutor creates a new Restate-backed durable executor for objects.
func (*RestateObjectExecutor) Checkpoint ¶
func (e *RestateObjectExecutor) Checkpoint(ctx context.Context, name string) error
Checkpoint creates an explicit checkpoint.