pubnub

package module
v4.2.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 21 Imported by: 0

README

PubNub 4.2.5 client for Go

  • Go (1.9+)

Please direct all Support Questions and Concerns to Support@PubNub.com

GoDoc Build Status codecov.io Go Report Card

All new PubNub Go SDK

DOCS

Please direct all Support Questions and Concerns to Support@PubNub.com

Documentation

Index

Constants

View Source
const (
	// Version :the version of the SDK
	Version = "4.2.5"
	// MaxSequence for publish messages
	MaxSequence = 65535
)

Default constants

View Source
const (
	// StrMissingPubKey shows Missing Publish Key message
	StrMissingPubKey = "Missing Publish Key"
	// StrMissingSubKey shows Missing Subscribe Key message
	StrMissingSubKey = "Missing Subscribe Key"
	// StrMissingChannel shows Channel message
	StrMissingChannel = "Missing Channel"
	// StrMissingChannelGroup shows Channel Group message
	StrMissingChannelGroup = "Missing Channel Group"
	// StrMissingMessage shows Missing Message message
	StrMissingMessage = "Missing Message"
	// StrMissingSecretKey shows Missing Secret Key message
	StrMissingSecretKey = "Missing Secret Key"
	// StrMissingUUID shows Missing UUID message
	StrMissingUUID = "Missing UUID"
	// StrMissingDeviceID shows Missing Device ID message
	StrMissingDeviceID = "Missing Device ID"
	// StrMissingPushType shows Missing Push Type message
	StrMissingPushType = "Missing Push Type"
	// StrChannelsTimetoken shows Missing Channels Timetoken message
	StrChannelsTimetoken = "Missing Channels Timetoken"
	// StrChannelsTimetokenLength shows Length of Channels Timetoken message
	StrChannelsTimetokenLength = "Length of Channels Timetoken and Channels do not match"
)

Variables

This section is empty.

Functions

func NewHTTP1Client

func NewHTTP1Client(connectTimeout, responseReadTimeout, maxIdleConnsPerHost int) *http.Client

NewHTTP1Client creates a new HTTP 1 client with a new transport initialized with connect and read timeout

func NewHTTP2Client

func NewHTTP2Client(connectTimeout int, responseReadTimeout int) *http.Client

NewHTTP2Client creates a new HTTP 2 client with a new transport initialized with connect and read timeout

func SetQueryParam

func SetQueryParam(q *url.Values, queryParam map[string]string)

Types

type AddChannelToChannelGroupResponse

type AddChannelToChannelGroupResponse struct {
}

AddChannelToChannelGroupResponse is the struct returned when the Execute function of AddChannelToChannelGroup is called.

type AddPushNotificationsOnChannelsResponse

type AddPushNotificationsOnChannelsResponse struct{}

AddPushNotificationsOnChannelsResponse is response structure for AddPushNotificationsOnChannelsBuilder

type AllChannelGroupResponse

type AllChannelGroupResponse struct {
	Channels     []string
	ChannelGroup string
}

AllChannelGroupResponse is the struct returned when the Execute function of List All Channel Groups is called.

type Config

