Documentation ¶
Index ¶
- Constants
- type BoolValue
- type Client
- type ConnectCredentials
- type ConnectExtra
- type ConnectHandler
- type ConnectHandlerConfig
- type ConnectProxy
- type ConnectReply
- type ConnectRequest
- type ConnectingHandlerFunc
- type GRPCConnectProxy
- type GRPCPublishProxy
- type GRPCRPCProxy
- type GRPCRefreshProxy
- type GRPCSubscribeProxy
- type HTTPCaller
- type HTTPConnectProxy
- type HTTPPublishProxy
- type HTTPRPCProxy
- type HTTPRefreshProxy
- type HTTPSubscribeProxy
- type PerCallData
- type Proxy
- type PublishHandler
- type PublishHandlerConfig
- type PublishHandlerFunc
- type PublishProxy
- type PublishReply
- type PublishRequest
- type PublishRequestHTTP
- type PublishResult
- type RPCData
- type RPCHandler
- type RPCHandlerConfig
- type RPCHandlerFunc
- type RPCProxy
- type RPCReply
- type RPCRequest
- type RefreshCredentials
- type RefreshExtra
- type RefreshHandler
- type RefreshHandlerConfig
- type RefreshHandlerFunc
- type RefreshProxy
- type RefreshReply
- type RefreshRequest
- type RefreshRequestHTTP
- type SubscribeExtra
- type SubscribeHandler
- type SubscribeHandlerConfig
- type SubscribeHandlerFunc
- type SubscribeOptionOverride
- type SubscribeOptions
- type SubscribeProxy
- type SubscribeReply
- type SubscribeRequest
- type SubscribeResult
Constants ¶
const DefaultMaxIdleConnsPerHost = 255
DefaultMaxIdleConnsPerHost is a reasonable value for all HTTP clients.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoolValue ¶
type BoolValue struct {
Value bool `json:"value,omitempty"`
}
BoolValue allows override boolean option.
type Client ¶ added in v4.0.1
type Client interface { ID() string UserID() string Context() context.Context Transport() centrifuge.TransportInfo }
type ConnectCredentials ¶
type ConnectCredentials struct { UserID string `json:"user"` ExpireAt int64 `json:"expire_at"` Info json.RawMessage `json:"info"` Base64Info string `json:"b64info"` Data json.RawMessage `json:"data"` Base64Data string `json:"b64data"` Channels []string `json:"channels"` Subs map[string]SubscribeOptions `json:"subs,omitempty"` }
ConnectCredentials ...
type ConnectExtra ¶
type ConnectExtra struct { }
type ConnectHandler ¶
type ConnectHandler struct {
// contains filtered or unexported fields
}
ConnectHandler ...
func NewConnectHandler ¶
func NewConnectHandler(c ConnectHandlerConfig, ruleContainer *rule.Container) *ConnectHandler
NewConnectHandler ...
func (*ConnectHandler) Handle ¶
func (h *ConnectHandler) Handle(node *centrifuge.Node) ConnectingHandlerFunc
Handle returns connecting handler func.
type ConnectHandlerConfig ¶
type ConnectHandlerConfig struct {
Proxy ConnectProxy
}
ConnectHandlerConfig ...
type ConnectProxy ¶
type ConnectProxy interface { ProxyConnect(context.Context, *proxyproto.ConnectRequest) (*proxyproto.ConnectResponse, error) // Protocol for metrics and logging. Protocol() string // UseBase64 for bytes in requests from Centrifugo to application backend. UseBase64() bool }
ConnectProxy allows to proxy connect requests to application backend to authenticate client connection.
func GetConnectProxy ¶
func GetConnectProxy(p Proxy) (ConnectProxy, error)
type ConnectReply ¶
type ConnectReply struct { Result *ConnectCredentials `json:"result"` Error *centrifuge.Error `json:"error"` Disconnect *centrifuge.Disconnect `json:"disconnect"` }
ConnectReply ...
type ConnectRequest ¶
type ConnectRequest struct { ClientID string Transport centrifuge.TransportInfo Data []byte Name string Version string }
ConnectRequest ...
type ConnectingHandlerFunc ¶
type ConnectingHandlerFunc func(context.Context, centrifuge.ConnectEvent) (centrifuge.ConnectReply, ConnectExtra, error)
type GRPCConnectProxy ¶
type GRPCConnectProxy struct {
// contains filtered or unexported fields
}
GRPCConnectProxy ...
func NewGRPCConnectProxy ¶
func NewGRPCConnectProxy(p Proxy) (*GRPCConnectProxy, error)
NewGRPCConnectProxy ...
func (*GRPCConnectProxy) ProxyConnect ¶
func (p *GRPCConnectProxy) ProxyConnect(ctx context.Context, req *proxyproto.ConnectRequest) (*proxyproto.ConnectResponse, error)
ProxyConnect proxies connect control to application backend.
type GRPCPublishProxy ¶
type GRPCPublishProxy struct {
// contains filtered or unexported fields
}
GRPCPublishProxy ...
func NewGRPCPublishProxy ¶
func NewGRPCPublishProxy(p Proxy) (*GRPCPublishProxy, error)
NewGRPCPublishProxy ...
func (*GRPCPublishProxy) IncludeMeta ¶
func (p *GRPCPublishProxy) IncludeMeta() bool
IncludeMeta ...
func (*GRPCPublishProxy) ProxyPublish ¶
func (p *GRPCPublishProxy) ProxyPublish(ctx context.Context, req *proxyproto.PublishRequest) (*proxyproto.PublishResponse, error)
ProxyPublish proxies Publish to application backend.
type GRPCRPCProxy ¶
type GRPCRPCProxy struct {
// contains filtered or unexported fields
}
GRPCRPCProxy ...
func (*GRPCRPCProxy) ProxyRPC ¶
func (p *GRPCRPCProxy) ProxyRPC(ctx context.Context, req *proxyproto.RPCRequest) (*proxyproto.RPCResponse, error)
ProxyRPC ...
type GRPCRefreshProxy ¶
type GRPCRefreshProxy struct {
// contains filtered or unexported fields
}
GRPCRefreshProxy ...
func NewGRPCRefreshProxy ¶
func NewGRPCRefreshProxy(p Proxy) (*GRPCRefreshProxy, error)
NewGRPCRefreshProxy ...
func (*GRPCRefreshProxy) IncludeMeta ¶
func (p *GRPCRefreshProxy) IncludeMeta() bool
IncludeMeta ...
func (*GRPCRefreshProxy) ProxyRefresh ¶
func (p *GRPCRefreshProxy) ProxyRefresh(ctx context.Context, req *proxyproto.RefreshRequest) (*proxyproto.RefreshResponse, error)
ProxyRefresh proxies refresh to application backend.
type GRPCSubscribeProxy ¶
type GRPCSubscribeProxy struct {
// contains filtered or unexported fields
}
GRPCSubscribeProxy ...
func NewGRPCSubscribeProxy ¶
func NewGRPCSubscribeProxy(p Proxy) (*GRPCSubscribeProxy, error)
NewGRPCSubscribeProxy ...
func (*GRPCSubscribeProxy) IncludeMeta ¶
func (p *GRPCSubscribeProxy) IncludeMeta() bool
IncludeMeta ...
func (*GRPCSubscribeProxy) ProxySubscribe ¶
func (p *GRPCSubscribeProxy) ProxySubscribe(ctx context.Context, req *proxyproto.SubscribeRequest) (*proxyproto.SubscribeResponse, error)
ProxySubscribe proxies Subscribe to application backend.
type HTTPCaller ¶
type HTTPCaller interface {
CallHTTP(context.Context, string, http.Header, []byte) ([]byte, error)
}
HTTPCaller is responsible for calling HTTP.
func NewHTTPCaller ¶
func NewHTTPCaller(httpClient *http.Client) HTTPCaller
NewHTTPCaller creates new HTTPCaller.
type HTTPConnectProxy ¶
type HTTPConnectProxy struct {
// contains filtered or unexported fields
}
HTTPConnectProxy ...
func NewHTTPConnectProxy ¶
func NewHTTPConnectProxy(p Proxy) (*HTTPConnectProxy, error)
NewHTTPConnectProxy ...
func (*HTTPConnectProxy) ProxyConnect ¶
func (p *HTTPConnectProxy) ProxyConnect(ctx context.Context, req *proxyproto.ConnectRequest) (*proxyproto.ConnectResponse, error)
ProxyConnect proxies connect control to application backend.
type HTTPPublishProxy ¶
type HTTPPublishProxy struct {
// contains filtered or unexported fields
}
HTTPPublishProxy ...
func NewHTTPPublishProxy ¶
func NewHTTPPublishProxy(p Proxy) (*HTTPPublishProxy, error)
NewHTTPPublishProxy ...
func (*HTTPPublishProxy) IncludeMeta ¶
func (p *HTTPPublishProxy) IncludeMeta() bool
IncludeMeta ...
func (*HTTPPublishProxy) ProxyPublish ¶
func (p *HTTPPublishProxy) ProxyPublish(ctx context.Context, req *proxyproto.PublishRequest) (*proxyproto.PublishResponse, error)
ProxyPublish proxies Publish to application backend.
type HTTPRPCProxy ¶
type HTTPRPCProxy struct {
// contains filtered or unexported fields
}
HTTPRPCProxy ...
func (*HTTPRPCProxy) ProxyRPC ¶
func (p *HTTPRPCProxy) ProxyRPC(ctx context.Context, req *proxyproto.RPCRequest) (*proxyproto.RPCResponse, error)
ProxyRPC ...
type HTTPRefreshProxy ¶
type HTTPRefreshProxy struct {
// contains filtered or unexported fields
}
HTTPRefreshProxy ...
func NewHTTPRefreshProxy ¶
func NewHTTPRefreshProxy(p Proxy) (*HTTPRefreshProxy, error)
NewHTTPRefreshProxy ...
func (*HTTPRefreshProxy) IncludeMeta ¶
func (p *HTTPRefreshProxy) IncludeMeta() bool
IncludeMeta ...
func (*HTTPRefreshProxy) ProxyRefresh ¶
func (p *HTTPRefreshProxy) ProxyRefresh(ctx context.Context, req *proxyproto.RefreshRequest) (*proxyproto.RefreshResponse, error)
ProxyRefresh proxies refresh to application backend.
type HTTPSubscribeProxy ¶
type HTTPSubscribeProxy struct {
// contains filtered or unexported fields
}
HTTPSubscribeProxy ...
func NewHTTPSubscribeProxy ¶
func NewHTTPSubscribeProxy(p Proxy) (*HTTPSubscribeProxy, error)
NewHTTPSubscribeProxy ...
func (*HTTPSubscribeProxy) IncludeMeta ¶
func (p *HTTPSubscribeProxy) IncludeMeta() bool
IncludeMeta ...
func (*HTTPSubscribeProxy) ProxySubscribe ¶
func (p *HTTPSubscribeProxy) ProxySubscribe(ctx context.Context, req *proxyproto.SubscribeRequest) (*proxyproto.SubscribeResponse, error)
ProxySubscribe proxies Subscribe to application backend.
type PerCallData ¶
type PerCallData struct {
Meta json.RawMessage
}
type Proxy ¶
type Proxy struct { // Name is a unique name of proxy to reference. Name string `mapstructure:"name" json:"name"` // Endpoint - HTTP address or GRPC service endpoint. Endpoint string `mapstructure:"endpoint" json:"endpoint"` // Timeout for proxy request. Timeout tools.Duration `mapstructure:"timeout" json:"timeout,omitempty"` // HTTPHeaders is a list of HTTP headers to proxy. No headers used by proxy by default. // If GRPC proxy is used then request HTTP headers set to outgoing request metadata. HttpHeaders []string `mapstructure:"http_headers" json:"http_headers,omitempty"` // GRPCMetadata is a list of GRPC metadata keys to proxy. No meta keys used by proxy by // default. If HTTP proxy is used then these keys become outgoing request HTTP headers. GrpcMetadata []string `mapstructure:"grpc_metadata" json:"grpc_metadata,omitempty"` // BinaryEncoding makes proxy send data as base64 string (assuming it contains custom // non-JSON payload). BinaryEncoding bool `mapstructure:"binary_encoding" json:"binary_encoding,omitempty"` // IncludeConnectionMeta to each proxy request (except connect where it's obtained). IncludeConnectionMeta bool `mapstructure:"include_connection_meta" json:"include_connection_meta,omitempty"` // GrpcCertFile is a path to GRPC cert file on disk. GrpcCertFile string `mapstructure:"grpc_cert_file" json:"grpc_cert_file,omitempty"` // GrpcCredentialsKey is a custom key to add into per-RPC credentials. GrpcCredentialsKey string `mapstructure:"grpc_credentials_key" json:"grpc_credentials_key,omitempty"` // GrpcCredentialsValue is a custom value for GrpcCredentialsKey. GrpcCredentialsValue string `mapstructure:"grpc_credentials_value" json:"grpc_credentials_value,omitempty"` // contains filtered or unexported fields }
Proxy model.
type PublishHandler ¶
type PublishHandler struct {
// contains filtered or unexported fields
}
PublishHandler ...
func NewPublishHandler ¶
func NewPublishHandler(c PublishHandlerConfig) *PublishHandler
NewPublishHandler ...
func (*PublishHandler) Handle ¶
func (h *PublishHandler) Handle(node *centrifuge.Node) PublishHandlerFunc
Handle Publish.
type PublishHandlerConfig ¶
type PublishHandlerConfig struct { Proxies map[string]PublishProxy GranularProxyMode bool }
PublishHandlerConfig ...
type PublishHandlerFunc ¶
type PublishHandlerFunc func(Client, centrifuge.PublishEvent, rule.ChannelOptions, PerCallData) (centrifuge.PublishReply, error)
PublishHandlerFunc ...
type PublishProxy ¶
type PublishProxy interface { ProxyPublish(context.Context, *proxyproto.PublishRequest) (*proxyproto.PublishResponse, error) // Protocol for metrics and logging. Protocol() string // UseBase64 for bytes in requests from Centrifugo to application backend. UseBase64() bool // IncludeMeta ... IncludeMeta() bool }
PublishProxy allows to send Publish requests.
func GetPublishProxy ¶
func GetPublishProxy(p Proxy) (PublishProxy, error)
type PublishReply ¶
type PublishReply struct { Result *PublishResult `json:"result"` Error *centrifuge.Error `json:"error"` Disconnect *centrifuge.Disconnect `json:"disconnect"` }
PublishReply ...
type PublishRequest ¶
type PublishRequest struct { ClientID string UserID string Channel string Data []byte Transport centrifuge.TransportInfo }
PublishRequest ...
type PublishRequestHTTP ¶
type PublishRequestHTTP struct { UserID string `json:"user"` Channel string `json:"channel"` Data json.RawMessage `json:"data,omitempty"` // Base64Data to proxy binary data. Base64Data string `json:"b64data,omitempty"` // contains filtered or unexported fields }
PublishRequestHTTP ...
type PublishResult ¶
type PublishResult struct { Data json.RawMessage `json:"data"` Base64Data string `json:"b64data"` }
PublishResult ...
type RPCData ¶
type RPCData struct { Data json.RawMessage `json:"data"` Base64Data string `json:"b64data"` }
RPCData ...
type RPCHandler ¶
type RPCHandler struct {
// contains filtered or unexported fields
}
RPCHandler ...
func (*RPCHandler) Handle ¶
func (h *RPCHandler) Handle(node *centrifuge.Node) RPCHandlerFunc
Handle RPC.
type RPCHandlerConfig ¶
RPCHandlerConfig ...
type RPCHandlerFunc ¶
type RPCHandlerFunc func(Client, centrifuge.RPCEvent, *rule.Container, PerCallData) (centrifuge.RPCReply, error)
RPCHandlerFunc ...
type RPCProxy ¶
type RPCProxy interface { ProxyRPC(context.Context, *proxyproto.RPCRequest) (*proxyproto.RPCResponse, error) // Protocol for metrics and logging. Protocol() string // UseBase64 for bytes in requests from Centrifugo to application backend. UseBase64() bool // IncludeMeta ... IncludeMeta() bool }
RPCProxy allows to proxy RPC requests to application backend.
func GetRpcProxy ¶
type RPCReply ¶
type RPCReply struct { Result *RPCData `json:"result"` Error *centrifuge.Error `json:"error"` Disconnect *centrifuge.Disconnect `json:"disconnect"` }
RPCReply ...
type RPCRequest ¶
type RPCRequest struct { Method string Data []byte ClientID string UserID string Transport centrifuge.TransportInfo }
RPCRequest ...
type RefreshCredentials ¶
type RefreshCredentials struct { Expired bool `json:"expired"` ExpireAt int64 `json:"expire_at"` Info json.RawMessage `json:"info"` Base64Info string `json:"b64info"` }
RefreshCredentials ...
type RefreshExtra ¶
type RefreshExtra struct {
Meta json.RawMessage
}
type RefreshHandler ¶
type RefreshHandler struct {
// contains filtered or unexported fields
}
RefreshHandler ...
func NewRefreshHandler ¶
func NewRefreshHandler(c RefreshHandlerConfig) *RefreshHandler
NewRefreshHandler ...
func (*RefreshHandler) Handle ¶
func (h *RefreshHandler) Handle(node *centrifuge.Node) RefreshHandlerFunc
Handle refresh.
type RefreshHandlerConfig ¶
type RefreshHandlerConfig struct {
Proxy RefreshProxy
}
RefreshHandlerConfig ...
type RefreshHandlerFunc ¶
type RefreshHandlerFunc func(Client, centrifuge.RefreshEvent, PerCallData) (centrifuge.RefreshReply, RefreshExtra, error)
RefreshHandlerFunc ...
type RefreshProxy ¶
type RefreshProxy interface { ProxyRefresh(context.Context, *proxyproto.RefreshRequest) (*proxyproto.RefreshResponse, error) // Protocol for metrics and logging. Protocol() string // UseBase64 for bytes in requests from Centrifugo to application backend. UseBase64() bool // IncludeMeta ... IncludeMeta() bool }
RefreshProxy allows to send refresh requests.
func GetRefreshProxy ¶
func GetRefreshProxy(p Proxy) (RefreshProxy, error)
type RefreshReply ¶
type RefreshReply struct { Result *RefreshCredentials `json:"result"` Error *centrifuge.Error `json:"error"` Disconnect *centrifuge.Disconnect `json:"disconnect"` }
RefreshReply ...
type RefreshRequest ¶
type RefreshRequest struct { ClientID string UserID string Transport centrifuge.TransportInfo }
RefreshRequest ...
type RefreshRequestHTTP ¶
type RefreshRequestHTTP struct { UserID string `json:"user"` // contains filtered or unexported fields }
RefreshRequestHTTP ...
type SubscribeExtra ¶
type SubscribeExtra struct { }
type SubscribeHandler ¶
type SubscribeHandler struct {
// contains filtered or unexported fields
}
SubscribeHandler ...
func NewSubscribeHandler ¶
func NewSubscribeHandler(c SubscribeHandlerConfig) *SubscribeHandler
NewSubscribeHandler ...
func (*SubscribeHandler) Handle ¶
func (h *SubscribeHandler) Handle(node *centrifuge.Node) SubscribeHandlerFunc
Handle Subscribe.
type SubscribeHandlerConfig ¶
type SubscribeHandlerConfig struct { Proxies map[string]SubscribeProxy GranularProxyMode bool }
SubscribeHandlerConfig ...
type SubscribeHandlerFunc ¶
type SubscribeHandlerFunc func(Client, centrifuge.SubscribeEvent, rule.ChannelOptions, PerCallData) (centrifuge.SubscribeReply, SubscribeExtra, error)
SubscribeHandlerFunc ...
type SubscribeOptionOverride ¶
type SubscribeOptionOverride struct { // Presence turns on participating in channel presence. Presence *BoolValue `json:"presence,omitempty"` // JoinLeave enables sending Join and Leave messages for this client in channel. JoinLeave *BoolValue `json:"join_leave,omitempty"` // Position on says that client will additionally sync its position inside // a stream to prevent message loss. Make sure you are enabling Position in channels // that maintain Publication history stream. When Position is on Centrifuge will // include StreamPosition information to subscribe response - for a client to be able // to manually track its position inside a stream. Position *BoolValue `json:"position,omitempty"` // Recover turns on recovery option for a channel. In this case client will try to // recover missed messages automatically upon resubscribe to a channel after reconnect // to a server. This option also enables client position tracking inside a stream // (like Position option) to prevent occasional message loss. Make sure you are using // Recover in channels that maintain Publication history stream. Recover *BoolValue `json:"recover,omitempty"` }
SubscribeOptionOverride to override configured behaviour.
type SubscribeOptions ¶
type SubscribeOptions struct { // ExpireAt defines time in future when subscription should expire, // zero value means no expiration. ExpireAt int64 `json:"expire_at,omitempty"` // Info defines custom channel information, zero value means no channel information. Info json.RawMessage `json:"info,omitempty"` // Base64Info is like Info but for binary. Base64Info string `json:"b64info,omitempty"` // Data to send to a client with Subscribe Push. Data json.RawMessage `json:"data,omitempty"` // Base64Data is like Data but for binary data. Base64Data string `json:"b64data,omitempty"` // Override channel options can contain channel options overrides. Override *SubscribeOptionOverride `json:"override,omitempty"` }
SubscribeOptions define per-subscription options.
type SubscribeProxy ¶
type SubscribeProxy interface { ProxySubscribe(context.Context, *proxyproto.SubscribeRequest) (*proxyproto.SubscribeResponse, error) // Protocol for metrics and logging. Protocol() string // UseBase64 for bytes in requests from Centrifugo to application backend. UseBase64() bool // IncludeMeta ... IncludeMeta() bool }
SubscribeProxy allows to send Subscribe requests.
func GetSubscribeProxy ¶
func GetSubscribeProxy(p Proxy) (SubscribeProxy, error)
type SubscribeReply ¶
type SubscribeReply struct { Result *SubscribeResult `json:"result"` Error *centrifuge.Error `json:"error"` Disconnect *centrifuge.Disconnect `json:"disconnect"` }
SubscribeReply ...
type SubscribeRequest ¶
type SubscribeRequest struct { ClientID string UserID string Channel string Transport centrifuge.TransportInfo Token string }
SubscribeRequest ...
Source Files ¶
- client.go
- connect.go
- connect_grpc.go
- connect_handler.go
- connect_http.go
- grpc.go
- http.go
- metrics.go
- proxy.go
- publish.go
- publish_grpc.go
- publish_handler.go
- publish_http.go
- refresh.go
- refresh_grpc.go
- refresh_handler.go
- refresh_http.go
- rpc.go
- rpc_grpc.go
- rpc_handler.go
- rpc_http.go
- subscribe.go
- subscribe_grpc.go
- subscribe_handler.go
- subscribe_http.go
- test_grpc_server.go