Documentation
¶
Overview ¶
Calling the First method on the PaginatedResults returns the first page of the results. However, the Next method has to be called before inspecting the items.
For every page in the PaginatedResults, the HasNext method can be called to check if there are more page(s) available. IsLast method checks if the page is the last page. Both methods return a true or false value.
See the PaginatedResults example.
Example (PaginatedResults) ¶
package main
import (
"fmt"
"context"
"github.com/ably/ably-go/ably"
)
func main() {
ctx := context.Background()
client, err := ably.NewRealtime(ably.WithKey("xxx:xxx"))
if err != nil {
panic(err)
}
channel := client.Channels.Get("persisted:test")
err = channel.Publish(ctx, "EventName1", "EventData1")
if err != nil {
panic(err)
}
pages, err := channel.History().Pages(ctx)
if err != nil {
panic(err)
}
// Returning and iterating over the first page
pages.Next(ctx)
pages.First(ctx)
for _, message := range pages.Items() {
fmt.Println(message)
}
// Iteration over pages in PaginatedResult
for pages.Next(ctx) {
fmt.Println(pages.HasNext(ctx))
fmt.Println(pages.IsLast(ctx))
for _, presence := range pages.Items() {
fmt.Println(presence)
}
}
if err := pages.Err(); err != nil {
panic(err)
}
}
Index ¶
- Constants
- Variables
- type Auth
- func (a *Auth) Authorize(ctx context.Context, params *TokenParams, setOpts ...AuthOption) (*TokenDetails, error)
- func (a *Auth) ClientID() string
- func (a *Auth) CreateTokenRequest(params *TokenParams, opts ...AuthOption) (*TokenRequest, error)
- func (a *Auth) RequestToken(ctx context.Context, params *TokenParams, opts ...AuthOption) (*TokenDetails, error)
- type AuthOption
- func AuthWithCallback(authCallback func(context.Context, TokenParams) (Tokener, error)) AuthOption
- func AuthWithDefaultTokenParams(params TokenParams) AuthOption
- func AuthWithHeaders(headers http.Header) AuthOption
- func AuthWithKey(key string) AuthOption
- func AuthWithMethod(method string) AuthOption
- func AuthWithParams(params url.Values) AuthOption
- func AuthWithQueryTime(queryTime bool) AuthOption
- func AuthWithToken(token string) AuthOption
- func AuthWithTokenDetails(details *TokenDetails) AuthOption
- func AuthWithURL(url string) AuthOption
- func AuthWithUseTokenAuth(use bool) AuthOption
- type ChannelDetails
- type ChannelEvent
- type ChannelEventEmitter
- func (em ChannelEventEmitter) Off(e ChannelEvent)
- func (em ChannelEventEmitter) OffAll()
- func (em ChannelEventEmitter) On(e ChannelEvent, handle func(ChannelStateChange)) (off func())
- func (em ChannelEventEmitter) OnAll(handle func(ChannelStateChange)) (off func())
- func (em ChannelEventEmitter) Once(e ChannelEvent, handle func(ChannelStateChange)) (off func())
- func (em ChannelEventEmitter) OnceAll(handle func(ChannelStateChange)) (off func())
- type ChannelMetrics
- type ChannelMode
- type ChannelOccupancy
- type ChannelOption
- type ChannelState
- type ChannelStateChange
- type ChannelStatus
- type CipherAlgorithm
- type CipherMode
- type CipherParams
- type ClientOption
- func WithAuthCallback(authCallback func(context.Context, TokenParams) (Tokener, error)) ClientOption
- func WithAuthHeaders(headers http.Header) ClientOption
- func WithAuthMethod(method string) ClientOption
- func WithAuthParams(params url.Values) ClientOption
- func WithAuthURL(url string) ClientOption
- func WithAutoConnect(autoConnect bool) ClientOption
- func WithChannelRetryTimeout(d time.Duration) ClientOption
- func WithClientID(clientID string) ClientOption
- func WithDefaultTokenParams(params TokenParams) ClientOption
- func WithDial(dial func(protocol string, u *url.URL, timeout time.Duration) (conn, error)) ClientOption
- func WithDisconnectedRetryTimeout(d time.Duration) ClientOption
- func WithEchoMessages(echo bool) ClientOption
- func WithEnvironment(env string) ClientOption
- func WithFallbackHosts(hosts []string) ClientOption
- func WithFallbackHostsUseDefault(fallbackHostsUseDefault bool) ClientOption
- func WithHTTPClient(client *http.Client) ClientOption
- func WithHTTPMaxRetryCount(count int) ClientOption
- func WithHTTPOpenTimeout(d time.Duration) ClientOption
- func WithHTTPRequestTimeout(timeout time.Duration) ClientOption
- func WithIdempotentRESTPublishing(idempotent bool) ClientOption
- func WithKey(key string) ClientOption
- func WithLogHandler(handler Logger) ClientOption
- func WithLogLevel(level LogLevel) ClientOption
- func WithPort(port int) ClientOption
- func WithQueryTime(queryTime bool) ClientOption
- func WithQueueMessages(queue bool) ClientOption
- func WithRESTHost(host string) ClientOption
- func WithRealtimeHost(host string) ClientOption
- func WithRealtimeRequestTimeout(d time.Duration) ClientOption
- func WithRecover(key string) ClientOption
- func WithSuspendedRetryTimeout(d time.Duration) ClientOption
- func WithTLS(tls bool) ClientOption
- func WithTLSPort(port int) ClientOption
- func WithToken(token string) ClientOption
- func WithTokenDetails(details *TokenDetails) ClientOption
- func WithTransportParams(params url.Values) ClientOption
- func WithUseBinaryProtocol(use bool) ClientOption
- func WithUseTokenAuth(use bool) ClientOption
- type Connection
- type ConnectionEvent
- type ConnectionEventEmitter
- func (em ConnectionEventEmitter) Off(e ConnectionEvent)
- func (em ConnectionEventEmitter) OffAll()
- func (em ConnectionEventEmitter) On(e ConnectionEvent, handle func(ConnectionStateChange)) (off func())
- func (em ConnectionEventEmitter) OnAll(handle func(ConnectionStateChange)) (off func())
- func (em ConnectionEventEmitter) Once(e ConnectionEvent, handle func(ConnectionStateChange)) (off func())
- func (em ConnectionEventEmitter) OnceAll(handle func(ConnectionStateChange)) (off func())
- type ConnectionState
- type ConnectionStateChange
- type Direction
- type ErrorCode
- type ErrorInfo
- type GetPresenceOption
- type HTTPPaginatedResponse
- func (r *HTTPPaginatedResponse) ErrorCode() ErrorCode
- func (r *HTTPPaginatedResponse) ErrorMessage() string
- func (p *HTTPPaginatedResponse) HasNext(ctx context.Context) bool
- func (r *HTTPPaginatedResponse) Headers() http.Header
- func (p *HTTPPaginatedResponse) IsLast(ctx context.Context) bool
- func (p *HTTPPaginatedResponse) Items(dst interface{}) error
- func (p *HTTPPaginatedResponse) Next(ctx context.Context) bool
- func (r *HTTPPaginatedResponse) StatusCode() int
- func (r *HTTPPaginatedResponse) Success() bool
- type HistoryOption
- type HistoryRequest
- type LogLevel
- type Logger
- type Message
- type MessagesPaginatedItems
- type MessagesPaginatedResult
- type PaginateParams
- type PaginatedResult
- type PeriodUnit
- type PresenceAction
- type PresenceGetOption
- type PresenceHistoryOption
- type PresenceMessage
- type PresencePaginatedItems
- type PresencePaginatedResult
- type PresenceRequest
- type PublishMultipleOption
- type PushStats
- type REST
- type RESTChannel
- func (c *RESTChannel) History(o ...HistoryOption) HistoryRequest
- func (c *RESTChannel) Publish(ctx context.Context, name string, data interface{}, ...) error
- func (c *RESTChannel) PublishMultiple(ctx context.Context, messages []*Message, options ...PublishMultipleOption) error
- func (c *RESTChannel) PublishMultipleWithOptions(ctx context.Context, messages []*Message, options ...PublishMultipleOption) errordeprecated
- func (c *RESTChannel) Status(ctx context.Context) (*ChannelDetails, error)
- type RESTChannels
- type RESTPaginatedItems
- type RESTPresence
- type RESTRequest
- type Realtime
- type RealtimeChannel
- func (c *RealtimeChannel) Attach(ctx context.Context) error
- func (c *RealtimeChannel) Detach(ctx context.Context) error
- func (c *RealtimeChannel) ErrorReason() *ErrorInfo
- func (c *RealtimeChannel) History(o ...HistoryOption) HistoryRequest
- func (c *RealtimeChannel) Modes() []ChannelMode
- func (c *RealtimeChannel) Params() map[string]string
- func (c *RealtimeChannel) Publish(ctx context.Context, name string, data interface{}) error
- func (c *RealtimeChannel) PublishMultiple(ctx context.Context, messages []*Message) error
- func (c *RealtimeChannel) State() ChannelState
- func (c *RealtimeChannel) Subscribe(ctx context.Context, name string, handle func(*Message)) (func(), error)
- func (c *RealtimeChannel) SubscribeAll(ctx context.Context, handle func(*Message)) (func(), error)
- type RealtimeChannels
- type RealtimePresence
- func (pres *RealtimePresence) Enter(ctx context.Context, data interface{}) error
- func (pres *RealtimePresence) EnterClient(ctx context.Context, clientID string, data interface{}) error
- func (pres *RealtimePresence) Get(ctx context.Context) ([]*PresenceMessage, error)
- func (pres *RealtimePresence) GetWithOptions(ctx context.Context, options ...PresenceGetOption) ([]*PresenceMessage, error)
- func (pres *RealtimePresence) Leave(ctx context.Context, data interface{}) error
- func (pres *RealtimePresence) LeaveClient(ctx context.Context, clientID string, data interface{}) error
- func (pres *RealtimePresence) Subscribe(ctx context.Context, action PresenceAction, handle func(*PresenceMessage)) (func(), error)
- func (pres *RealtimePresence) SubscribeAll(ctx context.Context, handle func(*PresenceMessage)) (func(), error)
- func (pres *RealtimePresence) SyncComplete() bool
- func (pres *RealtimePresence) Update(ctx context.Context, data interface{}) error
- func (pres *RealtimePresence) UpdateClient(ctx context.Context, clientID string, data interface{}) error
- type RequestOption
- type ScopeParams
- type Stats
- type StatsConnectionTypes
- type StatsMessageCount
- type StatsMessageDirections
- type StatsMessageTraffic
- type StatsMessageTypes
- type StatsOption
- type StatsPaginatedItems
- type StatsPaginatedResult
- type StatsPushNotificationFailures
- type StatsPushNotifications
- type StatsPushTransportTypeCounter
- type StatsRates
- type StatsReactorRates
- type StatsRequest
- type StatsRequestCount
- type StatsResourceCount
- type StatsXchgMessages
- type TokenDetails
- type TokenParams
- type TokenRequest
- type TokenString
- type Tokener
Examples ¶
Constants ¶
const ( Port = 80 TLSPort = 443 )
const ( StatGranularityMinute = "minute" StatGranularityHour = "hour" StatGranularityDay = "day" StatGranularityMonth = "month" )
Variables ¶
var Crypto struct { // GenerateRandomKey returns a random key. keyLength is optional; if // non-zero, it should be in bits. GenerateRandomKey func(keyLength int) ([]byte, error) // GetDefaultParams returns the provided CipherParams with missing fields // set to default values. The Key field must be provided. GetDefaultParams func(CipherParams) CipherParams }
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth
func (*Auth) Authorize ¶ added in v1.1.0
func (a *Auth) Authorize(ctx context.Context, params *TokenParams, setOpts ...AuthOption) (*TokenDetails, error)
Authorize performs authorization with ably service and returns the authorization token details.
Refers to RSA10
func (*Auth) CreateTokenRequest ¶
func (a *Auth) CreateTokenRequest(params *TokenParams, opts ...AuthOption) (*TokenRequest, error)
CreateTokenRequest
func (*Auth) RequestToken ¶
func (a *Auth) RequestToken(ctx context.Context, params *TokenParams, opts ...AuthOption) (*TokenDetails, error)
RequestToken
type AuthOption ¶ added in v1.2.0
type AuthOption func(*authOptions)
An AuthOption configures authentication/authorization for a REST or Realtime instance or operation.
func AuthWithCallback ¶ added in v1.2.0
func AuthWithCallback(authCallback func(context.Context, TokenParams) (Tokener, error)) AuthOption
func AuthWithDefaultTokenParams ¶ added in v1.2.0
func AuthWithDefaultTokenParams(params TokenParams) AuthOption
func AuthWithHeaders ¶ added in v1.2.0
func AuthWithHeaders(headers http.Header) AuthOption
func AuthWithKey ¶ added in v1.2.0
func AuthWithKey(key string) AuthOption
func AuthWithMethod ¶ added in v1.2.0
func AuthWithMethod(method string) AuthOption
func AuthWithParams ¶ added in v1.2.0
func AuthWithParams(params url.Values) AuthOption
func AuthWithQueryTime ¶ added in v1.2.0
func AuthWithQueryTime(queryTime bool) AuthOption
func AuthWithToken ¶ added in v1.2.0
func AuthWithToken(token string) AuthOption
func AuthWithTokenDetails ¶ added in v1.2.0
func AuthWithTokenDetails(details *TokenDetails) AuthOption
func AuthWithURL ¶ added in v1.2.0
func AuthWithURL(url string) AuthOption
func AuthWithUseTokenAuth ¶ added in v1.2.0
func AuthWithUseTokenAuth(use bool) AuthOption
type ChannelDetails ¶ added in v1.2.7
type ChannelDetails struct {
ChannelId string `json:"channelId" codec:"channelId"`
Status ChannelStatus `json:"status" codec:"status"`
}
type ChannelEvent ¶ added in v1.2.0
type ChannelEvent struct {
// contains filtered or unexported fields
}
A ChannelEvent identifies an event in the lifetime of an Ably realtime channel.
var ( ChannelEventInitialized ChannelEvent = ChannelEvent(ChannelStateInitialized) ChannelEventAttaching ChannelEvent = ChannelEvent(ChannelStateAttaching) ChannelEventAttached ChannelEvent = ChannelEvent(ChannelStateAttached) ChannelEventDetaching ChannelEvent = ChannelEvent(ChannelStateDetaching) ChannelEventDetached ChannelEvent = ChannelEvent(ChannelStateDetached) ChannelEventSuspended ChannelEvent = ChannelEvent(ChannelStateSuspended) ChannelEventFailed ChannelEvent = ChannelEvent(ChannelStateFailed) ChannelEventUpdate ChannelEvent = ChannelEvent{/* contains filtered or unexported fields */} )
func (ChannelEvent) String ¶ added in v1.2.0
func (e ChannelEvent) String() string
type ChannelEventEmitter ¶ added in v1.2.0
type ChannelEventEmitter struct {
// contains filtered or unexported fields
}
func (ChannelEventEmitter) Off ¶ added in v1.2.0
func (em ChannelEventEmitter) Off(e ChannelEvent)
Off deregisters event handlers for connection events of a specific kind.
See package-level documentation on Event Emitter for details.
func (ChannelEventEmitter) OffAll ¶ added in v1.2.0
func (em ChannelEventEmitter) OffAll()
OffAll de-registers all event handlers.
See package-level documentation on Event Emitter for details.
func (ChannelEventEmitter) On ¶ added in v1.2.0
func (em ChannelEventEmitter) On(e ChannelEvent, handle func(ChannelStateChange)) (off func())
On registers an event handler for connection events of a specific kind.
See package-level documentation on Event Emitter for details.
func (ChannelEventEmitter) OnAll ¶ added in v1.2.0
func (em ChannelEventEmitter) OnAll(handle func(ChannelStateChange)) (off func())
OnAll registers an event handler for all connection events.
See package-level documentation on Event Emitter for details.
func (ChannelEventEmitter) Once ¶ added in v1.2.0
func (em ChannelEventEmitter) Once(e ChannelEvent, handle func(ChannelStateChange)) (off func())
Once registers an one-off event handler for connection events of a specific kind.
See package-level documentation on Event Emitter for details.
func (ChannelEventEmitter) OnceAll ¶ added in v1.2.0
func (em ChannelEventEmitter) OnceAll(handle func(ChannelStateChange)) (off func())
OnceAll registers an one-off event handler for all connection events.
See package-level documentation on Event Emitter for details.
type ChannelMetrics ¶ added in v1.2.7
type ChannelMetrics struct {
Connections int `json:"connections" codec:"connections"`
PresenceConnections int `json:"presenceConnections" codec:"presenceConnections"`
PresenceMembers int `json:"presenceMembers" codec:"presenceMembers"`
PresenceSubscribers int `json:"presenceSubscribers" codec:"presenceSubscribers"`
Publishers int `json:"publishers" codec:"publishers"`
Subscribers int `json:"subscribers" codec:"subscribers"`
}
type ChannelMode ¶ added in v1.2.0
type ChannelMode int64
const ( // Presence mode. Allows the attached channel to enter Presence. ChannelModePresence ChannelMode = iota + 1 // Publish mode. Allows the messages to be published to the attached channel. ChannelModePublish // Subscribe mode. Allows the attached channel to subscribe to messages. ChannelModeSubscribe // PresenceSubscribe. Allows the attached channel to subscribe to Presence updates. ChannelModePresenceSubscribe )
type ChannelOccupancy ¶ added in v1.2.7
type ChannelOccupancy struct {
Metrics ChannelMetrics `json:"metrics" codec:"metrics"`
}
type ChannelOption ¶ added in v1.2.0
type ChannelOption func(*channelOptions)
A ChannelOption configures a channel.
func ChannelWithCipher ¶ added in v1.2.0
func ChannelWithCipher(params CipherParams) ChannelOption
Cipher sets cipher parameters for encrypting messages on a channel.
func ChannelWithCipherKey ¶ added in v1.2.0
func ChannelWithCipherKey(key []byte) ChannelOption
CipherKey is like Cipher with an AES algorithm and CBC mode.
func ChannelWithModes ¶ added in v1.2.0
func ChannelWithModes(modes ...ChannelMode) ChannelOption
func ChannelWithParams ¶ added in v1.2.0
func ChannelWithParams(key string, value string) ChannelOption
type ChannelState ¶ added in v1.2.0
type ChannelState struct {
// contains filtered or unexported fields
}
A ChannelState identifies the state of an Ably realtime channel.
var ( ChannelStateInitialized ChannelState = ChannelState{/* contains filtered or unexported fields */} ChannelStateAttaching ChannelState = ChannelState{/* contains filtered or unexported fields */} ChannelStateAttached ChannelState = ChannelState{/* contains filtered or unexported fields */} ChannelStateDetaching ChannelState = ChannelState{/* contains filtered or unexported fields */} ChannelStateDetached ChannelState = ChannelState{/* contains filtered or unexported fields */} ChannelStateSuspended ChannelState = ChannelState{/* contains filtered or unexported fields */} ChannelStateFailed ChannelState = ChannelState{/* contains filtered or unexported fields */} )
func (ChannelState) String ¶ added in v1.2.0
func (e ChannelState) String() string
type ChannelStateChange ¶ added in v1.2.0
type ChannelStateChange struct {
Current ChannelState
Event ChannelEvent
Previous ChannelState
// Reason, if any, is an error that caused the state change.
Reason *ErrorInfo
// Resumed is set to true for Attached and Update events when channel state
// has been maintained without interruption in the server, so there has
// been no loss of message continuity.
Resumed bool
}
A ChannelStateChange is the data associated with a ChannelEvent.
If the Event is a ChannelEventUpdated, Current and Previous are the the same. Otherwise, the event is a state transition from Previous to Current.
type ChannelStatus ¶ added in v1.2.7
type ChannelStatus struct {
IsActive bool `json:"isActive" codec:"isActive"`
Occupancy ChannelOccupancy `json:"occupancy" codec:"occupancy"`
}
type CipherAlgorithm ¶ added in v1.2.0
type CipherAlgorithm uint
CipherAlgorithm is a supported algorithm for channel encryption.
const (
CipherAES CipherAlgorithm = 1 + iota
)
func (CipherAlgorithm) String ¶ added in v1.2.0
func (c CipherAlgorithm) String() string
type CipherMode ¶ added in v1.2.0
type CipherMode uint
CipherMode is a supported cipher mode for channel encryption.
const (
CipherCBC CipherMode = 1 + iota
)
func (CipherMode) String ¶ added in v1.2.0
func (c CipherMode) String() string
type CipherParams ¶ added in v1.2.0
type CipherParams struct {
Algorithm CipherAlgorithm // Spec item (TZ2a)
// The length of the private key in bits
KeyLength int // Spec item (TZ2b)
// This is the private key used to encrypt/decrypt payloads.
Key []byte // Spec item (TZ2d)
// The cipher mode to be used for encryption default is CBC.
//
// Spec item (TZ2c)
Mode CipherMode
// contains filtered or unexported fields
}
CipherParams provides parameters for configuring encryption for channels.
Spec item (TZ1)
func DefaultCipherParams ¶ added in v1.2.0
func DefaultCipherParams() (*CipherParams, error)
DefaultCipherParams returns CipherParams with fields set to default values. This generates random secret key and iv values
type ClientOption ¶ added in v1.2.0
type ClientOption func(*clientOptions)
A ClientOption configures a REST or Realtime instance.
See: https://www.ably.io/documentation/realtime/usage#client-options
func WithAuthCallback ¶ added in v1.2.0
func WithAuthCallback(authCallback func(context.Context, TokenParams) (Tokener, error)) ClientOption
func WithAuthHeaders ¶ added in v1.2.0
func WithAuthHeaders(headers http.Header) ClientOption
func WithAuthMethod ¶ added in v1.2.0
func WithAuthMethod(method string) ClientOption
func WithAuthParams ¶ added in v1.2.0
func WithAuthParams(params url.Values) ClientOption
func WithAuthURL ¶ added in v1.2.0
func WithAuthURL(url string) ClientOption
func WithAutoConnect ¶ added in v1.2.0
func WithAutoConnect(autoConnect bool) ClientOption
func WithChannelRetryTimeout ¶ added in v1.2.0
func WithChannelRetryTimeout(d time.Duration) ClientOption
func WithClientID ¶ added in v1.2.0
func WithClientID(clientID string) ClientOption
func WithDefaultTokenParams ¶ added in v1.2.0
func WithDefaultTokenParams(params TokenParams) ClientOption
func WithDisconnectedRetryTimeout ¶ added in v1.2.0
func WithDisconnectedRetryTimeout(d time.Duration) ClientOption
func WithEchoMessages ¶ added in v1.2.0
func WithEchoMessages(echo bool) ClientOption
func WithEnvironment ¶ added in v1.2.0
func WithEnvironment(env string) ClientOption
func WithFallbackHosts ¶ added in v1.2.0
func WithFallbackHosts(hosts []string) ClientOption
func WithFallbackHostsUseDefault ¶ added in v1.2.0
func WithFallbackHostsUseDefault(fallbackHostsUseDefault bool) ClientOption
func WithHTTPClient ¶ added in v1.2.0
func WithHTTPClient(client *http.Client) ClientOption
func WithHTTPMaxRetryCount ¶ added in v1.2.0
func WithHTTPMaxRetryCount(count int) ClientOption
func WithHTTPOpenTimeout ¶ added in v1.2.0
func WithHTTPOpenTimeout(d time.Duration) ClientOption
func WithHTTPRequestTimeout ¶ added in v1.2.0
func WithHTTPRequestTimeout(timeout time.Duration) ClientOption
func WithIdempotentRESTPublishing ¶ added in v1.2.0
func WithIdempotentRESTPublishing(idempotent bool) ClientOption
func WithKey ¶ added in v1.2.0
func WithKey(key string) ClientOption
func WithLogHandler ¶ added in v1.2.0
func WithLogHandler(handler Logger) ClientOption
func WithLogLevel ¶ added in v1.2.0
func WithLogLevel(level LogLevel) ClientOption
func WithPort ¶ added in v1.2.0
func WithPort(port int) ClientOption
func WithQueryTime ¶ added in v1.2.0
func WithQueryTime(queryTime bool) ClientOption
func WithQueueMessages ¶ added in v1.2.0
func WithQueueMessages(queue bool) ClientOption
func WithRESTHost ¶ added in v1.2.0
func WithRESTHost(host string) ClientOption
func WithRealtimeHost ¶ added in v1.2.0
func WithRealtimeHost(host string) ClientOption
func WithRealtimeRequestTimeout ¶ added in v1.2.0
func WithRealtimeRequestTimeout(d time.Duration) ClientOption
func WithRecover ¶ added in v1.2.0
func WithRecover(key string) ClientOption
func WithSuspendedRetryTimeout ¶ added in v1.2.0
func WithSuspendedRetryTimeout(d time.Duration) ClientOption
func WithTLS ¶ added in v1.2.0
func WithTLS(tls bool) ClientOption
func WithTLSPort ¶ added in v1.2.0
func WithTLSPort(port int) ClientOption
func WithToken ¶ added in v1.2.0
func WithToken(token string) ClientOption
func WithTokenDetails ¶ added in v1.2.0
func WithTokenDetails(details *TokenDetails) ClientOption
func WithTransportParams ¶ added in v1.2.0
func WithTransportParams(params url.Values) ClientOption
func WithUseBinaryProtocol ¶ added in v1.2.0
func WithUseBinaryProtocol(use bool) ClientOption
func WithUseTokenAuth ¶ added in v1.2.0
func WithUseTokenAuth(use bool) ClientOption
type Connection ¶ added in v1.2.0
type Connection struct {
ConnectionEventEmitter
// contains filtered or unexported fields
}
Connection represents a single connection Realtime instantiates for communication with Ably servers.
func (*Connection) Close ¶ added in v1.2.0
func (c *Connection) Close()
Close attempts to move the connection to the CLOSED state, if it can and if it isn't already.
func (*Connection) Connect ¶ added in v1.2.0
func (c *Connection) Connect()
Connect attempts to move the connection to the CONNECTED state, if it can and if it isn't already.
func (*Connection) ErrorReason ¶ added in v1.2.0
func (c *Connection) ErrorReason() *ErrorInfo
ErrorReason gives last known error that caused connection transit to ConnectionStateFailed state.
func (*Connection) ID ¶ added in v1.2.0
func (c *Connection) ID() string
ID gives unique ID string obtained from Ably upon successful connection. The ID may change due to reconnection and recovery; on every received ConnectionStateConnected event previously obtained ID is no longer valid.
func (*Connection) Key ¶ added in v1.2.0
func (c *Connection) Key() string
Key gives unique key string obtained from Ably upon successful connection. The key may change due to reconnection and recovery; on every received StatConnConnected event previously obtained Key is no longer valid.
func (*Connection) RecoveryKey ¶ added in v1.2.0
func (c *Connection) RecoveryKey() string
func (*Connection) Serial ¶ added in v1.2.0
func (c *Connection) Serial() *int64
Serial gives serial number of a message received most recently. Last known serial number is used when recovering connection state.
func (*Connection) State ¶ added in v1.2.0
func (c *Connection) State() ConnectionState
State returns current state of the connection.
type ConnectionEvent ¶ added in v1.2.0
type ConnectionEvent struct {
// contains filtered or unexported fields
}
A ConnectionEvent identifies an event in the lifetime of an Ably realtime connection.
var ( ConnectionEventInitialized ConnectionEvent = ConnectionEvent(ConnectionStateInitialized) ConnectionEventConnecting ConnectionEvent = ConnectionEvent(ConnectionStateConnecting) ConnectionEventConnected ConnectionEvent = ConnectionEvent(ConnectionStateConnected) ConnectionEventDisconnected ConnectionEvent = ConnectionEvent(ConnectionStateDisconnected) ConnectionEventSuspended ConnectionEvent = ConnectionEvent(ConnectionStateSuspended) ConnectionEventClosing ConnectionEvent = ConnectionEvent(ConnectionStateClosing) ConnectionEventClosed ConnectionEvent = ConnectionEvent(ConnectionStateClosed) ConnectionEventFailed ConnectionEvent = ConnectionEvent(ConnectionStateFailed) ConnectionEventUpdate ConnectionEvent = ConnectionEvent{/* contains filtered or unexported fields */} )
func (ConnectionEvent) String ¶ added in v1.2.0
func (e ConnectionEvent) String() string
type ConnectionEventEmitter ¶ added in v1.2.0
type ConnectionEventEmitter struct {
// contains filtered or unexported fields
}
func (ConnectionEventEmitter) Off ¶ added in v1.2.0
func (em ConnectionEventEmitter) Off(e ConnectionEvent)
Off deregisters event handlers for connection events of a specific kind.
See package-level documentation on Event Emitter for details.
func (ConnectionEventEmitter) OffAll ¶ added in v1.2.0
func (em ConnectionEventEmitter) OffAll()
OffAll deregisters all event handlers.
See package-level documentation on Event Emitter for details.
func (ConnectionEventEmitter) On ¶ added in v1.2.0
func (em ConnectionEventEmitter) On(e ConnectionEvent, handle func(ConnectionStateChange)) (off func())
On registers an event handler for connection events of a specific kind.
See package-level documentation on Event Emitter for details.
func (ConnectionEventEmitter) OnAll ¶ added in v1.2.0
func (em ConnectionEventEmitter) OnAll(handle func(ConnectionStateChange)) (off func())
OnAll registers an event handler for all connection events.
See package-level documentation on Event Emitter for details.
func (ConnectionEventEmitter) Once ¶ added in v1.2.0
func (em ConnectionEventEmitter) Once(e ConnectionEvent, handle func(ConnectionStateChange)) (off func())
Once registers an one-off event handler for connection events of a specific kind.
See package-level documentation on Event Emitter for details.
func (ConnectionEventEmitter) OnceAll ¶ added in v1.2.0
func (em ConnectionEventEmitter) OnceAll(handle func(ConnectionStateChange)) (off func())
OnceAll registers an one-off event handler for all connection events.
See package-level documentation on Event Emitter for details.
type ConnectionState ¶ added in v1.2.0
type ConnectionState struct {
// contains filtered or unexported fields
}
A ConnectionState identifies the state of an Ably realtime connection.
var ( ConnectionStateInitialized ConnectionState = ConnectionState{/* contains filtered or unexported fields */} ConnectionStateConnecting ConnectionState = ConnectionState{/* contains filtered or unexported fields */} ConnectionStateConnected ConnectionState = ConnectionState{/* contains filtered or unexported fields */} ConnectionStateDisconnected ConnectionState = ConnectionState{/* contains filtered or unexported fields */} ConnectionStateSuspended ConnectionState = ConnectionState{/* contains filtered or unexported fields */} ConnectionStateClosing ConnectionState = ConnectionState{/* contains filtered or unexported fields */} ConnectionStateClosed ConnectionState = ConnectionState{/* contains filtered or unexported fields */} ConnectionStateFailed ConnectionState = ConnectionState{/* contains filtered or unexported fields */} )
func (ConnectionState) String ¶ added in v1.2.0
func (e ConnectionState) String() string
type ConnectionStateChange ¶ added in v1.2.0
type ConnectionStateChange struct {
Current ConnectionState
Event ConnectionEvent
Previous ConnectionState
RetryIn time.Duration //RTN14d, TA2
// Reason, if any, is an error that caused the state change.
Reason *ErrorInfo
}
A ConnectionStateChange is the data associated with a ConnectionEvent.
If the Event is a ConnectionEventUpdated, Current and Previous are the the same. Otherwise, the event is a state transition from Previous to Current.
type ErrorCode ¶ added in v1.2.0
type ErrorCode int
ErrorCode is the type for predefined Ably error codes.
const ( ErrNotSet ErrorCode = 0 ErrNoError ErrorCode = 10000 ErrBadRequest ErrorCode = 40000 ErrInvalidRequestBody ErrorCode = 40001 ErrInvalidParameterName ErrorCode = 40002 ErrInvalidParameterValue ErrorCode = 40003 ErrInvalidHeader ErrorCode = 40004 ErrInvalidCredential ErrorCode = 40005 ErrInvalidConnectionID ErrorCode = 40006 ErrInvalidMessageID ErrorCode = 40007 ErrInvalidContentLength ErrorCode = 40008 ErrMaximumMessageLengthExceeded ErrorCode = 40009 ErrInvalidChannelName ErrorCode = 40010 ErrStaleRingState ErrorCode = 40011 ErrInvalidClientID ErrorCode = 40012 ErrInvalidMessageDataOrEncoding ErrorCode = 40013 ErrResourceDisposed ErrorCode = 40014 ErrInvalidDeviceID ErrorCode = 40015 ErrBatchError ErrorCode = 40020 ErrInvalidPublishRequestUnspecified ErrorCode = 40030 ErrInvalidPublishRequestInvalidClientSpecifiedID ErrorCode = 40031 ErrInvalidCredentials ErrorCode = 40101 ErrIncompatibleCredentials ErrorCode = 40102 ErrInvalidUseOfBasicAuthOverNonTLSTransport ErrorCode = 40103 ErrTimestampNotCurrent ErrorCode = 40104 ErrNonceValueReplayed ErrorCode = 40105 ErrUnableToObtainCredentialsFromGivenParameters ErrorCode = 40106 ErrAccountDisabled ErrorCode = 40110 ErrAccountRestrictedConnectionLimitsExceeded ErrorCode = 40111 ErrAccountBlockedMessageLimitsExceeded ErrorCode = 40112 ErrAccountBlocked ErrorCode = 40113 ErrAccountRestrictedChannelLimitsExceeded ErrorCode = 40114 ErrApplicationDisabled ErrorCode = 40120 ErrKeyErrorUnspecified ErrorCode = 40130 ErrKeyRevoked ErrorCode = 40131 ErrKeyExpired ErrorCode = 40132 ErrKeyDisabled ErrorCode = 40133 ErrTokenErrorUnspecified ErrorCode = 40140 ErrTokenRevoked ErrorCode = 40141 ErrTokenExpired ErrorCode = 40142 ErrTokenUnrecognised ErrorCode = 40143 ErrInvalidJWTFormat ErrorCode = 40144 ErrInvalidTokenFormat ErrorCode = 40145 ErrConnectionBlockedLimitsExceeded ErrorCode = 40150 ErrOperationNotPermittedWithProvidedCapability ErrorCode = 40160 ErrErrorFromClientTokenCallback ErrorCode = 40170 ErrForbidden ErrorCode = 40300 ErrAccountDoesNotPermitTLSConnection ErrorCode = 40310 ErrOperationRequiresTLSConnection ErrorCode = 40311 ErrApplicationRequiresAuthentication ErrorCode = 40320 ErrNotFound ErrorCode = 40400 ErrMethodNotAllowed ErrorCode = 40500 ErrRateLimitExceededNonfatal ErrorCode = 42910 ErrMaxPerConnectionPublishRateLimitExceededNonfatal ErrorCode = 42911 ErrRateLimitExceededFatal ErrorCode = 42920 ErrMaxPerConnectionPublishRateLimitExceededFatal ErrorCode = 42921 ErrInternalError ErrorCode = 50000 ErrInternalChannelError ErrorCode = 50001 ErrInternalConnectionError ErrorCode = 50002 ErrTimeoutError ErrorCode = 50003 ErrRequestFailedDueToOverloadedInstance ErrorCode = 50004 ErrReactorOperationFailed ErrorCode = 70000 ErrReactorOperationFailedPostOperationFailed ErrorCode = 70001 ErrReactorOperationFailedPostOperationReturnedUnexpectedCode ErrorCode = 70002 ErrReactorOperationFailedMaximumNumberOfConcurrentInFlightRequestsExceeded ErrorCode = 70003 ErrExchangeErrorUnspecified ErrorCode = 71000 ErrForcedReAttachmentDueToPermissionsChange ErrorCode = 71001 ErrExchangePublisherErrorUnspecified ErrorCode = 71100 ErrNoSuchPublisher ErrorCode = 71101 ErrPublisherNotEnabledAsAnExchangePublisher ErrorCode = 71102 ErrExchangeProductErrorUnspecified ErrorCode = 71200 ErrNoSuchProduct ErrorCode = 71201 ErrProductDisabled ErrorCode = 71202 ErrNoSuchChannelInThisProduct ErrorCode = 71203 ErrExchangeSubscriptionErrorUnspecified ErrorCode = 71300 ErrSubscriptionDisabled ErrorCode = 71301 ErrRequesterHasNoSubscriptionToThisProduct ErrorCode = 71302 ErrConnectionFailed ErrorCode = 80000 ErrConnectionFailedNoCompatibleTransport ErrorCode = 80001 ErrConnectionSuspended ErrorCode = 80002 ErrDisconnected ErrorCode = 80003 ErrAlreadyConnected ErrorCode = 80004 ErrInvalidConnectionIDRemoteNotFound ErrorCode = 80005 ErrUnableToRecoverConnectionMessagesExpired ErrorCode = 80006 ErrUnableToRecoverConnectionMessageLimitExceeded ErrorCode = 80007 ErrUnableToRecoverConnectionConnectionExpired ErrorCode = 80008 ErrConnectionNotEstablishedNoTransportHandle ErrorCode = 80009 ErrInvalidOperationInvalidTransportHandle ErrorCode = 80010 ErrUnableToRecoverConnectionIncompatibleAuthParams ErrorCode = 80011 ErrUnableToRecoverConnectionInvalidOrUnspecifiedConnectionSerial ErrorCode = 80012 ErrProtocolError ErrorCode = 80013 ErrConnectionTimedOut ErrorCode = 80014 ErrIncompatibleConnectionParameters ErrorCode = 80015 ErrOperationOnSupersededTransport ErrorCode = 80016 ErrConnectionClosed ErrorCode = 80017 ErrInvalidConnectionIDInvalidFormat ErrorCode = 80018 ErrClientConfiguredAuthenticationProviderRequestFailed ErrorCode = 80019 ErrContinuityLossDueToMaximumSubscribeMessageRateExceeded ErrorCode = 80020 ErrClientRestrictionNotSatisfied ErrorCode = 80030 ErrChannelOperationFailed ErrorCode = 90000 ErrChannelOperationFailedInvalidChannelState ErrorCode = 90001 ErrChannelOperationFailedEpochExpiredOrNeverExisted ErrorCode = 90002 ErrUnableToRecoverChannelMessagesExpired ErrorCode = 90003 ErrUnableToRecoverChannelMessageLimitExceeded ErrorCode = 90004 ErrUnableToRecoverChannelNoMatchingEpoch ErrorCode = 90005 ErrUnableToRecoverChannelUnboundedRequest ErrorCode = 90006 ErrChannelOperationFailedNoResponseFromServer ErrorCode = 90007 ErrMaximumNumberOfChannelsPerConnectionExceeded ErrorCode = 90010 ErrUnableToEnterPresenceChannelNoClientID ErrorCode = 91000 ErrUnableToEnterPresenceChannelInvalidChannelState ErrorCode = 91001 ErrUnableToLeavePresenceChannelThatIsNotEntered ErrorCode = 91002 ErrUnableToEnterPresenceChannelMaximumMemberLimitExceeded ErrorCode = 91003 ErrUnableToAutomaticallyReEnterPresenceChannel ErrorCode = 91004 ErrPresenceStateIsOutOfSync ErrorCode = 91005 ErrMemberImplicitlyLeftPresenceChannelConnectionClosed ErrorCode = 91100 )
type ErrorInfo ¶ added in v1.2.0
type ErrorInfo struct {
StatusCode int
Code ErrorCode
HRef string
Cause *ErrorInfo
// contains filtered or unexported fields
}
ErrorInfo describes error returned from Ably API. It always has non-zero error code. It may contain underlying error value which caused the failure condition.
type GetPresenceOption ¶ added in v1.2.0
type GetPresenceOption func(*getPresenceOptions)
A GetPresenceOption configures a call to RESTPresence.Get or RealtimePresence.Get.
func GetPresenceWithClientID ¶ added in v1.2.0
func GetPresenceWithClientID(clientID string) GetPresenceOption
func GetPresenceWithConnectionID ¶ added in v1.2.0
func GetPresenceWithConnectionID(connectionID string) GetPresenceOption
func GetPresenceWithLimit ¶ added in v1.2.0
func GetPresenceWithLimit(limit int) GetPresenceOption
type HTTPPaginatedResponse ¶ added in v1.1.0
type HTTPPaginatedResponse struct {
PaginatedResult
// contains filtered or unexported fields
}
A HTTPPaginatedResponse is an iterator for the response of a REST request.
See "Paginated results" section in the package-level documentation.
func (*HTTPPaginatedResponse) ErrorCode ¶ added in v1.1.0
func (r *HTTPPaginatedResponse) ErrorCode() ErrorCode
func (*HTTPPaginatedResponse) ErrorMessage ¶ added in v1.1.0
func (r *HTTPPaginatedResponse) ErrorMessage() string
func (*HTTPPaginatedResponse) HasNext ¶ added in v1.2.6
func (p *HTTPPaginatedResponse) HasNext(ctx context.Context) bool
HasNext returns true is there are more pages available.
See "Paginated results" section in the package-level documentation.
func (*HTTPPaginatedResponse) Headers ¶ added in v1.1.0
func (r *HTTPPaginatedResponse) Headers() http.Header
func (*HTTPPaginatedResponse) IsLast ¶ added in v1.2.6
func (p *HTTPPaginatedResponse) IsLast(ctx context.Context) bool
IsLast returns true if the page is last page.
See "Paginated results" section in the package-level documentation.
func (*HTTPPaginatedResponse) Items ¶ added in v1.2.0
func (p *HTTPPaginatedResponse) Items(dst interface{}) error
Items unmarshals the current page of results into the provided variable.
See the "Paginated results" section in the package-level documentation.
func (*HTTPPaginatedResponse) Next ¶ added in v1.1.0
func (p *HTTPPaginatedResponse) Next(ctx context.Context) bool
Next retrieves the next page of results.
See the "Paginated results" section in the package-level documentation.
func (*HTTPPaginatedResponse) StatusCode ¶ added in v1.1.0
func (r *HTTPPaginatedResponse) StatusCode() int
func (*HTTPPaginatedResponse) Success ¶ added in v1.1.0
func (r *HTTPPaginatedResponse) Success() bool
type HistoryOption ¶ added in v1.2.0
type HistoryOption func(*historyOptions)
A HistoryOption configures a call to RESTChannel.History or RealtimeChannel.History.
func HistoryWithDirection ¶ added in v1.2.0
func HistoryWithDirection(d Direction) HistoryOption
func HistoryWithEnd ¶ added in v1.2.0
func HistoryWithEnd(t time.Time) HistoryOption
func HistoryWithLimit ¶ added in v1.2.0
func HistoryWithLimit(limit int) HistoryOption
func HistoryWithStart ¶ added in v1.2.0
func HistoryWithStart(t time.Time) HistoryOption
type HistoryRequest ¶ added in v1.2.0
type HistoryRequest struct {
// contains filtered or unexported fields
}
HistoryRequest represents a request prepared by the RESTChannel.History or RealtimeChannel.History method, ready to be performed by its Pages or Items methods.
func (HistoryRequest) Items ¶ added in v1.2.0
func (r HistoryRequest) Items(ctx context.Context) (*MessagesPaginatedItems, error)
Items returns a convenience iterator for single History, over an underlying paginated iterator.
See "Paginated results" section in the package-level documentation.
func (HistoryRequest) Pages ¶ added in v1.2.0
func (r HistoryRequest) Pages(ctx context.Context) (*MessagesPaginatedResult, error)
Pages returns an iterator for whole pages of History.
See "Paginated results" section in the package-level documentation.
type Message ¶ added in v1.2.0
type Message struct {
ID string `json:"id,omitempty" codec:"id,omitempty"`
ClientID string `json:"clientId,omitempty" codec:"clientId,omitempty"`
ConnectionID string `json:"connectionId,omitempty" codec:"connectionID,omitempty"`
ConnectionKey string `json:"connectionKey,omitempty" codec:"connectionKey,omitempty"`
Name string `json:"name,omitempty" codec:"name,omitempty"`
Data interface{} `json:"data,omitempty" codec:"data,omitempty"`
Encoding string `json:"encoding,omitempty" codec:"encoding,omitempty"`
Timestamp int64 `json:"timestamp,omitempty" codec:"timestamp,omitempty"`
Extras map[string]interface{} `json:"extras,omitempty" codec:"extras,omitempty"`
}
Message is what Ably channels send and receive.
type MessagesPaginatedItems ¶ added in v1.2.0
type MessagesPaginatedItems struct {
PaginatedResult
// contains filtered or unexported fields
}
func (*MessagesPaginatedItems) Item ¶ added in v1.2.0
func (p *MessagesPaginatedItems) Item() *Message
Item returns the current result.
See the "Paginated results" section in the package-level documentation.
type MessagesPaginatedResult ¶ added in v1.2.0
type MessagesPaginatedResult struct {
PaginatedResult
// contains filtered or unexported fields
}
A MessagesPaginatedResult is an iterator for the result of a History request.
See "Paginated results" section in the package-level documentation.
func (*MessagesPaginatedResult) HasNext ¶ added in v1.2.6
func (p *MessagesPaginatedResult) HasNext(ctx context.Context) bool
HasNext returns true is there are more pages available.
See "Paginated results" section in the package-level documentation.
func (*MessagesPaginatedResult) IsLast ¶ added in v1.2.6
func (p *MessagesPaginatedResult) IsLast(ctx context.Context) bool
IsLast returns true if the page is last page.
See "Paginated results" section in the package-level documentation.
func (*MessagesPaginatedResult) Items ¶ added in v1.2.0
func (p *MessagesPaginatedResult) Items() []*Message
Items returns the current page of results.
See the "Paginated results" section in the package-level documentation.
type PaginateParams ¶
type PaginateParams struct {
ScopeParams
Limit int
Direction string
}
func (*PaginateParams) EncodeValues ¶
func (p *PaginateParams) EncodeValues(out *url.Values) error
type PaginatedResult ¶
type PaginatedResult struct {
// contains filtered or unexported fields
}
PaginatedResult is a generic iterator for PaginatedResult pagination. Items decoding is delegated to type-specific wrappers.
See "Paginated results" section in the package-level documentation.
func (*PaginatedResult) Err ¶ added in v1.2.0
func (p *PaginatedResult) Err() error
Err returns the error that caused Next to fail, if there was one.
type PeriodUnit ¶ added in v1.2.0
type PeriodUnit string
const ( PeriodMinute PeriodUnit = "minute" PeriodHour PeriodUnit = "hour" PeriodDay PeriodUnit = "day" PeriodMonth PeriodUnit = "month" )
type PresenceAction ¶ added in v1.2.0
type PresenceAction int64
A PresenceAction is a kind of action involving presence in a channel.
const ( PresenceActionAbsent PresenceAction = iota PresenceActionPresent PresenceActionEnter PresenceActionLeave PresenceActionUpdate )
func (PresenceAction) String ¶ added in v1.2.0
func (e PresenceAction) String() string
type PresenceGetOption ¶ added in v1.2.0
type PresenceGetOption func(*presenceGetOptions)
A PresenceGetOption is an optional parameter for RealtimePresence.GetWithOptions.
func PresenceGetWithWaitForSync ¶ added in v1.2.0
func PresenceGetWithWaitForSync(wait bool) PresenceGetOption
PresenceGetWithWaitForSync if true, makes GetWithOptions wait until the presence information is fully synchronized with the server before returning. It defaults to true.
type PresenceHistoryOption ¶ added in v1.2.0
type PresenceHistoryOption func(*presenceHistoryOptions)
A PresenceHistoryOption configures a call to RESTChannel.History or RealtimeChannel.History.
func PresenceHistoryWithDirection ¶ added in v1.2.0
func PresenceHistoryWithDirection(d Direction) PresenceHistoryOption
func PresenceHistoryWithEnd ¶ added in v1.2.0
func PresenceHistoryWithEnd(t time.Time) PresenceHistoryOption
func PresenceHistoryWithLimit ¶ added in v1.2.0
func PresenceHistoryWithLimit(limit int) PresenceHistoryOption
func PresenceHistoryWithStart ¶ added in v1.2.0
func PresenceHistoryWithStart(t time.Time) PresenceHistoryOption
type PresenceMessage ¶ added in v1.2.0
type PresenceMessage struct {
Message
Action PresenceAction `json:"action" codec:"action"`
}
func (PresenceMessage) String ¶ added in v1.2.0
func (m PresenceMessage) String() string
type PresencePaginatedItems ¶ added in v1.2.0
type PresencePaginatedItems struct {
PaginatedResult
// contains filtered or unexported fields
}
func (*PresencePaginatedItems) Item ¶ added in v1.2.0
func (p *PresencePaginatedItems) Item() *PresenceMessage
Item returns the current result.
See the "Paginated results" section in the package-level documentation.
type PresencePaginatedResult ¶ added in v1.2.0
type PresencePaginatedResult struct {
PaginatedResult
// contains filtered or unexported fields
}
A PresencePaginatedResult is an iterator for the result of a PresenceHistory request.
See "Paginated results" section in the package-level documentation.
func (*PresencePaginatedResult) HasNext ¶ added in v1.2.6
func (p *PresencePaginatedResult) HasNext(ctx context.Context) bool
func (*PresencePaginatedResult) IsLast ¶ added in v1.2.6
func (p *PresencePaginatedResult) IsLast(ctx context.Context) bool
IsLast returns true if the page is last page.
See "Paginated results" section in the package-level documentation.
func (*PresencePaginatedResult) Items ¶ added in v1.2.0
func (p *PresencePaginatedResult) Items() []*PresenceMessage
Items returns the current page of results.
See the "Paginated results" section in the package-level documentation.
type PresenceRequest ¶ added in v1.2.0
type PresenceRequest struct {
// contains filtered or unexported fields
}
PresenceRequest represents a request prepared by the RESTPresence.History or RealtimePresence.History method, ready to be performed by its Pages or Items methods.
func (PresenceRequest) Items ¶ added in v1.2.0
func (r PresenceRequest) Items(ctx context.Context) (*PresencePaginatedItems, error)
Items returns a convenience iterator for single PresenceHistory, over an underlying paginated iterator.
See "Paginated results" section in the package-level documentation.
func (PresenceRequest) Pages ¶ added in v1.2.0
func (r PresenceRequest) Pages(ctx context.Context) (*PresencePaginatedResult, error)
Pages returns an iterator for whole pages of presence messages.
See "Paginated results" section in the package-level documentation.
type PublishMultipleOption ¶ added in v1.2.0
type PublishMultipleOption func(*publishMultipleOptions)
PublishMultipleOption is an optional parameter for RESTChannel.Publish and RESTChannel.PublishMultiple.
TODO: This started out as just an option for PublishMultiple, but has since
been added as an option for Publish too, so it should be renamed to PublishOption when we perform the next major version bump to 2.x.x.
func PublishMultipleWithParams
deprecated
added in
v1.2.0
func PublishMultipleWithParams(params map[string]string) PublishMultipleOption
PublishMultipleWithParams is the same as PublishWithParams.
Deprecated: Use PublishWithParams instead.
TODO: Remove this in the next major version bump to 2.x.x.
func PublishWithConnectionKey ¶ added in v1.2.4
func PublishWithConnectionKey(connectionKey string) PublishMultipleOption
PublishWithConnectionKey allows a message to be published for a specified connectionKey.
func PublishWithParams ¶ added in v1.2.4
func PublishWithParams(params map[string]string) PublishMultipleOption
PublishWithParams adds query parameters to the resulting HTTP request to the REST API.
type PushStats ¶ added in v1.2.0
type PushStats struct {
Messages float64 `json:"messages" codec:"messages"`
Notifications StatsPushNotifications `json:"notifications" codec:"notifications"`
DirectPublishes float64 `json:"directPublishes" codec:"directPublishes"`
}
type REST ¶ added in v1.2.0
type REST struct {
Auth *Auth
Channels *RESTChannels
// contains filtered or unexported fields
}
func NewREST ¶ added in v1.2.0
func NewREST(options ...ClientOption) (*REST, error)
NewREST constructs a new REST.
func (*REST) Request ¶ added in v1.2.0
func (c *REST) Request(method string, path string, o ...RequestOption) RESTRequest
Request prepares an arbitrary request to the REST API.
func (*REST) Stats ¶ added in v1.2.0
func (c *REST) Stats(o ...StatsOption) StatsRequest
Stats retrieves statistics about the Ably app's activity.
type RESTChannel ¶ added in v1.2.0
type RESTChannel struct {
Name string
Presence *RESTPresence
// contains filtered or unexported fields
}
RESTChannel is the interface for REST API operations on a channel.
func (*RESTChannel) History ¶ added in v1.2.0
func (c *RESTChannel) History(o ...HistoryOption) HistoryRequest
History gives the channel's message history.
func (*RESTChannel) Publish ¶ added in v1.2.0
func (c *RESTChannel) Publish(ctx context.Context, name string, data interface{}, options ...PublishMultipleOption) error
Publish publishes a message on the channel.
Example ¶
When publishing a message to a channel, data can be either a single string or a struct of type Message. This example shows the different ways to publish a message.
package main
import (
"context"
"fmt"
"time"
"github.com/ably/ably-go/ably"
)
func main() {
// Create a new REST client.
client, err := ably.NewREST(
ably.WithKey("ABLY_PRIVATE_KEY"),
ably.WithClientID("Client A"),
)
if err != nil {
fmt.Println(err)
return
}
// Initialise a new channel.
channel := client.Channels.Get("chat")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
// Publish a string to the channel.
if err := channel.Publish(ctx, "chat_message", "Hello, how are you?"); err != nil {
fmt.Println(err)
return
}
// Publish a single message to the channel.
newChatMessage := ably.Message{
Name: "chat_message",
Data: "Hello, how are you?",
}
if err := channel.Publish(ctx, "chat_message", newChatMessage); err != nil {
fmt.Println(err)
return
}
// Publish multiple messages in a single request.
if err := channel.PublishMultiple(ctx, []*ably.Message{
{Name: "HelloEvent", Data: "Hello!"},
{Name: "ByeEvent", Data: "Bye!"},
}); err != nil {
fmt.Println(err)
return
}
// Publish a message on behalf of a different client.
if err := channel.Publish(ctx, "temperature", "12.7",
ably.PublishWithConnectionKey("connectionKeyOfAnotherClient"),
); err != nil {
fmt.Println(err)
return
}
}
func (*RESTChannel) PublishMultiple ¶ added in v1.2.0
func (c *RESTChannel) PublishMultiple(ctx context.Context, messages []*Message, options ...PublishMultipleOption) error
PublishMultiple publishes multiple messages in a batch.
func (*RESTChannel) PublishMultipleWithOptions
deprecated
added in
v1.2.0
func (c *RESTChannel) PublishMultipleWithOptions(ctx context.Context, messages []*Message, options ...PublishMultipleOption) error
PublishMultipleWithOptions is the same as PublishMultiple.
Deprecated: Use PublishMultiple instead.
TODO: Remove this in the next major version bump to 2.x.x.
func (*RESTChannel) Status ¶ added in v1.2.7
func (c *RESTChannel) Status(ctx context.Context) (*ChannelDetails, error)
Status returns ChannelDetails representing information for a channel
type RESTChannels ¶ added in v1.2.0
type RESTChannels struct {
// contains filtered or unexported fields
}
RESTChannels provides an API for managing collection of RESTChannel. This is safe for concurrent use.
func (*RESTChannels) Exists ¶ added in v1.2.0
func (c *RESTChannels) Exists(name string) bool
Exists returns true if the channel by the given name exists.
func (*RESTChannels) Get ¶ added in v1.2.0
func (c *RESTChannels) Get(name string, options ...ChannelOption) *RESTChannel
Get returns an existing channel or creates a new one if it doesn't exist.
You can optionally pass ChannelOptions, if the channel exists it will updated with the options and when it doesn't a new channel will be created with the given options.
func (*RESTChannels) Iterate ¶ added in v1.2.0
func (c *RESTChannels) Iterate() []*RESTChannel
Iterate returns a list of created channels.
It is safe to call Iterate from multiple goroutines, however there's no guarantee the returned list would not list a channel that was already released from different goroutine.
func (*RESTChannels) Release ¶ added in v1.2.0
func (c *RESTChannels) Release(name string)
Release deletes the channel from the chans.
type RESTPaginatedItems ¶ added in v1.2.0
type RESTPaginatedItems struct {
PaginatedResult
// contains filtered or unexported fields
}
func (*RESTPaginatedItems) HasNext ¶ added in v1.2.6
func (p *RESTPaginatedItems) HasNext(ctx context.Context) bool
HasNext returns true is there are more pages available.
See "Paginated results" section in the package-level documentation.
func (*RESTPaginatedItems) IsLast ¶ added in v1.2.6
func (p *RESTPaginatedItems) IsLast(ctx context.Context) bool
IsLast returns true if the page is last page.
See "Paginated results" section in the package-level documentation.
func (*RESTPaginatedItems) Item ¶ added in v1.2.0
func (p *RESTPaginatedItems) Item(dst interface{}) error
Item unmarshal the current result into the provided variable.
See the "Paginated results" section in the package-level documentation.
type RESTPresence ¶ added in v1.2.0
type RESTPresence struct {
// contains filtered or unexported fields
}
func (*RESTPresence) Get ¶ added in v1.2.0
func (c *RESTPresence) Get(o ...GetPresenceOption) PresenceRequest
func (*RESTPresence) History ¶ added in v1.2.0
func (c *RESTPresence) History(o ...PresenceHistoryOption) PresenceRequest
History gives the channel's presence history.
type RESTRequest ¶ added in v1.2.0
type RESTRequest struct {
// contains filtered or unexported fields
}
RESTRequest represents a request prepared by the REST.Request method, ready to be performed by its Pages or Items methods.
func (RESTRequest) Items ¶ added in v1.2.0
func (r RESTRequest) Items(ctx context.Context) (*RESTPaginatedItems, error)
Items returns a convenience iterator for single items, over an underlying paginated iterator.
For each item,
See "Paginated results" section in the package-level documentation.
func (RESTRequest) Pages ¶ added in v1.2.0
func (r RESTRequest) Pages(ctx context.Context) (*HTTPPaginatedResponse, error)
Pages returns an iterator for whole pages of results.
See "Paginated results" section in the package-level documentation.
type Realtime ¶ added in v1.2.0
type Realtime struct {
Auth *Auth
Channels *RealtimeChannels
Connection *Connection
// contains filtered or unexported fields
}
The Realtime libraries establish and maintain a persistent connection to Ably enabling extremely low latency broadcasting of messages and presence state.
func NewRealtime ¶ added in v1.2.0
func NewRealtime(options ...ClientOption) (*Realtime, error)
NewRealtime constructs a new Realtime.
func (*Realtime) Close ¶ added in v1.2.0
func (c *Realtime) Close()
Close is the same as Connection.Close.
func (*Realtime) Connect ¶ added in v1.2.0
func (c *Realtime) Connect()
Connect is the same as Connection.Connect.
func (*Realtime) Stats ¶ added in v1.2.0
func (c *Realtime) Stats(o ...StatsOption) StatsRequest
Stats is the same as REST.Stats.
type RealtimeChannel ¶
type RealtimeChannel struct {
ChannelEventEmitter
Name string // name used to create the channel
Presence *RealtimePresence //
// contains filtered or unexported fields
}
RealtimeChannel represents a single named message channel.
func (*RealtimeChannel) Attach ¶
func (c *RealtimeChannel) Attach(ctx context.Context) error
Attach attaches the Realtime connection to the channel, after which it starts receiving messages from it.
If the context is canceled before the attach operation finishes, the call returns with an error, but the operation carries on in the background and the channel may eventually be attached anyway.
func (*RealtimeChannel) Detach ¶
func (c *RealtimeChannel) Detach(ctx context.Context) error
Detach detaches the Realtime connection to the channel, after which it stops receiving messages from it.
If the context is canceled before the detach operation finishes, the call returns with an error, but the operation carries on in the background and the channel may eventually be detached anyway.
func (*RealtimeChannel) ErrorReason ¶ added in v1.2.0
func (c *RealtimeChannel) ErrorReason() *ErrorInfo
ErrorReason gives the last error that caused channel transition to failed state.
func (*RealtimeChannel) History ¶
func (c *RealtimeChannel) History(o ...HistoryOption) HistoryRequest
History is equivalent to RESTChannel.History.
func (*RealtimeChannel) Modes ¶ added in v1.2.0
func (c *RealtimeChannel) Modes() []ChannelMode
func (*RealtimeChannel) Params ¶ added in v1.2.0
func (c *RealtimeChannel) Params() map[string]string
func (*RealtimeChannel) Publish ¶
func (c *RealtimeChannel) Publish(ctx context.Context, name string, data interface{}) error
Publish publishes a message on the channel.
This implicitly attaches the channel if it's not already attached. If the context is canceled before the attach operation finishes, the call returns with an error, but the operation carries on in the background and the channel may eventually be attached and the message published anyway.
Example ¶
When publishing a message to a channel, data can be either a single string or a struct of type Message. This example shows the different ways to publish a message.
package main
import (
"context"
"fmt"
"time"
"github.com/ably/ably-go/ably"
)
func main() {
// Create a new realtime client.
client, err := ably.NewRealtime(
ably.WithKey("ABLY_PRIVATE_KEY"),
ably.WithClientID("Client A"),
)
if err != nil {
fmt.Println(err)
return
}
// Initialise a new channel.
channel := client.Channels.Get("chat")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
// Publish a string to the channel
if err := channel.Publish(ctx, "chat_message", "Hello, how are you?"); err != nil {
fmt.Println(err)
return
}
// Publish a Message to the channel
newChatMessage := ably.Message{
Name: "chat_message",
Data: "Hello, how are you?",
}
if err := channel.Publish(ctx, "chat_message", newChatMessage); err != nil {
fmt.Println(err)
return
}
}
func (*RealtimeChannel) PublishMultiple ¶ added in v1.2.0
func (c *RealtimeChannel) PublishMultiple(ctx context.Context, messages []*Message) error
PublishMultiple publishes all given messages on the channel at once.
This implicitly attaches the channel if it's not already attached. If the context is canceled before the attach operation finishes, the call returns with an error, but the operation carries on in the background and the channel may eventually be attached and the message published anyway.
func (*RealtimeChannel) State ¶
func (c *RealtimeChannel) State() ChannelState
State gives the current state of the channel.
func (*RealtimeChannel) Subscribe ¶
func (c *RealtimeChannel) Subscribe(ctx context.Context, name string, handle func(*Message)) (func(), error)
Subscribe registers a message handler to be called with each message with the given name received from the channel.
This implicitly attaches the channel if it's not already attached. If the context is canceled before the attach operation finishes, the call returns with an error, but the operation carries on in the background and the channel may eventually be attached anyway.
See package-level documentation on Event Emitter for details about messages dispatch.
func (*RealtimeChannel) SubscribeAll ¶ added in v1.2.0
func (c *RealtimeChannel) SubscribeAll(ctx context.Context, handle func(*Message)) (func(), error)
SubscribeAll register a message handler to be called with each message received from the channel.
This implicitly attaches the channel if it's not already attached. If the context is canceled before the attach operation finishes, the call returns with an error, but the operation carries on in the background and the channel may eventually be attached anyway.
See package-level documentation on Event Emitter for details about messages dispatch.
type RealtimeChannels ¶ added in v1.2.0
type RealtimeChannels struct {
// contains filtered or unexported fields
}
RealtimeChannels is a goroutine-safe container for realtime channels that allows for creating, deleting and iterating over existing channels.
func (*RealtimeChannels) Exists ¶ added in v1.2.0
func (c *RealtimeChannels) Exists(name string) bool
Exists returns true if the channel by the given name exists.
This function just checks the local channel map for existence. It can not check for the existence of channels created by other clients,
func (*RealtimeChannels) Get ¶ added in v1.2.0
func (ch *RealtimeChannels) Get(name string, options ...ChannelOption) *RealtimeChannel
Get looks up a channel given by the name and creates it if it does not exist already.
If the channel does not already exist it is created with the given channel options. Otherwise the existing channel is returned and options ignored.
Creating a channel only adds a new channel struct into the channel map. It does not perform any network communication until attached.
It is safe to call Get from multiple goroutines - a single channel is guaranteed to be created only once for multiple calls to Get from different goroutines.
func (*RealtimeChannels) Iterate ¶ added in v1.2.0
func (ch *RealtimeChannels) Iterate() []*RealtimeChannel
Iterate returns a list of existing channels.
It is safe to call Iterate from multiple goroutines, however there's no guarantee the returned list would not list a channel that was already released from different goroutine.
type RealtimePresence ¶
type RealtimePresence struct {
// contains filtered or unexported fields
}
RealtimePresence represents a single presence map of a particular channel. It allows entering, leaving and updating presence state for the current client or on behalf of other client.
func (*RealtimePresence) Enter ¶
func (pres *RealtimePresence) Enter(ctx context.Context, data interface{}) error
Enter announces presence of the current client with an enter message for the associated channel.
If this connection has no clientID then this function will fail.
If the context is canceled before the operation finishes, the call returns with an error, but the operation carries on in the background and presence state may eventually be updated anyway.
Example ¶
When a client is created with a ClientID, Enter is used to announce the client's presence. This example shows Client A entering their presence.
package main
import (
"context"
"fmt"
"time"
"github.com/ably/ably-go/ably"
)
func main() {
// A new realtime client is created with a ClientID.
client, err := ably.NewRealtime(
ably.WithKey("ABLY_PRIVATE_KEY"),
ably.WithClientID("Client A"),
)
if err != nil {
fmt.Println(err)
return
}
// A new channel is initialised.
channel := client.Channels.Get("chat")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
// The client announces presence with Enter.
if err := channel.Presence.Enter(ctx, nil); err != nil {
fmt.Println(err)
return
}
}
func (*RealtimePresence) EnterClient ¶
func (pres *RealtimePresence) EnterClient(ctx context.Context, clientID string, data interface{}) error
EnterClient announces presence of the given clientID altogether with an enter message for the associated channel.
If the context is canceled before the operation finishes, the call returns with an error, but the operation carries on in the background and presence state may eventually be updated anyway.
Example ¶
When a client is created without a ClientID, EnterClient is used to announce the presence of a client. This example shows a client without a clientID announcing the presence of "Client A" using EnterClient.
package main
import (
"context"
"fmt"
"time"
"github.com/ably/ably-go/ably"
)
func main() {
// A new realtime client is created without providing a ClientID.
client, err := ably.NewRealtime(
ably.WithKey("ABLY_PRIVATE_KEY"),
)
if err != nil {
fmt.Println(err)
return
}
// A new channel is initialised.
channel := client.Channels.Get("chat")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
// The presence of Client A is announced using EnterClient.
if err := channel.Presence.EnterClient(ctx, "Client A", nil); err != nil {
fmt.Println(err)
return
}
}
func (*RealtimePresence) Get ¶
func (pres *RealtimePresence) Get(ctx context.Context) ([]*PresenceMessage, error)
Get returns a list of current members on the channel, attaching the channel first is optional. If the channel state is initialised, it will be updated to attached.
If the context is canceled before the operation finishes, the call returns with an error, but the operation carries on in the background and the channel may eventually be attached anyway.
func (*RealtimePresence) GetWithOptions ¶ added in v1.2.0
func (pres *RealtimePresence) GetWithOptions(ctx context.Context, options ...PresenceGetOption) ([]*PresenceMessage, error)
GetWithOptions is Get with optional parameters.
func (*RealtimePresence) Leave ¶
func (pres *RealtimePresence) Leave(ctx context.Context, data interface{}) error
Leave announces current client leave the channel altogether with a leave message if data is non-empty.
If the context is canceled before the operation finishes, the call returns with an error, but the operation carries on in the background and presence state may eventually be updated anyway.
func (*RealtimePresence) LeaveClient ¶
func (pres *RealtimePresence) LeaveClient(ctx context.Context, clientID string, data interface{}) error
LeaveClient announces the given clientID leave the associated channel altogether with a leave message if data is non-empty.
If the context is canceled before the operation finishes, the call returns with an error, but the operation carries on in the background and presence data may eventually be updated anyway.
func (*RealtimePresence) Subscribe ¶
func (pres *RealtimePresence) Subscribe(ctx context.Context, action PresenceAction, handle func(*PresenceMessage)) (func(), error)
Subscribe registers a presence message handler to be called with each presence message with the given action received from the channel.
This implicitly attaches the channel if it's not already attached. If the context is canceled before the attach operation finishes, the call returns with an error, but the operation carries on in the background and the channel may eventually be attached anyway.
See package-level documentation on Event Emitter for details about messages dispatch.
func (*RealtimePresence) SubscribeAll ¶ added in v1.2.0
func (pres *RealtimePresence) SubscribeAll(ctx context.Context, handle func(*PresenceMessage)) (func(), error)
SubscribeAll registers a presence message handler to be called with each presence message received from the channel.
This implicitly attaches the channel if it's not already attached. If the context is canceled before the attach operation finishes, the call returns with an error, but the operation carries on in the background and the channel may eventually be attached anyway.
See package-level documentation on Event Emitter for details about messages dispatch.
func (*RealtimePresence) SyncComplete ¶
func (pres *RealtimePresence) SyncComplete() bool
SyncComplete gives true if the initial SYNC operation has completed for the members present on the channel.
func (*RealtimePresence) Update ¶
func (pres *RealtimePresence) Update(ctx context.Context, data interface{}) error
Update announces an updated presence message for the current client.
If the current client is not present on the channel, Update will behave as Enter method.
If this connection has no clientID then this function will fail.
If the context is canceled before the operation finishes, the call returns with an error, but the operation carries on in the background and presence state may eventually be updated anyway.
func (*RealtimePresence) UpdateClient ¶
func (pres *RealtimePresence) UpdateClient(ctx context.Context, clientID string, data interface{}) error
UpdateClient announces an updated presence message for the given clientID.
If the given clientID is not present on the channel, Update will behave as Enter method.
If the context is canceled before the operation finishes, the call returns with an error, but the operation carries on in the background and presence data may eventually be updated anyway.
type RequestOption ¶ added in v1.2.0
type RequestOption func(*requestOptions)
A RequestOption configures a call to REST.Request.
func RequestWithBody ¶ added in v1.2.0
func RequestWithBody(body interface{}) RequestOption
func RequestWithHeaders ¶ added in v1.2.0
func RequestWithHeaders(headers http.Header) RequestOption
func RequestWithParams ¶ added in v1.2.0
func RequestWithParams(params url.Values) RequestOption
type ScopeParams ¶
func (ScopeParams) EncodeValues ¶
func (s ScopeParams) EncodeValues(out *url.Values) error
type Stats ¶ added in v1.2.0
type Stats struct {
IntervalID string `json:"intervalId" codec:"intervalId"`
Unit string `json:"unit" codec:"unit"`
InProgress string `json:"inProgress" codec:"inProgress"`
Count float64 `json:"count" codec:"count"`
All StatsMessageTypes `json:"all" codec:"all"`
Inbound StatsMessageTraffic `json:"inbound" codec:"inbound"`
Outbound StatsMessageTraffic `json:"outbound" codec:"outbound"`
Persisted StatsMessageTypes `json:"persisted" codec:"persisted"`
Connections StatsConnectionTypes `json:"connections" codec:"connections"`
Channels StatsResourceCount `json:"channels" codec:"channels"`
APIRequests StatsRequestCount `json:"apiRequests" codec:"apiRequests"`
TokenRequests StatsRequestCount `json:"tokenRequests" codec:"tokenRequests"`
Push PushStats `json:"push" codec:"push"`
XchgProducer StatsXchgMessages `json:"xchgProducer" codec:"xchgProducer"`
XchgConsumer StatsXchgMessages `json:"xchgConsumer" codec:"xchgConsumer"`
PeakRates StatsRates `json:"peakRates" codec:"peakRates"`
}
type StatsConnectionTypes ¶ added in v1.2.0
type StatsConnectionTypes struct {
All StatsResourceCount `json:"all" codec:"all"`
Plain StatsResourceCount `json:"plain" codec:"plain"`
TLS StatsResourceCount `json:"tls" codec:"tls"`
}
type StatsMessageCount ¶ added in v1.2.0
type StatsMessageDirections ¶ added in v1.2.0
type StatsMessageDirections struct {
All StatsMessageTypes `json:"all" codec:"all"`
Inbound StatsMessageTraffic `json:"inbound" codec:"inbound"`
Outbound StatsMessageTraffic `json:"outbound" codec:"outbound"`
}
type StatsMessageTraffic ¶ added in v1.2.0
type StatsMessageTraffic struct {
All StatsMessageTypes `json:"all" codec:"all"`
RealTime StatsMessageTypes `json:"realtime" codec:"realtime"`
REST StatsMessageTypes `json:"rest" codec:"rest"`
Webhook StatsMessageTypes `json:"webhook" codec:"webhook"`
Push StatsMessageTypes `json:"push" codec:"push"`
ExternalQueue StatsMessageTypes `json:"externalQueue" codec:"externalQueue"`
HTTPEvent StatsMessageTypes `json:"httpEvent" codec:"httpEvent"`
}
type StatsMessageTypes ¶ added in v1.2.0
type StatsMessageTypes struct {
All StatsMessageCount `json:"all" codec:"all"`
Messages StatsMessageCount `json:"messages" codec:"messages"`
Presence StatsMessageCount `json:"presence" codec:"presence"`
}
type StatsOption ¶ added in v1.2.0
type StatsOption func(*statsOptions)
A StatsOption configures a call to REST.Stats or Realtime.Stats.
func StatsWithDirection ¶ added in v1.2.0
func StatsWithDirection(d Direction) StatsOption
func StatsWithEnd ¶ added in v1.2.0
func StatsWithEnd(t time.Time) StatsOption
func StatsWithLimit ¶ added in v1.2.0
func StatsWithLimit(limit int) StatsOption
func StatsWithStart ¶ added in v1.2.0
func StatsWithStart(t time.Time) StatsOption
func StatsWithUnit ¶ added in v1.2.0
func StatsWithUnit(d PeriodUnit) StatsOption
type StatsPaginatedItems ¶ added in v1.2.0
type StatsPaginatedItems struct {
PaginatedResult
// contains filtered or unexported fields
}
func (*StatsPaginatedItems) Item ¶ added in v1.2.0
func (p *StatsPaginatedItems) Item() *Stats
Item returns the current result.
See the "Paginated results" section in the package-level documentation.
type StatsPaginatedResult ¶ added in v1.2.0
type StatsPaginatedResult struct {
PaginatedResult
// contains filtered or unexported fields
}
A StatsPaginatedResult is an iterator for the result of a Stats request.
See "Paginated results" section in the package-level documentation.
func (*StatsPaginatedResult) HasNext ¶ added in v1.2.6
func (p *StatsPaginatedResult) HasNext(ctx context.Context) bool
HasNext returns true is there are more pages available.
See "Paginated results" section in the package-level documentation.
func (*StatsPaginatedResult) IsLast ¶ added in v1.2.6
func (p *StatsPaginatedResult) IsLast(ctx context.Context) bool
IsLast returns true if the page is last page.
See "Paginated results" section in the package-level documentation.
func (*StatsPaginatedResult) Items ¶ added in v1.2.0
func (p *StatsPaginatedResult) Items() []*Stats
Items returns the current page of results.
See the "Paginated results" section in the package-level documentation.
type StatsPushNotificationFailures ¶ added in v1.2.0
type StatsPushNotificationFailures struct {
Retriable StatsPushTransportTypeCounter `json:"retriable" codec:"retriable"`
Final StatsPushTransportTypeCounter `json:"final" codec:"final"`
}
type StatsPushNotifications ¶ added in v1.2.0
type StatsPushNotifications struct {
Invalid float64 `json:"invalid" codec:"invalid"`
Attempted StatsPushTransportTypeCounter `json:"attempted" codec:"attempted"`
Successful StatsPushTransportTypeCounter `json:"successful" codec:"successful"`
Failed StatsPushNotificationFailures `json:"failed" codec:"failed"`
}
type StatsPushTransportTypeCounter ¶ added in v1.2.0
type StatsRates ¶ added in v1.2.0
type StatsRates struct {
Messages float64 `json:"messages" codec:"messages"`
APIRequests float64 `json:"apiRequests" codec:"apiRequests"`
TokenRequests float64 `json:"tokenRequests" codec:"tokenRequests"`
Reactor StatsReactorRates `json:"reactor" codec:"reactor"`
}
type StatsReactorRates ¶ added in v1.2.0
type StatsRequest ¶ added in v1.2.0
type StatsRequest struct {
// contains filtered or unexported fields
}
StatsRequest represents a request prepared by the REST.Stats or Realtime.Stats method, ready to be performed by its Pages or Items methods.
func (StatsRequest) Items ¶ added in v1.2.0
func (r StatsRequest) Items(ctx context.Context) (*StatsPaginatedItems, error)
Items returns a convenience iterator for single Stats, over an underlying paginated iterator.
See "Paginated results" section in the package-level documentation.
func (StatsRequest) Pages ¶ added in v1.2.0
func (r StatsRequest) Pages(ctx context.Context) (*StatsPaginatedResult, error)
Pages returns an iterator for whole pages of Stats.
See "Paginated results" section in the package-level documentation.
type StatsRequestCount ¶ added in v1.2.0
type StatsResourceCount ¶ added in v1.2.0
type StatsXchgMessages ¶ added in v1.2.0
type StatsXchgMessages struct {
All StatsMessageTypes `json:"all" codec:"all"`
ProducerPaid StatsMessageDirections `json:"producerPaid" codec:"producerPaid"`
ConsumerPaid StatsMessageDirections `json:"consumerPaid" codec:"consumerPaid"`
}
type TokenDetails ¶
type TokenDetails struct {
// Token
Token string `json:"token,omitempty" codec:"token,omitempty"`
// KeyName
KeyName string `json:"keyName,omitempty" codec:"keyName,omitempty"`
// Expires
Expires int64 `json:"expires,omitempty" codec:"expires,omitempty"`
// ClientID
ClientID string `json:"clientId,omitempty" codec:"clientId,omitempty"`
// Issued
Issued int64 `json:"issued,omitempty" codec:"issued,omitempty"`
// Capability
Capability string `json:"capability,omitempty" codec:"capability,omitempty"`
}
TokenDetails
func (*TokenDetails) ExpireTime ¶
func (tok *TokenDetails) ExpireTime() time.Time
func (TokenDetails) IsTokener ¶ added in v1.2.0
func (TokenDetails) IsTokener()
func (*TokenDetails) IssueTime ¶
func (tok *TokenDetails) IssueTime() time.Time
type TokenParams ¶
type TokenParams struct {
// TTL is a requested time to live for the token. If the token request
// is successful, the TTL of the returned token will be less than or equal
// to this value depending on application settings and the attributes
// of the issuing key.
TTL int64 `json:"ttl,omitempty" codec:"ttl,omitempty"`
// Capability represents encoded access rights of the token.
Capability string `json:"capability,omitempty" codec:"capability,omitempty"`
// ClientID represents a client, whom the token is generated for.
ClientID string `json:"clientId,omitempty" codec:"clientId,omitempty"`
// Timestamp of the token request. It's used, in conjunction with the nonce,
// are used to prevent token requests from being replayed.
Timestamp int64 `json:"timestamp,omitempty" codec:"timestamp,omitempty"`
}
TokenParams
func (*TokenParams) Query ¶
func (params *TokenParams) Query() url.Values
Query encodes the params to query params value. If a field of params is a zero-value, it's omitted. If params is zero-value, nil is returned.
type TokenRequest ¶
type TokenRequest struct {
TokenParams `codec:",inline"`
KeyName string `json:"keyName,omitempty" codec:"keyName,omitempty"`
Nonce string `json:"nonce,omitempty" codec:"nonce,omitempty"` // should be at least 16 characters long
MAC string `json:"mac,omitempty" codec:"mac,omitempty"` // message authentication code for the request
}
TokenRequest
func (TokenRequest) IsTokener ¶ added in v1.2.0
func (TokenRequest) IsTokener()
type TokenString ¶ added in v1.2.0
type TokenString string
A TokenString is the string representation of an authentication token.
func (TokenString) IsTokener ¶ added in v1.2.0
func (TokenString) IsTokener()
Source Files
¶
- ably.go
- auth.go
- crypto.go
- doc.go
- error.go
- errors.go
- event_emitter.go
- generate.go
- logger.go
- options.go
- os_version_unix.go
- paginated_result.go
- proto_action.go
- proto_channel_options.go
- proto_crypto.go
- proto_error.go
- proto_http.go
- proto_message.go
- proto_presence_message.go
- proto_protocol_message.go
- proto_stat.go
- proto_types.go
- realtime_channel.go
- realtime_client.go
- realtime_conn.go
- realtime_presence.go
- rest_channel.go
- rest_client.go
- rest_presence.go
- state.go
- token.go
- websocket.go