type Config struct {
	PublishKey                 string             // PublishKey you can get it from admin panel (only required if publishing).
	SubscribeKey               string             // SubscribeKey you can get it from admin panel.
	SecretKey                  string             // SecretKey (only required for modifying/revealing access permissions).
	AuthKey                    string             // AuthKey If Access Manager is utilized, client will use this AuthKey in all restricted requests.
	Origin                     string             // Custom Origin if needed
	UUID                       string             // UUID to be used as a device identifier, a default uuid is generated if not passed.
	CipherKey                  string             // If CipherKey is passed, all communications to/from PubNub will be encrypted.
	Secure                     bool               // True to use TLS
	ConnectTimeout             int                // net.Dialer.Timeout
	NonSubscribeRequestTimeout int                // http.Client.Timeout for non-subscribe requests
	SubscribeRequestTimeout    int                // http.Client.Timeout for subscribe requests only
	HeartbeatInterval          int                // The frequency of the pings to the server to state that the client is active
	PresenceTimeout            int                // The time after which the server will send a timeout for the client
	MaximumReconnectionRetries int                // The config sets how many times to retry to reconnect before giving up.
	MaximumLatencyDataAge      int                // Max time to store the latency data for telemetry
	FilterExpression           string             // Feature to subscribe with a custom filter expression.
	PNReconnectionPolicy       ReconnectionPolicy // Reconnection policy selection
	Log                        *log.Logger        // Logger instance
	SuppressLeaveEvents        bool               // When true the SDK doesn't send out the leave requests.
	DisablePNOtherProcessing   bool               // PNOther processing looks for pn_other in the JSON on the recevied message
	UseHTTP2                   bool               // HTTP2 Flag
	MessageQueueOverflowCount  int                // When the limit is exceeded by the number of messages received in a single subscribe request, a status event PNRequestMessageCountExceededCategory is fired.
	MaxIdleConnsPerHost        int                // Used to set the value of HTTP Transport's MaxIdleConnsPerHost.
	MaxWorkers                 int                // Number of max workers for Publish and Grant requests
}

Config instance is storage for user-provided information which describe further PubNub client behaviour. Configuration instance contain additional set of properties which allow to perform precise PubNub client configuration.

func NewConfig

func NewConfig() *Config

NewConfig initiates the config with default values.

func NewDemoConfig

func NewDemoConfig() *Config

NewDemoConfig initiates the config with demo keys, for tests only.

func (*Config) SetPresenceTimeout

func (c *Config) SetPresenceTimeout(timeout int) *Config

SetPresenceTimeout sets the presence timeout and automatically calulates the preferred timeout value. timeout: How long the server will consider the client alive for presence.

func (*Config) SetPresenceTimeoutWithCustomInterval

func (c *Config) SetPresenceTimeoutWithCustomInterval(
	timeout, interval int) *Config

SetPresenceTimeoutWithCustomInterval sets the presence timeout and interval. timeout: How long the server will consider the client alive for presence. interval: How often the client will announce itself to server.

type Context

type Context interface {
	Deadline() (deadline time.Time, ok bool)
	Done() <-chan struct{}
	Err() error
	Value(key interface{}) interface{}
}

type DeleteChannelGroupResponse

type DeleteChannelGroupResponse struct{}

DeleteChannelGroupResponse is response structure for Delete Channel Group function

type FetchResponse

type FetchResponse struct {
	Messages map[string][]FetchResponseItem
}

FetchResponse is the response to Fetch request. It contains a map of type FetchResponseItem

type FetchResponseItem

type FetchResponseItem struct {
	Message   interface{}
	Timetoken string
}

FetchResponseItem contains the message and the associated timetoken.

type GetStateResponse

type GetStateResponse struct {
	State map[string]interface{}
	UUID  string
}

GetStateResponse is the struct returned when the Execute function of GetState is called.

type GrantResponse

type GrantResponse struct {
	Level        string
	SubscribeKey string

	TTL int

	Channels      map[string]*PNPAMEntityData
	ChannelGroups map[string]*PNPAMEntityData

	ReadEnabled   bool
	WriteEnabled  bool
	ManageEnabled bool
	DeleteEnabled bool
}

GrantResponse is the struct returned when the Execute function of Grant is called.

type HeartbeatManager

type HeartbeatManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

HeartbeatManager is a struct that assists in running of the heartbeat.

func (*HeartbeatManager) Destroy

func (m *HeartbeatManager) Destroy()

Destroy stops the running heartbeat.

type HereNowChannelData

type HereNowChannelData struct {
	ChannelName string

	Occupancy int

	Occupants []HereNowOccupantsData
}

HereNowChannelData is the struct containing the occupancy details of the channels.

type HereNowOccupantsData

type HereNowOccupantsData struct {
	UUID string

	State map[string]interface{}
}

HereNowOccupantsData is the struct containing the state and UUID of the occupants in the channel.

type HereNowResponse

