grpc

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 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 added in v0.2.1

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 added in v0.2.1

type RelayAPIServer struct {
	signalingproto.UnimplementedRelayRegistryServer

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

func NewRelayAPIServer added in v0.2.1

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

func (*RelayAPIServer) Close added in v0.2.1

func (s *RelayAPIServer) Close() error

func (*RelayAPIServer) GetRelays added in v0.2.1

type RelayInfo added in v0.2.1

type RelayInfo struct {
	URL   string
	Realm string

	Username string
	Password string

	TTL    time.Duration
	Secret string
}

func NewRelayInfo added in v0.2.1

func NewRelayInfo(arg string) (RelayInfo, error)

func NewRelayInfos added in v0.2.1

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

func (*RelayInfo) GetCredentials added in v0.2.1

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 added in v0.2.1

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 added in v0.2.5

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

func NewTopic

func NewTopic() *Topic

func (*Topic) Close added in v0.2.5

func (t *Topic) Close()

func (*Topic) Publish added in v0.2.5

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

func (*Topic) Subscribe added in v0.2.5

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

func (*Topic) Unsubscribe added in v0.2.5

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