Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorToMap(err error, parent string) map[string]interface{}
- func Listen(ctx context.Context, nc *nats.EncodedConn, appName string, h Handler) error
- func MapToError(i map[string]interface{}) error
- type Client
- func (c *Client) Application() ari.Application
- func (c *Client) ApplicationName() string
- func (c *Client) Asterisk() ari.Asterisk
- func (c *Client) Bridge() ari.Bridge
- func (c *Client) Bus() ari.Bus
- func (c *Client) Channel() ari.Channel
- func (c Client) ClientClosed()
- func (c *Client) Close()
- func (c *Client) DeviceState() ari.DeviceState
- func (c *Client) Endpoint() ari.Endpoint
- func (c *Client) LiveRecording() ari.LiveRecording
- func (c *Client) Mailbox() ari.Mailbox
- func (c *Client) New() *Client
- func (c *Client) Playback() ari.Playback
- func (c *Client) Sound() ari.Sound
- func (c Client) Start() error
- func (c *Client) StoredRecording() ari.StoredRecording
- func (c *Client) TextMessage() ari.TextMessage
- func (c *Client) TimeoutCount() int64
- type Handler
- type OptionFunc
- func FromClient(cl ari.Client) OptionFunc
- func WithApplication(name string) OptionFunc
- func WithLogHandler(h log15.Handler) OptionFunc
- func WithLogger(l log15.Logger) OptionFunc
- func WithNATS(nc *nats.EncodedConn) OptionFunc
- func WithPrefix(prefix string) OptionFunc
- func WithTimeoutRetries(count int) OptionFunc
Constants ¶
const DefaultInputBufferLength = 100
DefaultInputBufferLength is the default size of the event buffer for events coming in from NATS
const DefaultRequestTimeout = 200 * time.Millisecond
DefaultRequestTimeout is the default timeout for a NATS request
Variables ¶
var DefaultClusterMaxAge = 5 * time.Minute
DefaultClusterMaxAge is the default maximum age for cluster members to be considered by this client
var ErrNil = errors.New("Nil")
ErrNil indicates that the request returned an empty response
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 ¶
ErrorToMap converts an error type to a key-value map
func Listen ¶
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 ¶
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 ¶
ApplicationName returns the ARI application's name
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) DeviceState ¶
func (c *Client) DeviceState() ari.DeviceState
DeviceState is the device state operation accessor
func (*Client) LiveRecording ¶
func (c *Client) LiveRecording() ari.LiveRecording
LiveRecording is the live recording accessor
func (*Client) New ¶
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) 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 ¶
TimeoutCount is the amount of times the NATS communication times out
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