connect

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseAcknowlegeDeadline = time.Second * 5
)
View Source
const (
	WorkerHeartbeatInterval = 10 * time.Second
)

Variables

View Source
var ErrTooManyConnections = fmt.Errorf("too many connections")
View Source
var ErrUnauthenticated = fmt.Errorf("authentication failed")

Functions

func NewWorkerPool

func NewWorkerPool(ctx context.Context, concurrency int, handler func(msg workerPoolMsg)) *workerPool

Types

type ConnectApp

type ConnectApp struct {
	AppName    string
	Functions  []sdk.SDKFunction
	AppVersion *string
}

type ConnectionState

type ConnectionState string
const (
	ConnectionStateConnecting   ConnectionState = "CONNECTING"
	ConnectionStateActive       ConnectionState = "ACTIVE"
	ConnectionStatePaused       ConnectionState = "PAUSED"
	ConnectionStateReconnecting ConnectionState = "RECONNECTING"
	ConnectionStateClosing      ConnectionState = "CLOSING"
	ConnectionStateClosed       ConnectionState = "CLOSED"
)

type FunctionInvoker

type FunctionInvoker interface {
	InvokeFunction(ctx context.Context, slug string, stepId *string, request sdkrequest.Request) (any, []state.GeneratorOpcode, error)
}

type Opts

type Opts struct {
	Env  *string
	Apps []ConnectApp

	Capabilities sdk.Capabilities

	HashedSigningKey         []byte
	HashedSigningKeyFallback []byte

	MaxConcurrency int

	APIBaseUrl   string
	IsDev        bool
	DevServerUrl string

	InstanceID *string

	Platform    *string
	SDKVersion  string
	SDKLanguage string

	RewriteGatewayEndpoint func(endpoint url.URL) (url.URL, error)
}

type WorkerConnection

type WorkerConnection interface {
	// State returns the current connection state.
	State() ConnectionState

	// Close connection gracefully.
	Close() error
}

func Connect

func Connect(ctx context.Context, opts Opts, invokers map[string]FunctionInvoker, logger *slog.Logger) (WorkerConnection, error)

Jump to

Keyboard shortcuts

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