Documentation ¶
Index ¶
- Variables
- func ValidateChannelOptions(c ChannelOptions) error
- func ValidateNamespace(ns ChannelNamespace) error
- func ValidateRpcNamespace(ns RpcNamespace) error
- func ValidateRpcOptions(_ RpcOptions) error
- func WarnUnknownNamespaceKeys(jsonNamespaces []byte)
- func WarnUnknownRpcNamespaceKeys(jsonRpcNamespaces []byte)
- type ChannelNamespace
- type ChannelOptions
- type Compiled
- type Config
- type Container
- func (n *Container) ChannelOptions(ch string) (string, string, ChannelOptions, bool, error)
- func (n *Container) Config() Config
- func (n *Container) IsPrivateChannel(ch string) bool
- func (n *Container) IsUserLimited(ch string) bool
- func (n *Container) NumNamespaces() int
- func (n *Container) NumRpcNamespaces() int
- func (n *Container) PersonalChannel(user string) string
- func (n *Container) Reload(c Config) error
- func (n *Container) RpcOptions(method string) (RpcOptions, bool, error)
- func (n *Container) UserAllowed(ch string, user string) bool
- type RpcNamespace
- type RpcOptions
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{
ChannelPrivatePrefix: "$",
ChannelNamespaceBoundary: ":",
ChannelUserBoundary: "#",
ChannelUserSeparator: ",",
RpcNamespaceBoundary: ":",
}
DefaultConfig has default config options.
Functions ¶
func ValidateChannelOptions ¶
func ValidateChannelOptions(c ChannelOptions) error
func ValidateNamespace ¶
func ValidateNamespace(ns ChannelNamespace) error
func ValidateRpcNamespace ¶
func ValidateRpcNamespace(ns RpcNamespace) error
func ValidateRpcOptions ¶
func ValidateRpcOptions(_ RpcOptions) error
func WarnUnknownNamespaceKeys ¶
func WarnUnknownNamespaceKeys(jsonNamespaces []byte)
func WarnUnknownRpcNamespaceKeys ¶
func WarnUnknownRpcNamespaceKeys(jsonRpcNamespaces []byte)
Types ¶
type ChannelNamespace ¶
type ChannelNamespace struct { // Name is a unique namespace name. Name string `mapstructure:"name" json:"name"` // Options for namespace determine channel options for channels // belonging to this namespace. ChannelOptions `mapstructure:",squash"` }
ChannelNamespace allows creating channels with different channel options.
type ChannelOptions ¶
type ChannelOptions struct { // Presence turns on presence information for channel. Presence has // information about all clients currently subscribed to a channel. Presence bool `mapstructure:"presence" json:"presence"` // JoinLeave turns on join/leave messages for a channel. // When client subscribes on a channel join message sent to all // subscribers in this channel (including current client). When client // leaves channel (unsubscribes) leave message sent. This option does // not fit well for channels with many subscribers because every // subscribe/unsubscribe event results into join/leave event broadcast // to all other active subscribers thus overloads server with tons of // messages. Use accurately for channels with small number of active // subscribers. JoinLeave bool `mapstructure:"join_leave" json:"join_leave"` // ForcePushJoinLeave forces sending join/leave messages towards subscribers. ForcePushJoinLeave bool `mapstructure:"force_push_join_leave" json:"force_push_join_leave"` // HistorySize determines max amount of history messages for a channel, // Zero value means no history for channel. Centrifuge history has an // auxiliary role with current Engines – it can not replace your backend // persistent storage. HistorySize int `mapstructure:"history_size" json:"history_size"` // HistoryTTL is a time to live for history cache. Server maintains a window of // messages in memory (or in Redis with Redis engine), to prevent infinite memory // grows it's important to remove history for inactive channels. HistoryTTL tools.Duration `mapstructure:"history_ttl" json:"history_ttl"` // HistoryMetaTTL is a time to live for history stream meta information. Must be // much larger than HistoryTTL in common scenario. If zero, then we use global value // set over default_history_meta_ttl on configuration top level. HistoryMetaTTL tools.Duration `mapstructure:"history_meta_ttl" json:"history_meta_ttl"` // ForcePositioning enables client positioning. This means that StreamPosition // will be exposed to the client and server will look that no messages from // PUB/SUB layer lost. In the loss found – client is disconnected (or unsubscribed) // with reconnect (resubscribe) code. ForcePositioning bool `mapstructure:"force_positioning" json:"force_positioning"` // AllowPositioning allows positioning when client asks about it. AllowPositioning bool `mapstructure:"allow_positioning" json:"allow_positioning"` // ForceRecovery enables recovery mechanism for channels. This means that // server will try to recover missed messages for resubscribing client. // This option uses publications from history and must be used with reasonable // HistorySize and HistoryTTL configuration. ForceRecovery bool `mapstructure:"force_recovery" json:"force_recovery"` // AllowRecovery allows recovery when client asks about it. AllowRecovery bool `mapstructure:"allow_recovery" json:"allow_recovery"` // SubscribeForAnonymous ... SubscribeForAnonymous bool `mapstructure:"allow_subscribe_for_anonymous" json:"allow_subscribe_for_anonymous"` // SubscribeForClient ... SubscribeForClient bool `mapstructure:"allow_subscribe_for_client" json:"allow_subscribe_for_client"` // PublishForAnonymous ... PublishForAnonymous bool `mapstructure:"allow_publish_for_anonymous" json:"allow_publish_for_anonymous"` // PublishForSubscriber ... PublishForSubscriber bool `mapstructure:"allow_publish_for_subscriber" json:"allow_publish_for_subscriber"` // PublishForClient ... PublishForClient bool `mapstructure:"allow_publish_for_client" json:"allow_publish_for_client"` // PresenceForAnonymous ... PresenceForAnonymous bool `mapstructure:"allow_presence_for_anonymous" json:"allow_presence_for_anonymous"` // PresenceForSubscriber ... PresenceForSubscriber bool `mapstructure:"allow_presence_for_subscriber" json:"allow_presence_for_subscriber"` // PresenceForClient ... PresenceForClient bool `mapstructure:"allow_presence_for_client" json:"allow_presence_for_client"` // HistoryForAnonymous ... HistoryForAnonymous bool `mapstructure:"allow_history_for_anonymous" json:"allow_history_for_anonymous"` // HistoryForSubscriber ... HistoryForSubscriber bool `mapstructure:"allow_history_for_subscriber" json:"allow_history_for_subscriber"` // HistoryForClient ... HistoryForClient bool `mapstructure:"allow_history_for_client" json:"allow_history_for_client"` // UserLimitedChannels ... UserLimitedChannels bool `mapstructure:"allow_user_limited_channels" json:"allow_user_limited_channels"` // ChannelRegex ... ChannelRegex string `mapstructure:"channel_regex" json:"channel_regex"` // ProxySubscribe turns on proxying subscribe decision for channels. ProxySubscribe bool `mapstructure:"proxy_subscribe" json:"proxy_subscribe"` // ProxyPublish turns on proxying publish decision for channels. ProxyPublish bool `mapstructure:"proxy_publish" json:"proxy_publish"` // ProxySubRefresh turns on proxying sub refresh for channels. ProxySubRefresh bool `mapstructure:"proxy_sub_refresh" json:"proxy_sub_refresh"` // SubscribeProxyName of proxy to use for subscribe operations in namespace. SubscribeProxyName string `mapstructure:"subscribe_proxy_name" json:"subscribe_proxy_name"` // PublishProxyName of proxy to use for publish operations in namespace. PublishProxyName string `mapstructure:"publish_proxy_name" json:"publish_proxy_name"` // SubRefreshProxyName of proxy to use for sub refresh operations in namespace. SubRefreshProxyName string `mapstructure:"sub_refresh_proxy_name" json:"sub_refresh_proxy_name"` Compiled }
ChannelOptions represent channel specific configuration for namespace or global channel options if set on top level of configuration.
type Config ¶
type Config struct { // ChannelOptions embedded on top level. ChannelOptions // Namespaces – list of namespaces for custom channel options. Namespaces []ChannelNamespace // RpcOptions embedded on top level. RpcOptions // RpcNamespaces - list of rpc namespace for custom rpc options. RpcNamespaces []RpcNamespace // RpcNamespaceBoundary is a string separator which must be put after // rpc namespace part in rpc method. RpcNamespaceBoundary string // ChannelUserBoundary is a string separator which must be set before // allowed users part in channel name. // ChannelPrivatePrefix is a prefix in channel name which indicates that // channel is private. ChannelPrivatePrefix string // ChannelNamespaceBoundary is a string separator which must be put after // namespace part in channel name. ChannelNamespaceBoundary string // ChannelUserBoundary is a string separator which must be set before // allowed users part in channel name. ChannelUserBoundary string // ChannelUserSeparator separates allowed users in user part of channel name. // So you can limit access to channel to limited set of users. ChannelUserSeparator string // UserSubscribeToPersonal enables automatic subscribing to personal channel // by user. Only users with user ID defined will subscribe to personal // channels, anonymous users are ignored. UserSubscribeToPersonal bool // UserPersonalChannelPrefix defines prefix to be added to user personal channel. // This should match one of configured namespace names. By default, no namespace // used for personal channel. UserPersonalChannelNamespace string // UserPersonalSingleConnection turns on a mode in which Centrifugo will try to // maintain only a single connection for each user in the same moment. As soon as // user establishes a connection other connections from the same user will be closed // with connection limit reason. // This feature works with a help of presence information inside personal channel. // So presence should be turned on in personal channel. UserPersonalSingleConnection bool // ClientInsecure turns on insecure mode for client connections - when it's // turned on then no authentication required at all when connecting to Centrifugo, // anonymous access and publish allowed for all channels, no connection expire // performed. This can be suitable for demonstration or personal usage. ClientInsecure bool // AnonymousConnectWithoutToken when set to true, allows connecting without specifying // a connection token or setting Credentials in authentication middleware. The resulting // user will have empty string for user ID (i.e. user is treated as anonymous). AnonymousConnectWithoutToken bool // DisallowAnonymousConnectionTokens tells Centrifugo to not accept connections from // anonymous users even if they provided a valid JWT. I.e. if token is valid but `sub` // claim is empty then Centrifugo closes connection with advice to not reconnect again. DisallowAnonymousConnectionTokens bool // ClientConcurrency when set allows processing client commands concurrently // with provided concurrency level. By default, commands processed sequentially // one after another. ClientConcurrency int // ClientConnectionLimit sets the maximum number of concurrent clients a single Centrifugo // node will accept. ClientConnectionLimit int // ClientConnectionRateLimit sets the maximum number of new connections a single Centrifugo // node will accept per second. ClientConnectionRateLimit int }
Config ...
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container ...
func (*Container) ChannelOptions ¶
ChannelOptions returns channel options for channel using current channel config.
func (*Container) IsPrivateChannel ¶
IsPrivateChannel checks if channel requires token to subscribe. In case of token-protected channel subscription request must contain a proper token.
func (*Container) IsUserLimited ¶
IsUserLimited returns whether channel is user-limited.
func (*Container) NumNamespaces ¶
NumNamespaces returns number of configured namespaces.
func (*Container) NumRpcNamespaces ¶
NumRpcNamespaces returns number of configured rpc namespaces.
func (*Container) PersonalChannel ¶
PersonalChannel returns personal channel for user based on node configuration.
func (*Container) RpcOptions ¶
func (n *Container) RpcOptions(method string) (RpcOptions, bool, error)
RpcOptions returns rpc options for method using current config.
type RpcNamespace ¶
type RpcNamespace struct { // Name is a unique rpc namespace name. Name string `mapstructure:"name" json:"name"` // Options for rpc namespace. RpcOptions `mapstructure:",squash"` }
RpcNamespace allows creating rules for different rpc.
type RpcOptions ¶
type RpcOptions struct { // RpcProxyName which should be used for RPC namespace. RpcProxyName string `mapstructure:"rpc_proxy_name" json:"rpc_proxy_name,omitempty"` }
RpcOptions can set a custom behaviour for rpc namespace.