pubnub

package module
v0.0.0-...-ec1bf44 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2017 License: MIT Imports: 6 Imported by: 1

README

pubnub Build Status

PubNub go-client wrapper

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChannelNotSet    = errors.New("channel name is not set")
	ErrTimeout          = errors.New("timeout reached")
	ErrConnectionAbort  = errors.New("connection aborted")
	ErrConnectionClosed = errors.New("connection closed")
)
View Source
var (
	ErrRecvMessage = errors.New("message not received")
	ErrInvalidKey  = errors.New("invalid key")
)
View Source
var ErrInvalidType = errors.New("invalid type")

Functions

This section is empty.

Types

type AccessGrant

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

func NewAccessGrant

func NewAccessGrant(ao *AccessGrantOptions, cs *ClientSettings) *AccessGrant

func (*AccessGrant) Grant

func (ag *AccessGrant) Grant(as *AuthSettings) error

type AccessGrantOptions

type AccessGrantOptions struct {
	ResumeOnReconnect bool
	SubscribeTimeout  int
	Origin            string
}

func NewAccessGrantOptions

func NewAccessGrantOptions() *AccessGrantOptions

type AuthSettings

type AuthSettings struct {

	// PubNub channel name
	ChannelName string

	// Grant access for the token. When token is an
	// empty string it provides public access for the channel.
	Token string

	// Grant read access
	CanRead bool

	// Grant write Access
	CanWrite bool

	// Time to live value in minutes.
	// Access is revoked after TTL period
	// Min-max values can be consecutively: 1 and 525600
	// 0 value will grant access indefinitely
	// -1 causes default value (1440) to be set
	TTL int
}

type Channel

type Channel struct {
	Name string
	// contains filtered or unexported fields
}

Channel is used for established subscription connections

func (*Channel) Close

func (c *Channel) Close()

func (*Channel) Consume

func (c *Channel) Consume() <-chan Message

func (*Channel) ConsumeErrors

func (c *Channel) ConsumeErrors() <-chan error

type ClientSettings

type ClientSettings struct {
	PublishKey   string
	SubscribeKey string
	SecretKey    string
	Cipher       string
	SSL          bool
	ID           string
}

type Message

type Message struct {
	Body interface{}
}

///////////// Message //////////////////

type PubNubClient

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

func NewPubNubClient

func NewPubNubClient(cs *ClientSettings) *PubNubClient

func (*PubNubClient) Close

func (p *PubNubClient) Close()

func (*PubNubClient) Grant

func (p *PubNubClient) Grant(a *AuthSettings) error

Grant read/write access to the given token for TTL period. If token

func (*PubNubClient) NewChannel

func (p *PubNubClient) NewChannel(name string) (*Channel, error)

NewChannel opens a new subscription channel

func (*PubNubClient) Push

func (p *PubNubClient) Push(channelName string, body interface{}) error

Push sends a message to the channel with channelName. If Access Manager is enabled access must be granted first.

func (*PubNubClient) SetAuthToken

func (p *PubNubClient) SetAuthToken(token string)

func (*PubNubClient) Subscribe

func (p *PubNubClient) Subscribe(channelName string) (*Channel, error)

Subscribe to given channel. Returns a message listener channel TODO add support for multiple channel subscription

type PubNubRequest

type PubNubRequest struct {
	// request timeout value in second
	Timeout int
	// contains filtered or unexported fields
}

PubNubRequest is used for each PubNub api call

func NewPubNubRequest

func NewPubNubRequest(channelName string, messages chan<- Message, errors chan<- error) *PubNubRequest

func (*PubNubRequest) Close

func (pr *PubNubRequest) Close()

func (*PubNubRequest) Do

func (pr *PubNubRequest) Do() error

Jump to

Keyboard shortcuts

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