pubnub

package module
v4.0.0-rc.2+incompatible Latest Latest
Warning

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

Go to latest
Published: May 24, 2018 License: MIT Imports: 20 Imported by: 0

README

PubNub 4.0.0-rc.2 client for Go

  • Go (1.7.1+)

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

Build Status codecov.io

All new PubNub Go SDK

DOCS

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

Documentation

Index

Constants

View Source
const (
	Version     = "4.0.0-rc.2"
	MaxSequence = 65535
)

Default constants

View Source
const (
	StrMissingPubKey       = "Missing Publish Key"
	StrMissingSubKey       = "Missing Subscribe Key"
	StrMissingChannel      = "Missing Channel"
	StrMissingChannelGroup = "Missing Channel Group"
	StrMissingMessage      = "Missing Message"
	StrMissingSecretKey    = "Missing Secret Key"
	StrMissingUuid         = "Missing Uuid"
	StrMissingDeviceID     = "Missing Device ID"
	StrMissingPushType     = "Missing Push Type"
)

Variables

This section is empty.

Functions

func NewHttp1Client

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

func NewHttp2Client

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

Types

type AddChannelToChannelGroupBuilder

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

func (*AddChannelToChannelGroupBuilder) ChannelGroup

func (*AddChannelToChannelGroupBuilder) Channels

func (*AddChannelToChannelGroupBuilder) Execute

func (*AddChannelToChannelGroupBuilder) Transport

type AddChannelToChannelGroupResponse

type AddChannelToChannelGroupResponse struct {
}

type AddPushNotificationsOnChannelsBuilder

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

func (*AddPushNotificationsOnChannelsBuilder) Channels

func (*AddPushNotificationsOnChannelsBuilder) DeviceIDForPush

func (*AddPushNotificationsOnChannelsBuilder) Execute

func (*AddPushNotificationsOnChannelsBuilder) PushType

type AddPushNotificationsOnChannelsResponse

type AddPushNotificationsOnChannelsResponse struct{}

type AllChannelGroupResponse

type AllChannelGroupResponse struct {
	Channels     []string
	ChannelGroup string
}

type Config

type Config struct {
	PublishKey   string
	SubscribeKey string
	SecretKey    string
	AuthKey      string
	Origin       string
	Uuid         string
	CipherKey    string
	Secure       bool

	// net.Dialer.Timeout
	ConnectTimeout int

	// http.Client.Timeout for non-subscribe requests
	NonSubscribeRequestTimeout int

	// http.Client.Timeout for subscribe requests only
	SubscribeRequestTimeout int

	HeartbeatInterval int

	PresenceTimeout int

	MaximumReconnectionRetries int

	MaximumLatencyDataAge int

	FilterExpression string

	PNReconnectionPolicy ReconnectionPolicy

	Log *log.Logger

	SuppressLeaveEvents bool

	DisablePNOtherProcessing bool

	UseHttp2 bool
}

func NewConfig

func NewConfig() *Config

func NewDemoConfig

func NewDemoConfig() *Config

func (*Config) SetPresenceTimeout

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

func (*Config) SetPresenceTimeoutWithCustomInterval

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

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{}

type FetchResponse

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

type FetchResponseItem

type FetchResponseItem struct {
	Message   interface{}
	Timetoken string
}

type GetStateResponse

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

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
}

type HereNowChannelData

type HereNowChannelData struct {
	ChannelName string

	Occupancy int

	Occupants []HereNowOccupantsData
}

type HereNowOccupantsData

type HereNowOccupantsData struct {
	Uuid string

	State map[string]interface{}
}

type HereNowResponse

type HereNowResponse struct {
	TotalChannels  int
	TotalOccupancy int

	Channels []HereNowChannelData
}

type HistoryDeleteResponse

type HistoryDeleteResponse struct {
}

type HistoryResponse

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

type HistoryResponseItem

type HistoryResponseItem struct {
	Message   interface{}
	Timetoken int64
}

type LatencyEntry

type LatencyEntry struct {
	D int64
	L float64
}

type ListPushProvisionsRequestBuilder

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

func (*ListPushProvisionsRequestBuilder) DeviceIDForPush

func (*ListPushProvisionsRequestBuilder) Execute

func (*ListPushProvisionsRequestBuilder) PushType

type ListPushProvisionsRequestResponse

type ListPushProvisionsRequestResponse struct {
	Channels []string
}

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 OperationType