type HereNowResponse struct {
	TotalChannels  int
	TotalOccupancy int

	Channels []HereNowChannelData
}

HereNowResponse is the struct returned when the Execute function of HereNow is called.

type HistoryDeleteResponse

type HistoryDeleteResponse struct {
}

HistoryDeleteResponse is the struct returned when Delete Messages is called.

type HistoryResponse

type HistoryResponse struct {
	Messages       []HistoryResponseItem
	StartTimetoken int64
	EndTimetoken   int64
}

HistoryResponse is used to store the response from the History request.

type HistoryResponseItem

type HistoryResponseItem struct {
	Message   interface{}
	Timetoken int64
}

HistoryResponseItem is used to store the Message and the associated timetoken from the History request.

type JobQItem

type JobQItem struct {
	Req         *http.Request
	Client      *http.Client
	JobResponse chan *JobQResponse
}

type JobQResponse

type JobQResponse struct {
	Resp  *http.Response
	Error error
}

type LatencyEntry

type LatencyEntry struct {
	D int64
	L float64
}

LatencyEntry is the struct to store the timestamp and latency values.

type ListPushProvisionsRequestResponse

type ListPushProvisionsRequestResponse struct {
	Channels []string
}

ListPushProvisionsRequestResponse is the struct returned when the Execute function of ListPushProvisions is called.

type Listener

type Listener struct {
	Status   chan *PNStatus
	Message  chan *PNMessage
	Presence chan *PNPresence
}

func NewListener

func NewListener() *Listener

type ListenerManager

type ListenerManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type MessageCountsResponse

type MessageCountsResponse struct {
	Channels map[string]int
}

MessageCountsResponse is the response to MessageCounts request. It contains a map of type MessageCountsResponseItem

type OperationType

type OperationType int

OperationType is used as an enum to catgorize the various operations in the APIs lifecycle

const (
	// PNSubscribeOperation is the enum used for the Subcribe operation.
	PNSubscribeOperation OperationType = 1 + iota
	// PNUnsubscribeOperation is the enum used for the Unsubcribe operation.
	PNUnsubscribeOperation
	// PNPublishOperation is the enum used for the Publish operation.
	PNPublishOperation
	// PNFireOperation is the enum used for the Fire operation.
	PNFireOperation
	// PNHistoryOperation is the enum used for the History operation.
	PNHistoryOperation
	// PNFetchMessagesOperation is the enum used for the Fetch operation.
	PNFetchMessagesOperation
	// PNWhereNowOperation is the enum used for the Where Now operation.
	PNWhereNowOperation
	// PNHereNowOperation is the enum used for the Here Now operation.
	PNHereNowOperation
	// PNHeartBeatOperation is the enum used for the Heartbeat operation.
	PNHeartBeatOperation
	// PNSetStateOperation is the enum used for the Set State operation.
	PNSetStateOperation
	// PNGetStateOperation is the enum used for the Get State operation.
	PNGetStateOperation
	// PNAddChannelsToChannelGroupOperation is the enum used for the Add Channels to Channel Group operation.
	PNAddChannelsToChannelGroupOperation
	// PNRemoveChannelFromChannelGroupOperation is the enum used for the Remove Channels from Channel Group operation.
	PNRemoveChannelFromChannelGroupOperation
	// PNRemoveGroupOperation is the enum used for the Remove Channel Group operation.
	PNRemoveGroupOperation
	// PNChannelsForGroupOperation is the enum used for the List Channels of Channel Group operation.
	PNChannelsForGroupOperation
	// PNPushNotificationsEnabledChannelsOperation is the enum used for the List Channels with Push Notifications enabled operation.
	PNPushNotificationsEnabledChannelsOperation
	// PNAddPushNotificationsOnChannelsOperation is the enum used for the Add Channels to Push Notifications operation.
	PNAddPushNotificationsOnChannelsOperation
	// PNRemovePushNotificationsFromChannelsOperation is the enum used for the Remove Channels from Push Notifications operation.
	PNRemovePushNotificationsFromChannelsOperation
	// PNRemoveAllPushNotificationsOperation is the enum used for the Remove All Channels from Push Notifications operation.
	PNRemoveAllPushNotificationsOperation
	// PNTimeOperation is the enum used for the Time operation.
	PNTimeOperation
	// PNAccessManagerGrant is the enum used for the Access Manager Grant operation.
	PNAccessManagerGrant
	// PNAccessManagerRevoke is the enum used for the Access Manager Revoke operation.
	PNAccessManagerRevoke
	// PNDeleteMessagesOperation is the enum used for the Delete Messages from History operation.
	PNDeleteMessagesOperation
	// PNMessageCountsOperation is the enum used for History with messages operation.
	PNMessageCountsOperation
)

