state

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = 1
)

Variables

View Source
var (
	ErrInvalidVersion = fmt.Errorf("invalid version number")
)

Functions

This section is empty.

Types

type Client added in v0.11.0

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) Request added in v0.11.0

func (c *Client) Request(input any, output any, opts ...options.RequestOption) error

Request makes a call and blocks on the response

func (*Client) RequestFuture added in v0.11.0

func (c *Client) RequestFuture(input any, opts ...options.RequestOption) DecodingResponseFuture

RequestFuture makes a call and returns a handle on the response

func (*Client) Send added in v0.11.0

func (c *Client) Send(input any, opts ...options.SendOption)

Send runs a call in the background after delay duration

type ClientGoneAway added in v0.11.0

type ClientGoneAway struct {
	// contains filtered or unexported fields
}

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

func (*Context) After

func (c *Context) After(d time.Duration) *futures.After

func (*Context) Awakeable

func (c *Context) Awakeable(opts ...options.AwakeableOption) DecodingAwakeable

func (*Context) Clear

func (c *Context) Clear(key string)

func (*Context) ClearAll

func (c *Context) ClearAll()

ClearAll drops all associated keys

func (*Context) Get

func (c *Context) Get(key string, output any, opts ...options.GetOption) (bool, error)

func (*Context) Key

func (c *Context) Key() string

func (*Context) Keys

func (c *Context) Keys() ([]string, error)

func (*Context) Log

func (c *Context) Log() *slog.Logger

func (*Context) Object

func (c *Context) Object(service, key, method string, opts ...options.ClientOption) *Client

func (*Context) Promise added in v0.12.0

func (c *Context) Promise(key string, opts ...options.PromiseOption) DecodingPromise

func (*Context) Rand

func (c *Context) Rand() *rand.Rand

func (*Context) RejectAwakeable

func (c *Context) RejectAwakeable(id string, reason error)

func (*Context) Request added in v0.9.1

func (c *Context) Request() *Request

func (*Context) ResolveAwakeable

func (c *Context) ResolveAwakeable(id string, value any, opts ...options.ResolveAwakeableOption)

func (*Context) Run

func (c *Context) Run(fn func(ctx RunContext) (any, error), output any, opts ...options.RunOption) error

func (*Context) Select

func (c *Context) Select(futs ...futures.Selectable) *selector

func (*Context) Service

func (c *Context) Service(service, method string, opts ...options.ClientOption) *Client

func (*Context) Set

func (c *Context) Set(key string, value any, opts ...options.SetOption)

func (*Context) Sleep

func (c *Context) Sleep(d time.Duration) error

func (*Context) Workflow added in v0.12.0

func (c *Context) Workflow(service, workflowID, method string, opts ...options.ClientOption) *Client

type DecodingAwakeable added in v0.11.0

type DecodingAwakeable struct {
	*futures.Awakeable
	// contains filtered or unexported fields
}

func (DecodingAwakeable) Id added in v0.11.0

func (d DecodingAwakeable) Id() string

func (DecodingAwakeable) Result added in v0.11.0

func (d DecodingAwakeable) Result(output any) (err error)

type DecodingPromise added in v0.12.0

type DecodingPromise struct {
	*futures.Promise
	// contains filtered or unexported fields
}

func (DecodingPromise) Peek added in v0.12.0

func (d DecodingPromise) Peek(output any) (ok bool, err error)

func (DecodingPromise) Reject added in v0.12.0

func (d DecodingPromise) Reject(reason error) error

func (DecodingPromise) Resolve added in v0.12.0

func (d DecodingPromise) Resolve(value any) error

func (DecodingPromise) Result added in v0.12.0

func (d DecodingPromise) Result(output any) (err error)

type DecodingResponseFuture added in v0.11.0

type DecodingResponseFuture struct {
	*futures.ResponseFuture
	// contains filtered or unexported fields
}

func (DecodingResponseFuture) Response added in v0.11.0

func (d DecodingResponseFuture) Response(output any) (err error)

type Handler added in v0.11.0

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 Machine

type Machine struct {
	Protocol wire.Protocol
	// contains filtered or unexported fields
}

func NewMachine

func NewMachine(handler Handler, conn io.ReadWriter, attemptHeaders map[string][]string) *Machine

func (*Machine) Log

func (m *Machine) Log() *slog.Logger

func (*Machine) Start

func (m *Machine) Start(inner context.Context, dropReplayLogs bool, logHandler slog.Handler) error

Start starts the state machine

func (*Machine) Write

func (m *Machine) Write(message wire.Message)

type Request added in v0.11.0

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 []byte
	// 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 RunContext added in v0.11.0

type RunContext struct {
	context.Context
	// contains filtered or unexported fields
}

func (RunContext) Log added in v0.11.0

func (r RunContext) Log() *slog.Logger

func (RunContext) Request added in v0.11.0

func (r RunContext) Request() *Request

Jump to

Keyboard shortcuts

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