Documentation
¶
Index ¶
- Constants
- Variables
- func CanBe[T, I any]() bool
- func NewResolveDecodeError(err error) error
- func NewResolveError(kind ResolveErrorKind, err error, msg string) error
- func NewResolveHTTPError(err error, format string, args ...interface{}) error
- func NewResolveLookupError(msg string) error
- func NewResolveStatusError(statusCode int) error
- func Propagator() propagation.TextMapPropagator
- func RegisterInterface[T any](fn any) bool
- func SetupOTelSDK(ctx context.Context) (shutdown func(context.Context) error, err error)
- func Tracer() otrace.Tracer
- func WithRequireClientCerts(o *stateOptions)
- func WithSkipVerify(o *stateOptions)
- func Zero[T any]() T
- type ActorCall
- type ActorClient
- func (a *ActorClient) Call(ctx context.Context, name string, arg, ret any) error
- func (a *ActorClient) CallWithCaps(ctx context.Context, method string, args, result any, ...) error
- func (a *ActorClient) Close() error
- func (a *ActorClient) NewClient(capa *Capability) Client
- func (a *ActorClient) NewInlineCapability(i *Interface, lower any) (*InlineCapability, OID, *Capability)
- type ActorRegistry
- type ActorResolver
- type Authenticator
- type Call
- type Capability
- type Client
- type CurrentConnectionInfo
- type DebugAuthResponse
- type DescField
- type DescFile
- type DescInterface
- type DescMethods
- type DescParamater
- type DescType
- type Dispatcher
- type ErrorCategory
- type ErrorCode
- type ErrorMessage
- type ForbidRestore
- type Generator
- type HasReconstructFromState
- type HasRestoreState
- type IfaceReg
- type Import
- type InlineCapability
- type Interface
- type InterfaceCreators
- type InterfaceDescriptor
- type InterfaceState
- type LocalActorRegistry
- type Method
- type NetworkCall
- type NetworkClient
- func (c *NetworkClient) Call(ctx context.Context, method string, args, result any) error
- func (c *NetworkClient) CallWithCaps(ctx context.Context, method string, args, result any, ...) error
- func (c *NetworkClient) Close() error
- func (c *NetworkClient) NewCapability(i *Interface, lower any) *Capability
- func (c *NetworkClient) NewClient(capa *Capability) Client
- func (c *NetworkClient) NewInlineCapability(i *Interface, lower any) (*InlineCapability, OID, *Capability)
- func (c *NetworkClient) String() string
- type NoOpAuthenticator
- type NoRestore
- type OID
- type ResolveError
- type ResolveErrorKind
- type ResolverFunc
- type Server
- type State
- type StateCommon
- type StateOption
- func WithAuthenticator(auth Authenticator) StateOption
- func WithBearerToken(token string) StateOption
- func WithBindAddr(addr string) StateOption
- func WithCert(certPath, keyPath string) StateOption
- func WithCertPEMs(certData, keyData []byte) StateOption
- func WithCertificateVerification(caCert []byte) StateOption
- func WithEndpoint(endpoint string) StateOption
- func WithLocalConnect(addr string) StateOption
- func WithLocalServer(addr string) StateOption
- func WithLogLevel(level slog.Level) StateOption
- func WithLogger(log *slog.Logger) StateOption
- type UnionField
Constants ¶
const ( TypeRW = iota TypeR TypeW )
const BootstrapOID = "!bootstrap"
Variables ¶
var ( ErrResolveHTTP = &ResolveError{Kind: ResolveHTTPError, Msg: "http request error"} ErrResolveStatus = &ResolveError{Kind: ResolveStatusError, Msg: "unexpected status code"} ErrResolveDecode = &ResolveError{Kind: ResolveDecodeError, Msg: "decode error"} ErrResolveLookup = &ResolveError{Kind: ResolveLookupError, Msg: "lookup error"} )
Exported sentinel errors for common resolve error kinds
Functions ¶
func NewResolveDecodeError ¶
NewResolveDecodeError creates a decode error
func NewResolveError ¶
func NewResolveError(kind ResolveErrorKind, err error, msg string) error
NewResolveError creates a new ResolveError with the specified kind and underlying error
func NewResolveHTTPError ¶
NewResolveHTTPError creates an HTTP request error
func NewResolveLookupError ¶
NewResolveLookupError creates a lookup error
func NewResolveStatusError ¶
NewResolveStatusError creates a status code error
func Propagator ¶
func Propagator() propagation.TextMapPropagator
func RegisterInterface ¶
func SetupOTelSDK ¶
setupOTelSDK bootstraps the OpenTelemetry pipeline. If it does not return an error, make sure to call shutdown for proper cleanup.
func WithRequireClientCerts ¶
func WithRequireClientCerts(o *stateOptions)
func WithSkipVerify ¶
func WithSkipVerify(o *stateOptions)
Types ¶
type ActorCall ¶
type ActorCall struct {
// contains filtered or unexported fields
}
func (*ActorCall) NewCapability ¶
func (a *ActorCall) NewCapability(i *Interface) *Capability
func (*ActorCall) NewClient ¶
func (a *ActorCall) NewClient(capa *Capability) Client
type ActorClient ¶
type ActorClient struct {
// contains filtered or unexported fields
}
func (*ActorClient) CallWithCaps ¶
func (a *ActorClient) CallWithCaps(ctx context.Context, method string, args, result any, caps map[OID]*InlineCapability) error
func (*ActorClient) Close ¶
func (a *ActorClient) Close() error
func (*ActorClient) NewClient ¶
func (a *ActorClient) NewClient(capa *Capability) Client
func (*ActorClient) NewInlineCapability ¶
func (a *ActorClient) NewInlineCapability(i *Interface, lower any) (*InlineCapability, OID, *Capability)
type ActorRegistry ¶
type ActorRegistry interface {
Register(ctx context.Context, name string, iface *Interface) error
Client(ctx context.Context, name string) (Client, error)
Close(ctx context.Context) error
}
func NewLocalActorRegistry ¶
func NewLocalActorRegistry() ActorRegistry
type ActorResolver ¶
type Authenticator ¶
type Authenticator interface {
// AuthenticateRequest authenticates an HTTP request and returns whether it's allowed
// It can check JWT tokens, certificates, or other authentication methods
AuthenticateRequest(ctx context.Context, r *http.Request) (authenticated bool, identity string, err error)
// NoAuthorization is called when a request has no Authorization header
// This allows the authenticator to decide if such requests should be allowed
// (e.g., based on client certificates or to enforce mandatory authentication)
NoAuthorization(ctx context.Context, r *http.Request) (allowed bool, identity string, err error)
}
Authenticator is an interface for authenticating RPC requests
type Call ¶
type Call interface {
NewClient(capa *Capability) Client
Args(v any)
Results(v any)
NewCapability(i *Interface) *Capability
}
type Capability ¶
type Capability struct {
OID OID `cbor:"0,keyasint" json:"oid"`
Address string `cbor:"1,keyasint" json:"address"`
User []byte `cbor:"2,keyasint" json:"owner"`
Issuer []byte `cbor:"3,keyasint" json:"issue"`
RestoreState *InterfaceState `cbor:"4,keyasint" json:"restore-state"`
Inline bool `cbor:"5,keyasint" json:"inline"`
}
type Client ¶
type Client interface {
CallWithCaps(ctx context.Context, method string, args, result any, caps map[OID]*InlineCapability) error
Call(ctx context.Context, method string, args, result any) error
NewInlineCapability(i *Interface, lower any) (*InlineCapability, OID, *Capability)
NewClient(capa *Capability) Client
Close() error
}
type CurrentConnectionInfo ¶
type CurrentConnectionInfo struct {
PeerSubject string
}
func ConnectionInfo ¶
func ConnectionInfo(ctx context.Context) *CurrentConnectionInfo
type DebugAuthResponse ¶
type DebugAuthResponse struct {
Success bool `json:"success"`
ServerVersion string `json:"server_version,omitempty"`
AuthMethod string `json:"auth_method,omitempty"`
Identity string `json:"identity,omitempty"`
UserInfo map[string]string `json:"user_info,omitempty"`
Message string `json:"message,omitempty"`
}
DebugAuthResponse represents the response from the debug-auth endpoint
type DescField ¶
type DescField struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
Index int `yaml:"index"`
Element string `yaml:"element"`
Union []UnionField `yaml:"union,omitempty"`
// contains filtered or unexported fields
}
type DescFile ¶
type DescFile struct {
Imports map[string]Import `yaml:"imports"`
Types []*DescType `yaml:"types"`
Interfaces []*DescInterface `yaml:"interfaces"`
}
type DescInterface ¶
type DescInterface struct {
Name string `yaml:"name"`
Method []*DescMethods `yaml:"methods"`
Generic []string `yaml:"generic,omitempty"`
Constraints []string `yaml:"constraints,omitempty"`
}
type DescMethods ¶
type DescMethods struct {
Name string `yaml:"name"`
Index int `yaml:"index"`
Parameters []*DescParamater `yaml:"parameters"`
Results []*DescParamater `yaml:"results"`
}
type DescParamater ¶
type DescType ¶
type DescType struct {
Type string `yaml:"type"`
Fields []*DescField `yaml:"fields"`
Compact bool `yaml:"compact,omitempty"`
Generic []string `yaml:"generic,omitempty"`
Constraints []string `yaml:"constraints,omitempty"`
// contains filtered or unexported fields
}
func (*DescType) CalculateOffsets ¶
type Dispatcher ¶
type ErrorCategory ¶
type ErrorCategory interface {
ErrorCategory() string
}
type ErrorMessage ¶
type ErrorMessage interface {
ErrorMessage() string
}
type ForbidRestore ¶
type ForbidRestore interface {
// contains filtered or unexported methods
}
type Generator ¶
type Generator struct {
Imports map[string]Import
Types []*DescType
Interfaces []*DescInterface
// contains filtered or unexported fields
}
func NewGenerator ¶
type HasReconstructFromState ¶
type HasReconstructFromState interface {
ReconstructFromState(is *InterfaceState) (*Interface, error)
}
type HasRestoreState ¶
type IfaceReg ¶
type IfaceReg struct {
// contains filtered or unexported fields
}
func NewIfaceReg ¶
func NewIfaceReg() *IfaceReg
type InlineCapability ¶
type InlineCapability struct {
*Capability
*Interface
}
type Interface ¶
type Interface struct {
// contains filtered or unexported fields
}
func NewInterface ¶
func (*Interface) SetAroundContext ¶
type InterfaceCreators ¶
type InterfaceCreators struct {
// contains filtered or unexported fields
}
func NewInterfaceCreators ¶
func NewInterfaceCreators() *InterfaceCreators
type InterfaceDescriptor ¶
type InterfaceDescriptor struct {
}
type InterfaceState ¶
type InterfaceState struct {
Category string `cbor:"0,keyasint" json:"category"`
Interface string `cbor:"1,keyasint" json:"interface"`
Data any `cbor:"2,keyasint" json:"data"`
}
func (*InterfaceState) Decode ¶
func (i *InterfaceState) Decode(v any) error
type LocalActorRegistry ¶
type LocalActorRegistry struct {
// contains filtered or unexported fields
}
type NetworkCall ¶
type NetworkCall struct {
// contains filtered or unexported fields
}
func Local ¶
func Local(args ...any) *NetworkCall
func (*NetworkCall) Args ¶
func (c *NetworkCall) Args(v any)
func (*NetworkCall) NewCapability ¶
func (c *NetworkCall) NewCapability(i *Interface) *Capability
func (*NetworkCall) NewClient ¶
func (c *NetworkCall) NewClient(capa *Capability) Client
func (*NetworkCall) RemoteAddr ¶
func (c *NetworkCall) RemoteAddr() string
func (*NetworkCall) Results ¶
func (c *NetworkCall) Results(v any)
func (*NetworkCall) String ¶
func (c *NetworkCall) String() string
type NetworkClient ¶
type NetworkClient struct {
State *State
// contains filtered or unexported fields
}
func LocalClient ¶
func LocalClient(iface *Interface) *NetworkClient
func (*NetworkClient) CallWithCaps ¶
func (c *NetworkClient) CallWithCaps(ctx context.Context, method string, args, result any, caps map[OID]*InlineCapability) error
func (*NetworkClient) Close ¶
func (c *NetworkClient) Close() error
func (*NetworkClient) NewCapability ¶
func (c *NetworkClient) NewCapability(i *Interface, lower any) *Capability
func (*NetworkClient) NewClient ¶
func (c *NetworkClient) NewClient(capa *Capability) Client
func (*NetworkClient) NewInlineCapability ¶
func (c *NetworkClient) NewInlineCapability(i *Interface, lower any) (*InlineCapability, OID, *Capability)
func (*NetworkClient) String ¶
func (c *NetworkClient) String() string
type NoOpAuthenticator ¶
type NoOpAuthenticator struct{}
NoOpAuthenticator is a no-op authenticator that allows all requests
func (*NoOpAuthenticator) AuthenticateRequest ¶
func (*NoOpAuthenticator) NoAuthorization ¶
type ResolveError ¶
type ResolveError struct {
Kind ResolveErrorKind
Err error
Msg string
StatusCode int // HTTP status code for ResolveStatusError
}
ResolveError represents an error that occurred during capability resolution
func (*ResolveError) Error ¶
func (e *ResolveError) Error() string
func (*ResolveError) Is ¶
func (e *ResolveError) Is(target error) bool
func (*ResolveError) Unwrap ¶
func (e *ResolveError) Unwrap() error
type ResolveErrorKind ¶
type ResolveErrorKind int
ResolveErrorKind represents different kinds of capability resolution errors
const ( ResolveHTTPError ResolveErrorKind = iota ResolveStatusError ResolveDecodeError ResolveLookupError )
type ResolverFunc ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ExposeValue ¶
type State ¶
type State struct {
*StateCommon
// contains filtered or unexported fields
}
func (*State) ListenAddr ¶
func (*State) LoopbackAddr ¶
type StateCommon ¶
type StateCommon struct {
// contains filtered or unexported fields
}
type StateOption ¶
type StateOption func(*stateOptions)
func WithAuthenticator ¶
func WithAuthenticator(auth Authenticator) StateOption
func WithBearerToken ¶
func WithBearerToken(token string) StateOption
func WithBindAddr ¶
func WithBindAddr(addr string) StateOption
func WithCert ¶
func WithCert(certPath, keyPath string) StateOption
func WithCertPEMs ¶
func WithCertPEMs(certData, keyData []byte) StateOption
func WithCertificateVerification ¶
func WithCertificateVerification(caCert []byte) StateOption
func WithEndpoint ¶
func WithEndpoint(endpoint string) StateOption
func WithLocalConnect ¶
func WithLocalConnect(addr string) StateOption
func WithLocalServer ¶
func WithLocalServer(addr string) StateOption
func WithLogLevel ¶
func WithLogLevel(level slog.Level) StateOption
func WithLogger ¶
func WithLogger(log *slog.Logger) StateOption