rtppool

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package rtppool routes signaling control requests across multiple RTP media nodes.

Nodes are discovered dynamically: RTP servers register with the signaling server's HTTP control API and send periodic heartbeats. Static seed URLs (RTP_CONTROL_URLS) remain supported for local development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseControlURLs

func ParseControlURLs(urlsEnv, singleEnv string) []string

ParseControlURLs reads RTP_CONTROL_URLS (comma-separated) or RTP_CONTROL_URL. Empty env returns no seeds — RTP nodes are expected to register instead.

func PublicControlURL

func PublicControlURL(publicEnv, mediaIP string, port int) string

PublicControlURL builds the control URL RTP advertises to signaling.

func RegisterHTTP

func RegisterHTTP(mux *http.ServeMux, pool *Pool)

RegisterHTTP mounts the signaling-side node registry API on mux.

Types

type Node

type Node struct {
	ID         string
	ControlURL string
	MediaIP    string
	ActiveLegs int
	Healthy    bool
	Static     bool
	LastSeen   time.Time
}

Node is one RTP media server's control plane endpoint.

type Pool

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

Pool selects RTP nodes and remembers which node owns each Call-ID.

func New

func New(client *http.Client, seedURLs ...string) *Pool

New creates an empty pool. Optional seed URLs are treated as static nodes.

func (*Pool) Delete

func (p *Pool) Delete(callID string) error

Delete removes the leg on the bound node.

func (*Pool) NodeInfos

func (p *Pool) NodeInfos() []controlapi.NodeInfo

NodeInfos returns registered nodes for the signaling HTTP list API.

func (*Pool) Nodes

func (p *Pool) Nodes() []Node

Nodes returns a snapshot after refreshing health from all backends.

func (*Pool) Prepare

func (p *Pool) Prepare(callID, offerSDP string) (*controlapi.PrepareLegResponse, string, error)

Prepare allocates a media leg on the least-loaded healthy node (with failover).

func (*Pool) Prune

func (p *Pool) Prune() int

Prune drops dynamic nodes that have not heartbeated within TTL.

func (*Pool) Refresh

func (p *Pool) Refresh()

Refresh probes /v1/health on every known node.

func (*Pool) Register

Register adds or refreshes a dynamically registered RTP node.

func (*Pool) SetTTL

func (p *Pool) SetTTL(d time.Duration)

SetTTL overrides the expiry window for dynamically registered nodes.

func (*Pool) Start

func (p *Pool) Start(callID string) error

Start activates the leg on the node that prepared it.

func (*Pool) Unregister

func (p *Pool) Unregister(nodeID string) bool

Unregister removes a dynamically registered node.

type Registrar

type Registrar struct {
	Client   *http.Client
	Registry string // signaling HTTP base URL, e.g. http://host:8080
	Node     controlapi.RegisterNodeRequest
	Interval time.Duration
	LegCount func() int // optional; sent as active_legs on each heartbeat
}

Registrar heartbeats an RTP node to the signaling server's registry API.

func NewRegistrar

func NewRegistrar(client *http.Client, registryURL string, node controlapi.RegisterNodeRequest) *Registrar

NewRegistrar builds a registrar with a default 10s heartbeat interval.

func (*Registrar) Deregister

func (r *Registrar) Deregister(ctx context.Context) error

Deregister removes this node from the signaling pool (best-effort).

func (*Registrar) Run

func (r *Registrar) Run(ctx context.Context) error

Run registers immediately, then heartbeats until ctx is cancelled.

Jump to

Keyboard shortcuts

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