Documentation
¶
Overview ¶
Package qpub is the official Go client for QPub real-time messaging.
Use NewSocket for WebSocket pub/sub and NewRest for HTTP channels and queues.
Index ¶
- Variables
- type AuthManager
- type AuthResponse
- type Connection
- type EnqueueOptions
- type EnqueueResult
- type Message
- type Option
- type OptionFunc
- type OptionManager
- type Permission
- type QueueJob
- type Rest
- type RestChannel
- type RestQueueManager
- type Socket
- type SocketChannel
- type TokenOptions
- type TokenRequest
Constants ¶
This section is empty.
Variables ¶
var ( WithAPIKey = option.WithAPIKey WithAutoConnect = option.WithAutoConnect DefaultOption = option.DefaultOption )
WithAPIKey and WithAutoConnect are option helpers.
var AuthEvents = struct { TokenUpdated string TokenExpired string TokenError string AuthError string }{ TokenUpdated: events.AuthTokenUpdated, TokenExpired: events.AuthTokenExpired, TokenError: events.AuthTokenError, AuthError: events.AuthError, }
AuthEvents names for authentication callbacks.
var ChannelEvents = struct { Initialized string Subscribing string Subscribed string Unsubscribing string Unsubscribed string Paused string Resumed string Failed string }{ Initialized: events.ChannelInitialized, Subscribing: events.ChannelSubscribing, Subscribed: events.ChannelSubscribed, Unsubscribing: events.ChannelUnsubscribing, Unsubscribed: events.ChannelUnsubscribed, Paused: events.ChannelPaused, Resumed: events.ChannelResumed, Failed: events.ChannelFailed, }
ChannelEvents names for socket channel lifecycle callbacks.
var ConnectionEvents = struct { Initialized string Connecting string Opened string Connected string Disconnected string Closing string Closed string Failed string }{ Initialized: events.ConnectionInitialized, Connecting: events.ConnectionConnecting, Opened: events.ConnectionOpened, Connected: events.ConnectionConnected, Disconnected: events.ConnectionDisconnected, Closing: events.ConnectionClosing, Closed: events.ConnectionClosed, Failed: events.ConnectionFailed, }
ConnectionEvents names for connection lifecycle callbacks.
Functions ¶
This section is empty.
Types ¶
type AuthManager ¶
type AuthManager interface {
Authenticate(ctx context.Context) (*option.AuthResponse, error)
IsAuthenticated() bool
ShouldAutoAuthenticate() bool
GetAuthenticateURL(baseURL string) (string, error)
RequestToken(ctx context.Context, request option.TokenRequest) (*option.AuthResponse, error)
GetCurrentToken() string
GetAuthHeaders() (map[string]string, error)
GetToken() string
ClearToken()
GetAuthQueryParams() (string, error)
Reset()
GenerateToken(ctx context.Context, opts option.TokenOptions) (string, error)
IssueToken(ctx context.Context, opts option.TokenOptions) (string, error)
CreateTokenRequest(ctx context.Context, opts option.TokenOptions) (option.TokenRequest, error)
On(event string, fn func(any))
}
AuthManager handles authentication.
type AuthResponse ¶
type AuthResponse = option.AuthResponse
type Connection ¶
type Connection interface {
Connect(ctx context.Context) error
Disconnect()
IsConnected() bool
WaitUntilConnected(ctx context.Context) error
Ping(ctx context.Context) (time.Duration, error)
Reset()
IsResetting() bool
On(event string, fn func(any))
}
Connection manages WebSocket connectivity.
type EnqueueOptions ¶
type EnqueueOptions = protocol.EnqueueOptions
type EnqueueResult ¶
type EnqueueResult = protocol.EnqueueResult
type OptionFunc ¶
type OptionFunc = option.OptionFunc
type OptionManager ¶
OptionManager manages SDK configuration.
type Permission ¶
type Permission = option.Permission
type Rest ¶
type Rest struct {
OptionManager *option.Manager
Auth *auth.Manager
Channels *channel.RestManager
Queues *queue.Manager
// contains filtered or unexported fields
}
Rest is the HTTP client for channels and queues.
func (*Rest) GetInstanceID ¶
GetInstanceID returns instance identifier.
type RestChannel ¶
type RestChannel interface {
Name() string
Publish(ctx context.Context, data interface{}, opts channel.PublishOptions) ([]byte, error)
Reset()
}
RestChannel publishes over HTTP.
type RestQueueManager ¶
type RestQueueManager interface {
Enqueue(ctx context.Context, queueName string, payload interface{}, opts protocol.EnqueueOptions) (protocol.EnqueueResult, error)
GetJob(ctx context.Context, queueName, jobID string) (protocol.QueueJob, error)
ListJobs(ctx context.Context, queueName string, opts protocol.ListJobsOptions) ([]protocol.QueueJob, error)
CancelJob(ctx context.Context, queueName, jobID string) error
RetryJob(ctx context.Context, queueName, jobID string) error
GetConfig(ctx context.Context, queueName string) (protocol.QueueConfig, error)
UpdateConfig(ctx context.Context, queueName string, opts protocol.UpdateQueueConfigOptions) (protocol.QueueConfig, error)
RegisterWorker(ctx context.Context, opts protocol.RegisterWorkerOptions) (protocol.WorkerRegistration, error)
Heartbeat(ctx context.Context, workerID string) (protocol.WorkerRegistration, error)
Pull(ctx context.Context, queueName string, opts protocol.PullJobsOptions) ([]protocol.QueueJob, error)
Ack(ctx context.Context, queueName, jobID string, opts protocol.AckJobOptions) error
Nack(ctx context.Context, queueName, jobID string, opts protocol.NackJobOptions) error
RunWorker(ctx context.Context, queueName string, handler func(context.Context, protocol.QueueJob) (interface{}, error), opts protocol.RunWorkerOptions) error
StopWorker()
Reset()
}
RestQueueManager manages queue jobs over REST.
type Socket ¶
type Socket struct {
OptionManager *option.Manager
Auth *auth.Manager
Connection *connection.Conn
Channels *channel.SocketManager
// contains filtered or unexported fields
}
Socket is the WebSocket client for realtime pub/sub.
func NewSocket ¶
func NewSocket(funcs ...option.OptionFunc) *Socket
NewSocket creates a Socket client.
func (*Socket) GetInstanceID ¶
GetInstanceID returns instance identifier.
type SocketChannel ¶
type SocketChannel interface {
Name() string
Publish(ctx context.Context, data interface{}, opts channel.PublishOptions) error
Subscribe(ctx context.Context, handler channel.MessageHandler, opts channel.SubscribeOptions) error
Unsubscribe(ctx context.Context, opts ...channel.UnsubscribeOptions) error
On(event string, fn func(any))
Pause(bufferMessages bool)
Resume()
IsPaused() bool
ClearBufferedMessages()
Reset()
}
SocketChannel is real-time pub/sub.
type TokenOptions ¶
type TokenOptions = option.TokenOptions
type TokenRequest ¶
type TokenRequest = option.TokenRequest
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
Basic REST publish example (set QPUB_API_KEY).
|
Basic REST publish example (set QPUB_API_KEY). |
|
queue-worker
command
Queue worker example (requires QPUB_API_KEY).
|
Queue worker example (requires QPUB_API_KEY). |
|
socket
command
Socket subscribe example (requires QPUB_API_KEY).
|
Socket subscribe example (requires QPUB_API_KEY). |
|
token-auth
command
Token auth: server-side CreateTokenRequest, client-side RequestToken.
|
Token auth: server-side CreateTokenRequest, client-side RequestToken. |
|
internal
|
|
|
Package testing provides mocks and helpers for unit tests against the public API.
|
Package testing provides mocks and helpers for unit tests against the public API. |
|
transport
|
|