Documentation
¶
Overview ¶
Package realtime adapts authenticated Centrifugo subscriptions and publications to the generic lobby. It does not create membership on socket connection.
Index ¶
Constants ¶
const ProxySecretHeader = "X-Lobby-Proxy-Secret"
const RefreshPath = "/internal/lobby/centrifugo/sub-refresh"
const SubscribePath = "/internal/lobby/centrifugo/subscribe"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorizer ¶
type Authorizer struct {
// contains filtered or unexported fields
}
func NewAuthorizer ¶
func NewAuthorizer(identities domain.IdentityStore, store domain.Store, clock domain.Clock, policy domain.Policy) (*Authorizer, error)
func (*Authorizer) AuthorizeSubscription ¶
func (authorizer *Authorizer) AuthorizeSubscription(ctx context.Context, playerID, channelName string) (domain.SubscriptionAuthorization, error)
type ErrorReporter ¶
ErrorReporter receives the error behind a proxy answer that leaves it out, such as a 503 for an unreachable store, so the host can log it with the request.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
func NewProxy ¶
func NewProxy(authorizer domain.SubscriptionAuthorizer, secret string, options ...ProxyOption) (*Proxy, error)
type ProxyOption ¶
type ProxyOption func(*Proxy)
ProxyOption configures a Proxy.
func WithErrorReporter ¶
func WithErrorReporter(report ErrorReporter) ProxyOption
WithErrorReporter passes the cause of each 503 to report.
type Publication ¶
Publication is one message for one Centrifugo channel.
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher pushes straight to Centrifugo's HTTP API after a commit. It sends all of a call's commands in one API request and retries the failed ones briefly. What still fails is logged and returned; it never undoes the commit, and clients recover by re-reading their state over HTTP. Nothing is queued.
func NewPublisher ¶
func (*Publisher) Publish ¶
func (publisher *Publisher) Publish(ctx context.Context, publications ...Publication) error
Publish delivers each publication to its channel. Games use it for their own events, such as a turn result on each player's personal channel.
func (*Publisher) PublishChange ¶
func (publisher *Publisher) PublishChange(ctx context.Context, room domain.Lobby, change domain.Change, stillDue domain.RevocationCheck) error
PublishChange announces a committed room version to the room channel and unsubscribes each revoked player from it. Before every attempt, stillDue confirms each unsubscribe, which is skipped once the player has rejoined.
type PushRetry ¶
type PushRetry struct {
Attempts int
AttemptTimeout time.Duration
// Pause precedes the second attempt and doubles before each later one.
Pause time.Duration
}
PushRetry bounds the time a request spends pushing after its commit.
func DefaultPushRetry ¶
func DefaultPushRetry() PushRetry
DefaultPushRetry makes three attempts within about a second.