client

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRequestTimeout = 200 * time.Millisecond

DefaultRequestTimeout is the default timeout for a NATS request

Variables

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, conn *nats.Conn, appName string, h Handler) error

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

func MapToError

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

MapToError converts a JSON parsed map to an error type

func New

func New(nc *nats.Conn, application string, d *session.Dialog, opts Options) (cl *ari.Client, err error)

New creates a new ari.Client connected to a gateway ARI server via NATS

Types

type Conn

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

Conn is the wrapper type for a nats connnection along some ARI specific options

func (*Conn) RawRequest

func (c *Conn) RawRequest(cmd string, name string, data []byte) (msg *nats.Msg, err error)

RawRequest sends a tiered request, with an initial OK to acknowledge receipt, followed by either a response or an error.

func (*Conn) ReadRequest

func (c *Conn) ReadRequest(cmd string, name string, body interface{}, dest interface{}) (err error)

ReadRequest sends a request that is a "read"... a request which can be retried as needed without consequence. NOTE: It is less about "read" operations and more about operations which are repeatable/idempotent.

func (*Conn) StandardRequest

func (c *Conn) StandardRequest(cmd string, name string, body interface{}, dest interface{}) (err error)

StandardRequest is a request that sends JSON and receives JSON (on success) OR receives an error from the remote server

type ContinueRequest

type ContinueRequest struct {
	Context   string `json:"context"`
	Extension string `json:"extension"`
	Priority  int    `json:"priority"`
}

ContinueRequest is the request body for continuing over the message queue

type CreateBridgeRequest

type CreateBridgeRequest struct {
	ID   string `json:"bridgeId,omitempty"`
	Type string `json:"type,omitempty"`
	Name string `json:"name,omitempty"`
}

CreateBridgeRequest is the request for creating bridges

type DialRequest

type DialRequest struct {
	Caller  string `json:"caller"`
	Timeout int    `json:"timeout"`
}

DialRequest is the request for the channel dial operation

type Handler

type Handler func(context.Context, *ari.Client, *session.Dialog)

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

type Options

type Options struct {
	// ReadOperationRetryCount is the amount of times to retry a read operation
	ReadOperationRetryCount int

	// RequestTimeout is the timeout duration of a request
	RequestTimeout time.Duration

	Parent context.Context
}

Options is the list options

type PlayRequest

type PlayRequest struct {
	PlaybackID string `json:"playback_id"`
	MediaURI   string `json:"media_uri"`
}

PlayRequest is the request for playback

type RecordRequest

type RecordRequest struct {
	Name        string `json:"name"`
	Format      string `json:"format"`
	MaxDuration int    `json:"maxDurationSeconds"`
	MaxSilence  int    `json:"maxSilenceSeconds"`
	IfExists    string `json:"ifExists,omitempty"`
	Beep        bool   `json:"beep"`
	TerminateOn string `json:"terminateOn,omitempty"`
}

RecordRequest is a request for recording

type SnoopRequest

type SnoopRequest struct {
	SnoopID string
	App     string
	Options *ari.SnoopOptions
}

SnoopRequest is the NATs snoop request

type UpdateMailboxRequest

type UpdateMailboxRequest struct {
	Old int `json:"old"`
	New int `json:"new"`
}

UpdateMailboxRequest is the encoded request for updating the mailbox

Jump to

Keyboard shortcuts

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