pbxclient

package
v0.0.0-...-677c443 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2018 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Provides mocked NATS encoded connection for pbxclient tests

pbxclient package connects to one of the the nats servers and makes out calls

Index

Constants

This section is empty.

Variables

View Source
var ErrConn = errors.New("Not connected")

Functions

This section is empty.

Types

type Client

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

Client stores NATS encoded conn and allows to make out call

func NewClient

func NewClient(conf *ClientConfig) (*Client, error)

NewClient returns PBX Client with an opened NATS encoded connection

func NewMockClient

func NewMockClient() (*Client, error)

NewMockClient returns pbxclient with a mocked NATS encoded connection

func (*Client) Close

func (c *Client) Close()

Close func closes client nats connection

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected func checks if NATS server is connected, note that client can be set without NATS connection

func (*Client) MakeOutCall

func (c *Client) MakeOutCall(oc *OutCall) (*OutCallResponse, error)

MakeOutCall sends a message via nats to the PBX server and wait for response

type ClientConfig

type ClientConfig struct {
	Servers string
	RootCAs string
}

ClientConfig is config for PBX Client Servers are divided by comma, example: "nats://localhost:1222,nats://localhost:1223,nats://localhost:1224" provide self-signed certs if you use secure connection, example: Servers: "tls://nats.demo.io:4443" RootCAs: "conf/certs/ca.pem,conf/certs/ca2.pem"

type OutCall

type OutCall struct {
	CallTimeout      int    `json:"callTimeout"`
	CarrierID        int    `json:"carrierId"`
	Cmd              string `json:"cmd"`
	DestPhoneNumber  string `json:"destPhoneNumber"`
	Endpoint         string `json:"endpoint"`
	IGRP             int    `json:"igrp"`
	PBXClientTimeout int    `json:"pbxClientTimeout"`
	PBXHost          string `json:"pbxHost"`
	SrcPhoneNumber   string `json:"srcPhoneNumber"`
}

OutCall has necessary data to make a request

type OutCallResponse

type OutCallResponse struct {
	ResponseStatus int
	ResponseData   map[string]string
}

OutCallResponse has out call response data

Jump to

Keyboard shortcuts

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