restate

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TypedRun

func TypedRun[T any](ctx restate.Context, fn func(restate.RunContext) (T, error)) (T, error)

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) Get

func (e *RestateExecutor) Get(ctx context.Context, key string) (any, bool, error)

Get retrieves a value from Restate's durable state.

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().

func (*RestateExecutor) Set

func (e *RestateExecutor) Set(ctx context.Context, key string, value any) error

Set stores a value in Restate's durable state.

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.

func (*RestateObjectExecutor) Get

func (e *RestateObjectExecutor) Get(ctx context.Context, key string) (any, bool, error)

Get retrieves a value from Restate's durable state.

func (*RestateObjectExecutor) Run

func (e *RestateObjectExecutor) Run(ctx context.Context, name string, fn func(ctx context.Context) (any, error)) (any, error)

Run executes a function with Restate durability.

func (*RestateObjectExecutor) Set

func (e *RestateObjectExecutor) Set(ctx context.Context, key string, value any) error

Set stores a value in Restate's durable state.

Jump to

Keyboard shortcuts

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