func (OperationType) String

func (t OperationType) String() string

type Operations

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

Operations is the struct to store the latency values of different operations.

type PNAccessManagerKeyData

type PNAccessManagerKeyData struct {
	ReadEnabled   bool
	WriteEnabled  bool
	ManageEnabled bool
	DeleteEnabled bool
	TTL           int
}

PNAccessManagerKeyData is the struct containing the access details of the channel groups.

type PNGrantType

type PNGrantType int

PNGrantType grant types

const (
	// PNReadEnabled Read Enabled
	PNReadEnabled PNGrantType = 1 + iota
	// PNWriteEnabled Write Enabled
	PNWriteEnabled
	// PNManageEnabled Manage Enabled
	PNManageEnabled
	// PNDeleteEnabled Delete Enabled
	PNDeleteEnabled
)

type PNMessage

type PNMessage struct {
	Message           interface{}
	UserMetadata      interface{}
	SubscribedChannel string
	ActualChannel     string
	Channel           string
	Subscription      string
	Publisher         string
	Timetoken         int64
}

type PNPAMEntityData

type PNPAMEntityData struct {
	Name          string
	AuthKeys      map[string]*PNAccessManagerKeyData
	ReadEnabled   bool
	WriteEnabled  bool
	ManageEnabled bool
	DeleteEnabled bool
	TTL           int
}

PNPAMEntityData is the struct containing the access details of the channels.

type PNPresence

type PNPresence struct {
	Event             string
	UUID              string
	SubscribedChannel string
	ActualChannel     string
	Channel           string
	Subscription      string
	Occupancy         int
	Timetoken         int64
	Timestamp         int64
	UserMetadata      map[string]interface{}
	State             interface{}
	Join              []string
	Leave             []string
	Timeout           []string
	HereNowRefresh    bool
}

type PNPushType

type PNPushType int

PNPushType is used as an enum to catgorize the available Push Types

const (
	// PNPushTypeNone is used as an enum to for selecting `none` as the PNPushType
	PNPushTypeNone PNPushType = 1 + iota
	// PNPushTypeGCM is used as an enum to for selecting `GCM` as the PNPushType
	PNPushTypeGCM
	// PNPushTypeAPNS is used as an enum to for selecting `APNS` as the PNPushType
	PNPushTypeAPNS
	// PNPushTypeMPNS is used as an enum to for selecting `MPNS` as the PNPushType
	PNPushTypeMPNS
)

func (PNPushType) String

func (p PNPushType) String() string

type PNStatus

type PNStatus struct {
	Category              StatusCategory
	Operation             OperationType
	ErrorData             error
	Error                 bool
	TLSEnabled            bool
	StatusCode            int
	UUID                  string
	AuthKey               string
	Origin                string
	ClientRequest         interface{} // Should be same for non-google environment
	AffectedChannels      []string
	AffectedChannelGroups []string
}

type PubNub

type PubNub struct {
	sync.RWMutex

	Config *Config
	// contains filtered or unexported fields
}

PubNub No server connection will be established when you create a new PubNub object. To establish a new connection use Subscribe() function of PubNub type.

func NewPubNub

func NewPubNub(pnconf *Config) *PubNub

func NewPubNubDemo

func NewPubNubDemo() *PubNub

func (*PubNub) AddChannelToChannelGroup

