Documentation ¶
Overview ¶
Package signaling implements various signaling backends to exchange encrypted messages between peers
Index ¶
- Variables
- type Backend
- type BackendConfig
- type BackendFactory
- type BackendPlugin
- type BackendReadyHandler
- type BackendType
- type Envelope
- type EnvelopeHandler
- type Message
- type MessageHandler
- type MultiBackend
- func (mb *MultiBackend) ByType(t signalingproto.BackendType) Backend
- func (mb *MultiBackend) Close() error
- func (mb *MultiBackend) Publish(ctx context.Context, kp *crypto.KeyPair, msg *Message) error
- func (mb *MultiBackend) Subscribe(ctx context.Context, kp *crypto.KeyPair, h MessageHandler) (bool, error)
- func (mb *MultiBackend) Type() signalingproto.BackendType
- func (mb *MultiBackend) Unsubscribe(ctx context.Context, kp *crypto.KeyPair, h MessageHandler) (bool, error)
- type Subscription
- type SubscriptionsRegistry
- func (s *SubscriptionsRegistry) GetOrCreateSubscription(sk *crypto.Key) (bool, *Subscription, error)
- func (s *SubscriptionsRegistry) GetSubscription(pk *crypto.Key) (*Subscription, error)
- func (s *SubscriptionsRegistry) NewMessage(env *Envelope) error
- func (s *SubscriptionsRegistry) NewSubscription(k *crypto.Key) (*Subscription, error)
- func (s *SubscriptionsRegistry) Subscribe(kp *crypto.KeyPair, h MessageHandler) (bool, error)
- func (s *SubscriptionsRegistry) Unsubscribe(kp *crypto.KeyPair, h MessageHandler) (bool, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Backends = map[BackendType]*BackendPlugin{} //nolint:gochecknoglobals ErrInvalidBackend = errors.New("unknown backend type") ErrClosed = errors.New("backend is closed") )
View Source
var (
ErrNotSubscribed = errors.New("missing subscription")
)
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { io.Closer // Publish a signaling message to a specific peer Publish(ctx context.Context, kp *crypto.KeyPair, msg *Message) error // Subscribe to messages send by a specific peer Subscribe(ctx context.Context, kp *crypto.KeyPair, h MessageHandler) (bool, error) // Unsubscribe from messages send by a specific peer Unsubscribe(ctx context.Context, kp *crypto.KeyPair, h MessageHandler) (bool, error) // Returns the backends type identifier Type() signalingproto.BackendType }
func NewBackend ¶
func NewBackend(cfg *BackendConfig) (Backend, error)
type BackendConfig ¶
type BackendConfig struct { URI *url.URL OnReady []BackendReadyHandler }
type BackendFactory ¶
type BackendFactory func(*BackendConfig, *log.Logger) (Backend, error)
type BackendPlugin ¶
type BackendPlugin struct { New BackendFactory Description string }
type BackendReadyHandler ¶
type BackendReadyHandler interface {
OnSignalingBackendReady(b Backend)
}
type BackendType ¶
type BackendType string // URL schemes
type Envelope ¶
type Envelope = signalingproto.Envelope
type EnvelopeHandler ¶
type EnvelopeHandler interface {
OnSignalingEnvelope(*Envelope)
}
type Message ¶
type Message = signalingproto.Message
type MessageHandler ¶
type MessageHandler interface {
OnSignalingMessage(*crypto.PublicKeyPair, *Message)
}
type MultiBackend ¶
type MultiBackend struct {
Backends []Backend
}
func NewMultiBackend ¶
func NewMultiBackend(uris []url.URL, cfg *BackendConfig) (*MultiBackend, error)
func (*MultiBackend) ByType ¶
func (mb *MultiBackend) ByType(t signalingproto.BackendType) Backend
func (*MultiBackend) Close ¶
func (mb *MultiBackend) Close() error
func (*MultiBackend) Subscribe ¶
func (mb *MultiBackend) Subscribe(ctx context.Context, kp *crypto.KeyPair, h MessageHandler) (bool, error)
func (*MultiBackend) Type ¶
func (mb *MultiBackend) Type() signalingproto.BackendType
func (*MultiBackend) Unsubscribe ¶
func (mb *MultiBackend) Unsubscribe(ctx context.Context, kp *crypto.KeyPair, h MessageHandler) (bool, error)
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func (*Subscription) AddMessageHandler ¶
func (s *Subscription) AddMessageHandler(pk *crypto.Key, h MessageHandler)
func (*Subscription) NewMessage ¶
func (s *Subscription) NewMessage(env *Envelope) error
func (*Subscription) RemoveMessageHandler ¶
func (s *Subscription) RemoveMessageHandler(pk *crypto.Key, h MessageHandler)
type SubscriptionsRegistry ¶
type SubscriptionsRegistry struct {
// contains filtered or unexported fields
}
func NewSubscriptionsRegistry ¶
func NewSubscriptionsRegistry() SubscriptionsRegistry
func (*SubscriptionsRegistry) GetOrCreateSubscription ¶
func (s *SubscriptionsRegistry) GetOrCreateSubscription(sk *crypto.Key) (bool, *Subscription, error)
func (*SubscriptionsRegistry) GetSubscription ¶
func (s *SubscriptionsRegistry) GetSubscription(pk *crypto.Key) (*Subscription, error)
func (*SubscriptionsRegistry) NewMessage ¶
func (s *SubscriptionsRegistry) NewMessage(env *Envelope) error
func (*SubscriptionsRegistry) NewSubscription ¶
func (s *SubscriptionsRegistry) NewSubscription(k *crypto.Key) (*Subscription, error)
func (*SubscriptionsRegistry) Subscribe ¶
func (s *SubscriptionsRegistry) Subscribe(kp *crypto.KeyPair, h MessageHandler) (bool, error)
func (*SubscriptionsRegistry) Unsubscribe ¶
func (s *SubscriptionsRegistry) Unsubscribe(kp *crypto.KeyPair, h MessageHandler) (bool, error)
Directories ¶
Path | Synopsis |
---|---|
Package grpc implements a signaling backend using a central gRPC service
|
Package grpc implements a signaling backend using a central gRPC service |
Package inprocess implements an in-process signaling backend using Go channels
|
Package inprocess implements an in-process signaling backend using Go channels |
Click to show internal directories.
Click to hide internal directories.