grpc

package
v0.5.33 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package grpc implements a signaling backend using a central gRPC service

Index

Constants

View Source
const (
	DefaultRelayTTL = 1 * time.Hour
)

Variables

This section is empty.

Functions

func NewBackend

func NewBackend(cfg *signaling.BackendConfig, logger *log.Logger) (signaling.Backend, error)

func NewServer

func NewServer(opts ...grpc.ServerOption) (*grpc.Server, error)

func ParseURL

func ParseURL(urlStr string) (string, []grpc.DialOption, error)

Types

type Backend

type Backend struct {
	signaling.SubscriptionsRegistry
	// contains filtered or unexported fields
}

func (*Backend) Close

func (b *Backend) Close() error

func (*Backend) Publish

func (b *Backend) Publish(ctx context.Context, kp *crypto.KeyPair, msg *signaling.Message) error

func (*Backend) Subscribe

func (b *Backend) Subscribe(ctx context.Context, kp *crypto.KeyPair, h signaling.MessageHandler) (bool, error)

func (*Backend) Type

func (*Backend) Unsubscribe

func (b *Backend) Unsubscribe(ctx context.Context, kp *crypto.KeyPair, h signaling.MessageHandler) (bool, error)

Unsubscribe from messages send by a specific peer

type BackendConfig

type BackendConfig struct {
	signaling.BackendConfig

	Target  string
	Options []grpc.DialOption
}

func (*BackendConfig) Parse

func (c *BackendConfig) Parse(cfg *signaling.BackendConfig) error

type RelayAPIServer

type RelayAPIServer struct {
	signalingproto.UnimplementedRelayRegistryServer

	*grpc.Server
	// contains filtered or unexported fields
}

func NewRelayAPIServer

func NewRelayAPIServer(relays []RelayInfo, opts ...grpc.ServerOption) (*RelayAPIServer, error)

func (*RelayAPIServer) Close

func (s *RelayAPIServer) Close() error

func (*RelayAPIServer) GetRelays

type RelayInfo

type RelayInfo struct {
	URL   string
	Realm string

	Username string
	Password string

	TTL    time.Duration
	Secret string
}

func NewRelayInfo

func NewRelayInfo(arg string) (RelayInfo, error)

func NewRelayInfos

func NewRelayInfos(args []string) ([]RelayInfo, error)

func (*RelayInfo) GetCredentials

func (s *RelayInfo) GetCredentials(username string) (string, string, time.Time)

type Server

type Server struct {
	signalingproto.UnimplementedSignalingServer

	*grpc.Server
	// contains filtered or unexported fields
}

func NewSignalingServer

func NewSignalingServer(opts ...grpc.ServerOption) *Server

func (*Server) Close

func (s *Server) Close() error

func (*Server) GetBuildInfo

func (s *Server) GetBuildInfo(context.Context, *proto.Empty) (*proto.BuildInfo, error)

func (*Server) Publish

func (s *Server) Publish(_ context.Context, env *signaling.Envelope) (*proto.Empty, error)

func (*Server) Subscribe

type Topic

type Topic struct {
	// contains filtered or unexported fields
}

func NewTopic

func NewTopic() *Topic

func (*Topic) Close

func (t *Topic) Close()

func (*Topic) Publish

func (t *Topic) Publish(env *signaling.Envelope)

func (*Topic) Subscribe

func (t *Topic) Subscribe() chan *signaling.Envelope

func (*Topic) Unsubscribe

func (t *Topic) Unsubscribe(ch chan *signaling.Envelope)

Jump to

Keyboard shortcuts

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