func (pn *PubNub) AddChannelToChannelGroup() *addChannelToChannelGroupBuilder

func (*PubNub) AddChannelToChannelGroupWithContext

func (pn *PubNub) AddChannelToChannelGroupWithContext(
	ctx Context) *addChannelToChannelGroupBuilder

func (*PubNub) AddListener

func (pn *PubNub) AddListener(listener *Listener)

func (*PubNub) AddPushNotificationsOnChannels

func (pn *PubNub) AddPushNotificationsOnChannels() *addPushNotificationsOnChannelsBuilder

func (*PubNub) AddPushNotificationsOnChannelsWithContext

func (pn *PubNub) AddPushNotificationsOnChannelsWithContext(
	ctx Context) *addPushNotificationsOnChannelsBuilder

func (*PubNub) DeleteChannelGroup

func (pn *PubNub) DeleteChannelGroup() *deleteChannelGroupBuilder

func (*PubNub) DeleteChannelGroupWithContext

func (pn *PubNub) DeleteChannelGroupWithContext(
	ctx Context) *deleteChannelGroupBuilder

func (*PubNub) DeleteMessages

func (pn *PubNub) DeleteMessages() *historyDeleteBuilder

func (*PubNub) DeleteMessagesWithContext

func (pn *PubNub) DeleteMessagesWithContext(ctx Context) *historyDeleteBuilder

func (*PubNub) Destroy

func (pn *PubNub) Destroy()

func (*PubNub) Fetch

func (pn *PubNub) Fetch() *fetchBuilder

func (*PubNub) FetchWithContext

func (pn *PubNub) FetchWithContext(ctx Context) *fetchBuilder

func (*PubNub) Fire

func (pn *PubNub) Fire() *fireBuilder

func (*PubNub) FireWithContext

func (pn *PubNub) FireWithContext(ctx Context) *fireBuilder

func (*PubNub) GetClient

func (pn *PubNub) GetClient() *http.Client

GetClient Get a client for transactional requests

func (*PubNub) GetListeners

func (pn *PubNub) GetListeners() map[*Listener]bool

func (*PubNub) GetState

func (pn *PubNub) GetState() *getStateBuilder

func (*PubNub) GetStateWithContext

func (pn *PubNub) GetStateWithContext(ctx Context) *getStateBuilder

func (*PubNub) GetSubscribeClient

func (pn *PubNub) GetSubscribeClient() *http.Client

GetSubscribeClient Get a client for transactional requests

func (*PubNub) GetSubscribedChannels

func (pn *PubNub) GetSubscribedChannels() []string

func (*PubNub) GetSubscribedGroups

func (pn *PubNub) GetSubscribedGroups() []string

func (*PubNub) Grant

func (pn *PubNub) Grant() *grantBuilder

func (*PubNub) GrantWithContext

func (pn *PubNub) GrantWithContext(ctx Context) *grantBuilder

func (*PubNub) HereNow

func (pn *PubNub) HereNow() *hereNowBuilder

func (*PubNub) HereNowWithContext

func (pn *PubNub) HereNowWithContext(ctx Context) *hereNowBuilder

func (*PubNub) History

func (pn *PubNub) History() *historyBuilder

func (*PubNub) HistoryWithContext

func (pn *PubNub) HistoryWithContext(ctx Context) *historyBuilder

func (*PubNub) Leave

func (pn *PubNub) Leave() *leaveBuilder

func (*PubNub) LeaveWithContext

func (pn *PubNub) LeaveWithContext(ctx Context) *leaveBuilder

func (*PubNub) ListChannelsInChannelGroup

func (pn *PubNub) ListChannelsInChannelGroup() *allChannelGroupBuilder

func (*PubNub) ListChannelsInChannelGroupWithContext

func (pn *PubNub) ListChannelsInChannelGroupWithContext(
	ctx Context) *allChannelGroupBuilder

func (*PubNub) ListPushProvisions

func (pn *PubNub) ListPushProvisions() *listPushProvisionsRequestBuilder

func (*PubNub) ListPushProvisionsWithContext