type OperationType int
const (
	PNSubscribeOperation OperationType = 1 + iota
	PNUnsubscribeOperation
	PNPublishOperation
	PNFireOperation
	PNHistoryOperation
	PNFetchMessagesOperation
	PNWhereNowOperation
	PNHereNowOperation
	PNHeartBeatOperation
	PNSetStateOperation
	PNGetStateOperation
	PNAddChannelsToChannelGroupOperation
	PNRemoveChannelFromChannelGroupOperation
	PNRemoveGroupOperation
	PNChannelsForGroupOperation
	PNPushNotificationsEnabledChannelsOperation
	PNAddPushNotificationsOnChannelsOperation
	PNRemovePushNotificationsFromChannelsOperation
	PNRemoveAllPushNotificationsOperation
	PNTimeOperation
	PNAccessManagerGrant
	PNAccessManagerRevoke
	PNDeleteMessagesOperation
)

func (OperationType) String

func (t OperationType) String() string

type Operations

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

type PNAccessManagerKeyData

type PNAccessManagerKeyData struct {
	ReadEnabled   bool
	WriteEnabled  bool
	ManageEnabled bool
	Ttl           int
}

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
	Ttl           int
}

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
const (
	PNPushTypeNone PNPushType = 1 + iota
	PNPushTypeGCM
	PNPushTypeAPNS
	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
	// Should be same for non-google environment
	ClientRequest interface{}

	AffectedChannels      []string
	AffectedChannelGroups []string
}

type PubNub

type PubNub struct {
	sync.RWMutex

	Config *Config
	// contains filtered or unexported fields
}

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() *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

Set 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

Set 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) 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)

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 int
}

type ReconnectionManager

type ReconnectionManager struct {
	sync.RWMutex

	ExponentialMultiplier int
	FailedCalls           int
	Milliseconds          int

	OnReconnection              func()
	OnMaxReconnectionExhaustion func()

	DoneTimer chan bool

	Timer *time.Ticker
	// contains filtered or unexported fields
}

func (*ReconnectionManager) HandleOnMaxReconnectionExhaustion

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

func (*ReconnectionManager) HandleReconnection

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

type ReconnectionPolicy

type ReconnectionPolicy int
const (
	PNNonePolicy ReconnectionPolicy = 1 + iota
	PNLinearPolicy
	PNExponentialPolicy
)

type RemoveAllPushChannelsForDeviceBuilder

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

func (*RemoveAllPushChannelsForDeviceBuilder) DeviceIDForPush

func (*RemoveAllPushChannelsForDeviceBuilder) Execute

func (*RemoveAllPushChannelsForDeviceBuilder) PushType

type RemoveAllPushChannelsForDeviceResponse

type RemoveAllPushChannelsForDeviceResponse struct{}

type RemoveChannelFromChannelGroupBuilder

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

func (*RemoveChannelFromChannelGroupBuilder) ChannelGroup

func (*RemoveChannelFromChannelGroupBuilder) Channels

func (*RemoveChannelFromChannelGroupBuilder) Execute

type RemoveChannelFromChannelGroupResponse

type RemoveChannelFromChannelGroupResponse struct {
}

type RemoveChannelsFromPushBuilder

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

func (*RemoveChannelsFromPushBuilder) Channels

func (*RemoveChannelsFromPushBuilder) DeviceIDForPush

func (*RemoveChannelsFromPushBuilder) Execute

func (*RemoveChannelsFromPushBuilder) PushType

type RemoveChannelsFromPushResponse

type RemoveChannelsFromPushResponse struct{}

type ResponseInfo

type ResponseInfo struct {
	Operation OperationType

	StatusCode int

	TlsEnabled bool

	Origin  string
	Uuid    string
	AuthKey string

	OriginalResponse *http.Response
}

type SetStateResponse

type SetStateResponse struct {
	State   interface{}
	Message string
}

type StateManager

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

type StateOperation

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

type StatusCategory

type StatusCategory int
const (
	PNUnknownCategory StatusCategory = 1 + iota
	// Request timeout reached
	PNTimeoutCategory
	// Subscribe received an initial timetoken
	PNConnectedCategory
	// Disconnected due network error
	PNDisconnectedCategory
	// Context cancelled
	PNCancelledCategory
	PNLoopStopCategory
	PNAcknowledgmentCategory
	PNBadRequestCategory
	PNAccessDeniedCategory
	PNNoStubMatchedCategory
	PNReconnectedCategory
	PNReconnectionAttemptsExhausted
)

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
}

type SubscribeOperation

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

type SubscribeResponse

type SubscribeResponse struct {
}

type SubscriptionItem

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

type SubscriptionManager

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

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

	ExitTelemetryManager chan bool
	// contains filtered or unexported fields
}

func (*TelemetryManager) CleanUpTelemetryData

func (m *TelemetryManager) CleanUpTelemetryData()

func (*TelemetryManager) OperationLatency

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

func (*TelemetryManager) StoreLatency

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

type TimeResponse

type TimeResponse struct {
	Timetoken int64
}

type UnsubscribeOperation

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

type WhereNowResponse

type WhereNowResponse struct {
	Channels []string
}

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