client

package
v2.0.0-pre0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultInputBufferLength = 100

DefaultInputBufferLength is the default size of the event buffer for events coming in from NATS

View Source
const DefaultRequestTimeout = 200 * time.Millisecond

DefaultRequestTimeout is the default timeout for a NATS request

Variables

View Source
var DefaultClusterMaxAge = 5 * time.Minute

DefaultClusterMaxAge is the default maximum age for cluster members to be considered by this client

View Source
var ErrNil = errors.New("Nil")

ErrNil indicates that the request returned an empty response

View Source
var Logger = log15.New()

Logger defaults to a discard handler (null output). If you wish to enable logging, you can set your own handler like so:

ari.Logger.SetHandler(log15.StderrHandler)

Functions

func ErrorToMap

func ErrorToMap(err error, parent string) map[string]interface{}

ErrorToMap converts an error type to a key-value map

func Listen

func Listen(ctx context.Context, nc *nats.EncodedConn, appName string, h Handler) error

Listen listens for an AppStart event and calls the handler when an event comes in

TODO: this should go away, with V2. similar functionality can be offered by a method on Client which generates a dialog and a new client for each StasisStart.

func MapToError

func MapToError(i map[string]interface{}) error

MapToError converts a JSON parsed map to an error type

Types

type Client

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

Client provides an ari.Client for an ari-proxy server

func New

func New(ctx context.Context, opts ...OptionFunc) (*Client, error)

New creates a new Client to the Asterisk ARI NATS proxy.

func (*Client) Application

func (c *Client) Application() ari.Application

Application is the application operation accessor

func (*Client) ApplicationName

func (c *Client) ApplicationName() string

ApplicationName returns the ARI application's name

func (*Client) Asterisk

func (c *Client) Asterisk() ari.Asterisk

Asterisk is the asterisk operation accessor

func (*Client) Bridge

func (c *Client) Bridge() ari.Bridge

Bridge is the bridge operation accessor

func (*Client) Bus

func (c *Client) Bus() ari.Bus

Bus is the bus operation accessor

func (*Client) Channel

func (c *Client) Channel() ari.Channel

Channel is the channel operation accessor

func (Client) ClientClosed

func (c Client) ClientClosed()

clientClosed is called any time a derived ARI client is closed; if the reference counter is ever dropped to zero, the core is also shut down

func (*Client) Close

func (c *Client) Close()

Close shuts down the client

func (*Client) DeviceState

func (c *Client) DeviceState() ari.DeviceState

DeviceState is the device state operation accessor

func (*Client) Endpoint

func (c *Client) Endpoint() ari.Endpoint

Endpoint is the endpoint accessor

func (*Client) LiveRecording

func (c *Client) LiveRecording() ari.LiveRecording

LiveRecording is the live recording accessor

func (*Client) Mailbox

func (c *Client) Mailbox() ari.Mailbox

Mailbox is the mailbox accessor

func (*Client) New

func (c *Client) New() *Client

New returns a new client from the existing one. The new client will have a separate event bus and lifecycle, allowing the closure of all subscriptions and handles derived from the client by simply closing the client. The underlying NATS connection and cluster awareness (the common Core) will be preserved across derived Client lifecycles.

func (*Client) Playback

func (c *Client) Playback() ari.Playback

Playback is the media playback accessor

func (*Client) Sound

func (c *Client) Sound() ari.Sound

Sound is the sound accessor

func (Client) Start

func (c Client) Start() error

func (*Client) StoredRecording

func (c *Client) StoredRecording() ari.StoredRecording

StoredRecording is the stored recording accessor

func (*Client) TextMessage

func (c *Client) TextMessage() ari.TextMessage

TextMessage is the text message accessor

func (*Client) TimeoutCount

func (c *Client) TimeoutCount() int64

TimeoutCount is the amount of times the NATS communication times out

type Handler

Handler defines a function which is called when a new dialog is created

type OptionFunc

type OptionFunc func(*Client)

OptionFunc is a function which configures options on a Client

func FromClient

func FromClient(cl ari.Client) OptionFunc

FromClient configures the ARI Application to use the transport details from another ARI Client. Transport-related details are copied, such as the NATS Client, the NATS prefix, the timeout values.

Specifically NOT copied are dialog, application, and asterisk details.

NOTE: use of this function will cause NATS connection leakage if there is a mix of uses of FromClient and not over a period of time. If you intend to use FromClient, it is recommended that you always pass a NATS client in to the first ari.Client and maintain lifecycle control of it manually.

func WithApplication

func WithApplication(name string) OptionFunc

WithApplication configures the ARI Client to use the provided ARI Application

func WithLogHandler

func WithLogHandler(h log15.Handler) OptionFunc

WithLogHandler sets the logging handler on a Client logger

func WithLogger

func WithLogger(l log15.Logger) OptionFunc

WithLogger sets the logger on a Client.

func WithNATS

func WithNATS(nc *nats.EncodedConn) OptionFunc

WithNATS binds an existing NATS connection

func WithPrefix

func WithPrefix(prefix string) OptionFunc

WithPrefix configures the NATS Prefix to use on a Client

func WithTimeoutRetries

func WithTimeoutRetries(count int) OptionFunc

WithTimeoutRetries configures the amount of times to retry on request timeout for a Client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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