func (pn *PubNub) ListPushProvisionsWithContext(
	ctx Context) *listPushProvisionsRequestBuilder

func (*PubNub) MessageCounts

func (pn *PubNub) MessageCounts() *messageCountsBuilder

func (*PubNub) MessageCountsWithContext

func (pn *PubNub) MessageCountsWithContext(ctx Context) *messageCountsBuilder

func (*PubNub) Presence

func (pn *PubNub) Presence() *presenceBuilder

func (*PubNub) PresenceWithContext

func (pn *PubNub) PresenceWithContext(ctx Context) *presenceBuilder

func (*PubNub) Publish

func (pn *PubNub) Publish() *publishBuilder

func (*PubNub) PublishWithContext

func (pn *PubNub) PublishWithContext(ctx Context) *publishBuilder

func (*PubNub) RemoveAllPushNotifications

func (pn *PubNub) RemoveAllPushNotifications() *removeAllPushChannelsForDeviceBuilder

func (*PubNub) RemoveAllPushNotificationsWithContext

func (pn *PubNub) RemoveAllPushNotificationsWithContext(
	ctx Context) *removeAllPushChannelsForDeviceBuilder

func (*PubNub) RemoveChannelFromChannelGroup

func (pn *PubNub) RemoveChannelFromChannelGroup() *removeChannelFromChannelGroupBuilder

func (*PubNub) RemoveChannelFromChannelGroupWithContext

func (pn *PubNub) RemoveChannelFromChannelGroupWithContext(
	ctx Context) *removeChannelFromChannelGroupBuilder

func (*PubNub) RemoveListener

func (pn *PubNub) RemoveListener(listener *Listener)

func (*PubNub) RemovePushNotificationsFromChannels

func (pn *PubNub) RemovePushNotificationsFromChannels() *removeChannelsFromPushBuilder

func (*PubNub) RemovePushNotificationsFromChannelsWithContext

func (pn *PubNub) RemovePushNotificationsFromChannelsWithContext(
	ctx Context) *removeChannelsFromPushBuilder

func (*PubNub) SetClient

func (pn *PubNub) SetClient(c *http.Client)

SetClient Set a client for transactional requests

func (*PubNub) SetState

func (pn *PubNub) SetState() *setStateBuilder

func (*PubNub) SetStateWithContext

func (pn *PubNub) SetStateWithContext(ctx Context) *setStateBuilder

func (*PubNub) SetSubscribeClient

func (pn *PubNub) SetSubscribeClient(client *http.Client)

func (*PubNub) Subscribe

func (pn *PubNub) Subscribe() *subscribeBuilder

func (*PubNub) Time

func (pn *PubNub) Time() *timeBuilder

func (*PubNub) TimeWithContext

func (pn *PubNub) TimeWithContext(ctx Context) *timeBuilder

func (*PubNub) Unsubscribe

func (pn *PubNub) Unsubscribe() *unsubscribeBuilder

func (*PubNub) UnsubscribeAll

func (pn *PubNub) UnsubscribeAll()

func (*PubNub) WhereNow

func (pn *PubNub) WhereNow() *whereNowBuilder

func (*PubNub) WhereNowWithContext

func (pn *PubNub) WhereNowWithContext(ctx Context) *whereNowBuilder

type PublishResponse

type PublishResponse struct {
	Timestamp int64
}

PublishResponse is the response after the execution on Publish and Fire operations.

type ReconnectionManager

type ReconnectionManager struct {
	sync.RWMutex

	ExponentialMultiplier       int
	FailedCalls                 int
	Milliseconds                int
	OnReconnection              func()
	OnMaxReconnectionExhaustion func()
	DoneTimer                   chan bool
	// contains filtered or unexported fields
}

ReconnectionManager is used to store the properties required in running the Reconnection Manager.

func (*ReconnectionManager) HandleOnMaxReconnectionExhaustion

func (m *ReconnectionManager) HandleOnMaxReconnectionExhaustion(handler func())

HandleOnMaxReconnectionExhaustion sets the handler that will be called when the max reconnection attempts are exhausted.

