server

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: MIT Imports: 23 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LambdaHandlerFunc added in v0.13.1

type LambdaHandlerFunc func(ctx context.Context, event LambdaRequest) (LambdaResponse, error)

type LambdaRequest added in v0.13.1

type LambdaRequest struct {
	Path            string            `json:"path"`
	RawPath         string            `json:"rawPath"`
	Body            string            `json:"body"`
	IsBase64Encoded bool              `json:"isBase64Encoded"`
	Headers         map[string]string `json:"headers"`
}

type LambdaResponse added in v0.13.1

type LambdaResponse struct {
	StatusCode      int               `json:"statusCode"`
	Headers         map[string]string `json:"headers"`
	Body            string            `json:"body"`
	IsBase64Encoded bool              `json:"isBase64Encoded"`
}

type Restate

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

Restate represents a Restate HTTP handler to which services or virtual objects may be attached.

func NewRestate

func NewRestate() *Restate

NewRestate creates a new instance of Restate server

func (*Restate) Bidirectional added in v0.9.1

func (r *Restate) Bidirectional(bidi bool) *Restate

Bidirectional is used to change the protocol mode advertised to Restate on discovery In bidirectional mode, Restate will keep the request body open even after we have started to respond, allowing for more work to be done without suspending. This is supported over HTTP2 and, in some cases (where there is no buffering proxy), with HTTP1.1. When serving over a non-bidirectional channel (eg, Cloudflare Workers), use .Bidirectional(false) otherwise your handlers may get stuck.

func (*Restate) Bind

func (r *Restate) Bind(definition restate.ServiceDefinition) *Restate

Bind attaches a Service Definition (a Service or Virtual Object) to this server

func (*Restate) Handler added in v0.9.1

func (r *Restate) Handler() (http.HandlerFunc, error)

Handler obtains a http.HandlerFunc representing the bound services which can be passed to other types of server. Ensure that .Bidirectional(false) is set when serving over a channel that doesn't support full-duplex request and response.

func (*Restate) LambdaHandler added in v0.13.1

func (r *Restate) LambdaHandler() (LambdaHandlerFunc, error)

LambdaHandler obtains a Lambda handler function representing the bound services .Bidirectional(false) will be set on your behalf as Lambda only supports request-response communication

func (*Restate) Start

func (r *Restate) Start(ctx context.Context, address string) error

Start starts a HTTP2 server serving the bound services

func (*Restate) WithIdentityV1

func (r *Restate) WithIdentityV1(keys ...string) *Restate

WithIdentityV1 attaches v1 request identity public keys to this server. All incoming requests will be validated against one of these keys.

func (*Restate) WithLogger

func (r *Restate) WithLogger(h slog.Handler, dropReplayLogs bool) *Restate

WithLogger overrides the slog handler used by the SDK (which defaults to the slog Default()) You may specify with dropReplayLogs whether to drop logs that originated from handler code while the invocation was replaying. If they are not dropped, you may still determine the replay status in a slog.Handler using github.com/restatedev/sdk-go/rcontext.LogContextFrom

Jump to

Keyboard shortcuts

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