Documentation
¶
Index ¶
Constants ¶
View Source
const ( RemoteIDContextKey key = iota DefaultResponseBufferLen = 1024 )
Variables ¶
View Source
var ( ErrNotAFunction = errors.New("not a function") ErrInvalidArgsCount = errors.New("invalid argument count") ErrInvalidArg = errors.New("invalid argument, either the type doesn't match or is too complex and can't be inspected") ErrClosureDoesNotExist = errors.New("closure does not exist") )
View Source
var ( ErrInvalidFunctionCallPath = errors.New("invalid or empty function call path") ErrInvalidReturn = errors.New("invalid return, can only return an error or a value and an error") ErrReturnValueTooComplex = errors.New("invalid return, either the type doesn't match or is too complex and can't be inspected") ErrInvalidArgs = errors.New("invalid arguments, first argument needs to be a context.Context") ErrCannotCallNonFunction = errors.New("can not call non function") )
Functions ¶
func GetRemoteID ¶
Types ¶
type LinkHooks ¶
type LinkHooks RegistryHooks
type Message ¶
type Message[T any] struct { Request *T `json:"request"` Response *T `json:"response"` }
type Registry ¶
type Registry[R, T any] struct { // contains filtered or unexported fields }
Registry exposes local RPCs and implements remote RPCs
func NewRegistry ¶
func NewRegistry[R, T any]( local any, hooks *RegistryHooks, ) *Registry[R, T]
NewRegistry creates a new registry
func (Registry[R, T]) ForRemotes ¶
ForRemotes iterates over the list of connected remotes
func (Registry[R, T]) LinkMessage ¶
func (r Registry[R, T]) LinkMessage( ctx context.Context, writeRequest, writeResponse func(b T) error, readRequest, readResponse func() (T, error), marshal func(v any) (T, error), unmarshal func(data T, v any) error, hooks *LinkHooks, ) error
LinkMessage exposes local RPCs and implements remote RPCs via a message-based transport
func (Registry[R, T]) LinkStream ¶
func (r Registry[R, T]) LinkStream( ctx context.Context, encode func(v Message[T]) error, decode func(v *Message[T]) error, marshal func(v any) (T, error), unmarshal func(data T, v any) error, hooks *LinkHooks, ) error
LinkStream exposes local RPCs and implements remote RPCs via a stream-based transport
type RegistryHooks ¶
Click to show internal directories.
Click to hide internal directories.