func (*ReconnectionManager) HandleReconnection

func (m *ReconnectionManager) HandleReconnection(handler func())

HandleReconnection sets the handler that will be called when the network reconnects after a disconnect.

type ReconnectionPolicy

type ReconnectionPolicy int

ReconnectionPolicy is used as an enum to catgorize the reconnection policies

const (
	// PNNonePolicy is to be used when selecting the no Reconnection Policy
	// ReconnectionPolicy is set in the config.
	PNNonePolicy ReconnectionPolicy = 1 + iota
	// PNLinearPolicy is to be used when selecting the Linear Reconnection Policy
	// ReconnectionPolicy is set in the config.
	PNLinearPolicy
	// PNExponentialPolicy is to be used when selecting the Exponential Reconnection Policy
	// ReconnectionPolicy is set in the config.
	PNExponentialPolicy
)

type RemoveAllPushChannelsForDeviceResponse

type RemoveAllPushChannelsForDeviceResponse struct{}

RemoveAllPushChannelsForDeviceResponse is the struct returned when the Execute function of RemoveAllPushNotifications is called.

type RemoveChannelFromChannelGroupResponse

type RemoveChannelFromChannelGroupResponse struct {
}

RemoveChannelFromChannelGroupResponse is the struct returned when the Execute function of RemoveChannelFromChannelGroup is called.

type RemoveChannelsFromPushResponse

type RemoveChannelsFromPushResponse struct{}

RemoveChannelsFromPushResponse is the struct returned when the Execute function of RemovePushNotificationsFromChannels is called.

type RequestWorkers

type RequestWorkers struct {
	Workers    chan chan *JobQItem
	MaxWorkers int
	Sem        chan bool
}

func (*RequestWorkers) Close

func (p *RequestWorkers) Close()

Close closes the workers

func (*RequestWorkers) ReadQueue

func (p *RequestWorkers) ReadQueue(pubnub *PubNub)

ReadQueue reads the queue and passes on the job to the workers

func (*RequestWorkers) Start

func (p *RequestWorkers) Start(pubnub *PubNub, ctx Context)

Start starts the workers

type ResponseInfo

type ResponseInfo struct {
	Operation        OperationType
	StatusCode       int
	TLSEnabled       bool
	Origin           string
	UUID             string
	AuthKey          string
	OriginalResponse *http.Response
}

ResponseInfo is used to store the properties in the response of an request.

type SetStateResponse

type SetStateResponse struct {
	State   interface{}
	Message string
}

SetStateResponse is the response returned when the Execute function of SetState is called.

type StateManager

type StateManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

StateManager is used to store the subscriptions types

type StateOperation

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

type StatusCategory

type StatusCategory int

StatusCategory is used as an enum to catgorize the various status events in the APIs lifecycle

const (
	// PNUnknownCategory as the StatusCategory means an unknown status category event occurred.
	PNUnknownCategory StatusCategory = 1 + iota
	// PNTimeoutCategory as the StatusCategory means the request timeout has reached.
	PNTimeoutCategory
	// PNConnectedCategory as the StatusCategory means the channel is subscribed to receive messages.
	PNConnectedCategory
	// PNDisconnectedCategory as the StatusCategory means a disconnection occurred due to network issues.
	PNDisconnectedCategory
	// PNCancelledCategory as the StatusCategory means the context was cancelled.
	PNCancelledCategory
	// PNLoopStopCategory as the StatusCategory means the subscribe loop was stopped.
	PNLoopStopCategory
	// PNAcknowledgmentCategory as the StatusCategory is the Acknowledgement of an operation (like Unsubscribe).
	PNAcknowledgmentCategory
	// PNBadRequestCategory as the StatusCategory means the request was malformed.
	PNBadRequestCategory
	// PNAccessDeniedCategory as the StatusCategory means that PAM is enabled and the channel is not granted R/W access.
	PNAccessDeniedCategory
	// PNNoStubMatchedCategory as the StatusCategory means an unknown status category event occurred.
	PNNoStubMatchedCategory
	// PNReconnectedCategory as the StatusCategory means that the network was reconnected (after a disconnection).
	// Applicable on for PNLinearPolicy and PNExponentialPolicy.
	PNReconnectedCategory
	// PNReconnectionAttemptsExhausted as the StatusCategory means that the reconnection attempts
	// to reconnect to the network were exhausted. All channels would be unsubscribed at this point.
	// Applicable on for PNLinearPolicy and PNExponentialPolicy.
	// Reconnection attempts are set in the config: MaximumReconnectionRetries.
	PNReconnectionAttemptsExhausted
	// PNRequestMessageCountExceededCategory is fired when the MessageQueueOverflowCount limit is exceeded by the number of messages received in a single subscribe request
	PNRequestMessageCountExceededCategory
)

