call

package
v0.1.61 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	SocketCodeUnknownProtocol = 3999
	SocketCodeExcessTraffic   = 3998
	SocketCodeBadCallID       = 3997
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CallFunc added in v0.1.58

type CallFunc[Init any] func(transport.Transport, Init) error

CallFunc is invoked for each new remote call.

type CallHandler

type CallHandler[Init any] interface {
	Init(context.Context, *http.Request) (Init, error)
	Call(transport.Transport, Init) error
}

type Handler

type Handler[Init any] struct {
	// CallHandler points to an object which implements Init and Call.
	// It takes preference over InitFunc/CallFunc.
	CallHandler CallHandler[Init]

	// InitFunc, if non-nil, handles the initial request and generates an Init.
	// Init is JSON-encoded to the caller, so make sure that it reveals fields intentionally.
	InitFunc func(context.Context, *http.Request) (Init, error)

	// CallFunc is invoked for each call.
	CallFunc CallFunc[Init]

	// SkipOriginVerify allows any hostname to connect here, not just our own.
	SkipOriginVerify bool

	// CallLimit optionally limits the number of calls allowed by a single session.
	// This is probably just each WebSocket connection.
	// A session will be killed if it exceeds this rate; the client must know it too.
	CallLimit *LimitConfig

	// PacketLimit optionally limits the number of packets allowed across all calls.
	// This includes call setup/metadata packets.
	// A session will be killed if it exceeds this rate; the client must know it too.
	PacketLimit *LimitConfig
	// contains filtered or unexported fields
}

Handler describes a call handler type that can be served over HTTP.

func (*Handler[Init]) ServeHTTP

func (ch *Handler[Init]) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LimitConfig

type LimitConfig struct {
	Burst int        `json:"b"`
	Rate  rate.Limit `json:"r"`
}

Jump to

Keyboard shortcuts

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