Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- type ClientListenHandler
- type ClientPeerRef
- func (r *ClientPeerRef) GetLocalPeerID() peer.ID
- func (r *ClientPeerRef) GetRemotePeerID() peer.ID
- func (r *ClientPeerRef) Recv(ctx context.Context) (*peer.SignedMsg, error)
- func (r *ClientPeerRef) Release()
- func (r *ClientPeerRef) Send(ctx context.Context, msg []byte) (_ *peer.SignedMsg, outErr error)
- type Config
- func (m *Config) CloneMessageVT() proto.Message
- func (m *Config) CloneVT() *Config
- func (*Config) Descriptor() ([]byte, []int)deprecated
- func (this *Config) EqualMessageVT(thatMsg proto.Message) bool
- func (this *Config) EqualVT(that *Config) bool
- func (c *Config) EqualsConfig(other config.Config) bool
- func (x *Config) GetBackoff() *backoff.Backoff
- func (x *Config) GetClient() *client.Config
- func (c *Config) GetConfigID() string
- func (c *Config) GetDebugVals() config.DebugValues
- func (x *Config) GetDisableListen() bool
- func (x *Config) GetPeerId() string
- func (x *Config) GetProtocolId() string
- func (x *Config) GetServiceId() string
- func (x *Config) GetSignalingId() string
- func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *Config) MarshalToVT(dAtA []byte) (int, error)
- func (m *Config) MarshalVT() (dAtA []byte, err error)
- func (c *Config) ParsePeerID() (peer.ID, error)
- func (c *Config) ParseProtocolID() (protocol.ID, error)
- func (*Config) ProtoMessage()
- func (x *Config) ProtoReflect() protoreflect.Message
- func (x *Config) Reset()
- func (m *Config) SizeVT() (n int)
- func (x *Config) String() string
- func (m *Config) UnmarshalVT(dAtA []byte) error
- func (c *Config) Validate() error
- type Controller
- type Factory
- type Session
Constants ¶
const ConfigID = ControllerID
ConfigID is the string used to identify this config object.
const ControllerID = "bifrost/signaling/rpc/client"
ControllerID is the ID of the controller.
Variables ¶
var File_github_com_aperturerobotics_bifrost_signaling_rpc_client_config_proto protoreflect.FileDescriptor
var Version = semver.MustParse("0.0.1")
Version is the version of the controller implementation.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements a signaling service client. Tracks a set of ongoing Session RPCs. Manages backpressure on senders across the signaling channel. Manages validating and signing messages with the peer private key.
func NewClient ¶
func NewClient( le *logrus.Entry, c signaling_rpc.SRPCSignalingClient, privKey crypto.PrivKey, backoffConf *backoff.Backoff, ) (*Client, error)
NewClient constructs a new client.
func NewClientWithBus ¶
func NewClientWithBus( le *logrus.Entry, b bus.Bus, privKey crypto.PrivKey, clientConf *stream_srpc_client.Config, protocolID protocol.ID, serviceID string, ) (*Client, error)
NewClientWithBus constructs a new client that contacts the server via a Bifrost stream.
If protocolID is empty, uses the default signaling protocol id. If serviceID is empty, uses the default signaling service id.
func (*Client) AddPeerRef ¶
func (c *Client) AddPeerRef(remotePeerID string) *ClientPeerRef
AddPeerRef adds a reference to a remote peer. Initiates a session with the remote peer that can send/recv messages. Be sure to release the ref when done with it.
func (*Client) ClearContext ¶
func (c *Client) ClearContext()
ClearContext clears the context for the client.
func (*Client) SetContext ¶
SetContext sets the context for the client. Until this is called, the client will do nothing.
func (*Client) SetListenHandler ¶
func (c *Client) SetListenHandler(listenHandler ClientListenHandler)
SetListenHandler sets the handler to call when the Listen RPC returns a peer to contact. If nil, disables the Listen RPC.
listenHandler: if set, calls Listen and updates the handler when the list of remote peers that want a session with the local peer changes.
listenHandler is called with reset=true when the list is cleared.
SetContext must also be called to start the Listen RPC routine.
type ClientListenHandler ¶
ClientListenHandler is a function to handle when the incoming sessions list changes.
pid is the peer id in string format.
type ClientPeerRef ¶
type ClientPeerRef struct {
// contains filtered or unexported fields
}
ClientPeerRef is a reference to a client peer.
func (*ClientPeerRef) GetLocalPeerID ¶
func (r *ClientPeerRef) GetLocalPeerID() peer.ID
GetLocalPeerID returns the local peer ID.
func (*ClientPeerRef) GetRemotePeerID ¶
func (r *ClientPeerRef) GetRemotePeerID() peer.ID
GetRemotePeerID returns the remote peer ID.
func (*ClientPeerRef) Release ¶
func (r *ClientPeerRef) Release()
Release releases the peer reference.
type Config ¶
type Config struct { // SignalingId is the signaling channel ID. // Filters which SignalPeer directives will be handled. SignalingId string `protobuf:"bytes,1,opt,name=signaling_id,json=signalingId,proto3" json:"signaling_id,omitempty"` // PeerId is the local peer id to use for the client. // Can be empty to use any local peer. PeerId string `protobuf:"bytes,2,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"` // Client contains srpc.client configuration for the signaling RPC client. // The local peer ID is overridden with the peer ID of the looked-up peer. Client *client.Config `protobuf:"bytes,3,opt,name=client,proto3" json:"client,omitempty"` // ProtocolId overrides the default protocol id for the signaling client. // Default: bifrost/signaling ProtocolId string `protobuf:"bytes,4,opt,name=protocol_id,json=protocolId,proto3" json:"protocol_id,omitempty"` // ServiceId overrides the default service id for the signaling client. // Default: signaling.rpc.Signaling ServiceId string `protobuf:"bytes,5,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` // Backoff is the backoff config for connecting to the service. // If unset, defaults to reasonable defaults. Backoff *backoff.Backoff `protobuf:"bytes,6,opt,name=backoff,proto3" json:"backoff,omitempty"` // DisableListen disables listening for incoming sessions. // If set, we will only call out, not accept incoming sessions. // If false, client will emit HandleSignalPeer directives for incoming sessions. DisableListen bool `protobuf:"varint,7,opt,name=disable_listen,json=disableListen,proto3" json:"disable_listen,omitempty"` // contains filtered or unexported fields }
Config configures a client for the Signaling SRPC service.
func (*Config) CloneMessageVT ¶
func (*Config) Descriptor
deprecated
func (*Config) EqualsConfig ¶
EqualsConfig checks if the other config is equal.
func (*Config) GetBackoff ¶
func (*Config) GetConfigID ¶
GetConfigID returns the unique string for this configuration type. This string is stored with the encoded config.
func (*Config) GetDebugVals ¶
func (c *Config) GetDebugVals() config.DebugValues
GetDebugVals returns the directive arguments as key/value pairs. This should be something like param1="test", param2="test". This is not necessarily unique, and is primarily intended for display.
func (*Config) GetDisableListen ¶
func (*Config) GetProtocolId ¶
func (*Config) GetServiceId ¶
func (*Config) GetSignalingId ¶
func (*Config) MarshalToSizedBufferVT ¶
func (*Config) ParsePeerID ¶
ParsePeerID parses the session peer ID.
func (*Config) ParseProtocolID ¶
ParseProtocolID parses the signaling protocol id if it is not empty.
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) ProtoReflect ¶
func (x *Config) ProtoReflect() protoreflect.Message
func (*Config) UnmarshalVT ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is the signaling client controller.
func NewController ¶
NewController constructs a new signaling client controller.
func (*Controller) Close ¶
func (c *Controller) Close() error
Close releases any resources used by the controller. Error indicates any issue encountered releasing.
func (*Controller) Execute ¶
func (c *Controller) Execute(ctx context.Context) error
Execute executes the controller goroutine. Returning nil ends execution. Returning an error triggers a retry with backoff.
func (*Controller) GetControllerInfo ¶
func (c *Controller) GetControllerInfo() *controller.Info
GetControllerInfo returns information about the controller.
func (*Controller) HandleDirective ¶
func (c *Controller) HandleDirective(ctx context.Context, di directive.Instance) ([]directive.Resolver, error)
HandleDirective asks if the handler can resolve the directive. If it can, it returns resolver(s). If not, returns nil. It is safe to add a reference to the directive during this call. The passed context is canceled when the directive instance expires. NOTE: the passed context is not canceled when the handler is removed.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory constructs a Signaling RPC Client.
func (*Factory) Construct ¶
func (t *Factory) Construct( conf config.Config, opts controller.ConstructOpts, ) (controller.Controller, error)
Construct constructs the associated controller given configuration.
func (*Factory) ConstructConfig ¶
ConstructConfig constructs an instance of the controller configuration.
func (*Factory) GetConfigID ¶
GetConfigID returns the configuration ID for the controller.
func (*Factory) GetControllerID ¶
GetControllerID returns the unique ID for the controller.
func (*Factory) GetVersion ¶
GetVersion returns the version of this controller.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session implements signaling.Session.
func NewSessionWithRef ¶
func NewSessionWithRef(ref *ClientPeerRef) *Session
NewSessionWithRef wraps a ClientPeerRef into a signaling.Session.
func (*Session) GetLocalPeerID ¶
GetLocalPeerID returns the local peer ID.
func (*Session) GetRemotePeerID ¶
GetRemotePeerID returns the remote peer ID.