server

package
v5.0.0-...-099034c Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package server provides a proxy for ARI calls. It is usable via the client/nc Client and can use any given ari.Client

Index

Constants

View Source
const DefaultNATSReconnectionAttemts = 5

DefaultReconnectionAttemts is the default number of reconnection attempts It implements a hard coded fault tolerance for a starting NATS cluster

View Source
const DefaultNATSReconnectionWait = 5 * time.Second

DefaultNATSReconnectionWait is the default wating time between each reconnection attempt

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(subj string, request []byte, reply Reply)

Handler is left for compat

type Handler2

type Handler2 func(msg *session.Message, reply Reply)

A Handler2 is a function which provides a session-aware request-response for nats

type Metrics

type Metrics interface {
	OnEvent(id string)
	OnRequest(id string)
}

type Options

type Options struct {
	URL string

	Logger log15.Logger
	Parent context.Context
}

Options are the group of options for the ari-proxy server

type Reply

type Reply func(interface{}, error)

Reply is a function which, when called, replies to the request via the response object or error.

type Server

type Server struct {
	// Application is the name of the ARI application of this server
	Application string

	// AsteriskID is the unique identifier for the Asterisk box
	// to which this server is connected.
	AsteriskID string

	// NATSPrefix is the string which should be prepended to all NATS subjects, sending and receiving.  It defaults to "ari.".
	NATSPrefix string

	// Dialog is the dialog manager
	Dialog dialog.Manager

	// Log is the log15.Logger for the service.  You may replace or call SetHandler() on this at any time to change the logging of the service.
	Log log15.Logger

	// Metrics is optional and when provided ari-proxy invokes OnXXX when an event or request is received
	Metrics Metrics
	// contains filtered or unexported fields
}

Server describes the asterisk-facing ARI proxy server

func New

func New() *Server

New returns a new Server

func (*Server) Listen

func (s *Server) Listen(ctx context.Context, ariOpts *native.Options, natsURI string) (err error)

Listen runs the given server, listening to ARI and NATS, as specified

func (*Server) ListenOn

func (s *Server) ListenOn(ctx context.Context, a ari.Client, n *nats.EncodedConn) error

ListenOn runs the given server, listening on the provided ARI and NATS connections

func (*Server) Ready

func (s *Server) Ready() <-chan struct{}

Ready returns a channel which is closed when the Server is ready

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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