func (StatusCategory) String

func (c StatusCategory) String() string

type StatusResponse

type StatusResponse struct {
	Error                 error
	Category              StatusCategory
	Operation             OperationType
	StatusCode            int
	TLSEnabled            bool
	UUID                  string
	AuthKey               string
	Origin                string
	OriginalResponse      string
	Request               string
	AffectedChannels      []string
	AffectedChannelGroups []string
}

StatusResponse is used to store the usable properties in the response of an request.

type SubscribeOperation

type SubscribeOperation struct {
	Channels         []string
	ChannelGroups    []string
	PresenceEnabled  bool
	Timetoken        int64
	FilterExpression string
	State            map[string]interface{}
	QueryParam       map[string]string
}

SubscribeOperation

type SubscriptionItem

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

SubscriptionItem is used to store the subscription item's properties.

type SubscriptionManager

type SubscriptionManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Heartbeat: - Heartbeat is enabled by default. - Default presence timeout is 0 seconds. - The first Heartbeat request will be scheduled to be executed after getHeartbeatInterval() seconds (default - 149).

func (*SubscriptionManager) AddListener

func (m *SubscriptionManager) AddListener(listener *Listener)

func (*SubscriptionManager) Destroy

func (m *SubscriptionManager) Destroy()

func (*SubscriptionManager) Disconnect

func (m *SubscriptionManager) Disconnect()

func (*SubscriptionManager) GetListeners

func (m *SubscriptionManager) GetListeners() map[*Listener]bool

func (*SubscriptionManager) RemoveAllListeners

func (m *SubscriptionManager) RemoveAllListeners()

func (*SubscriptionManager) RemoveListener

func (m *SubscriptionManager) RemoveListener(listener *Listener)

type TelemetryManager

type TelemetryManager struct {
	sync.RWMutex

	IsRunning bool
	// contains filtered or unexported fields
}

TelemetryManager is the struct to store the Telemetry details.

func (*TelemetryManager) CleanUpTelemetryData

func (m *TelemetryManager) CleanUpTelemetryData()

CleanUpTelemetryData cleans up telemetry data of all operations.

func (*TelemetryManager) OperationLatency

func (m *TelemetryManager) OperationLatency() map[string]string

OperationLatency returns a map of the stored latencies by operation.

func (*TelemetryManager) StoreLatency

func (m *TelemetryManager) StoreLatency(latency float64, t OperationType)

StoreLatency stores the latency values of the different operations.

type TimeResponse

type TimeResponse struct {
	Timetoken int64
}

TimeResponse is the response when Time call is executed.

type UnsubscribeOperation

type UnsubscribeOperation struct {
	Channels      []string
	ChannelGroups []string
	QueryParam    map[string]string
}

type WhereNowResponse

type WhereNowResponse struct {
	Channels []string
}

WhereNowResponse is the response of the WhereNow request. Contains channels info.

type Worker

type Worker struct {
	Workers    chan chan *JobQItem
	JobChannel chan *JobQItem
	// contains filtered or unexported fields
}

func (Worker) Process

func (pw Worker) Process(pubnub *PubNub)

Process runs a goroutine for the worker

Directories

Path Synopsis
examples
cli
tests
e2e

Jump to

Keyboard shortcuts

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