Documentation ¶
Index ¶
Constants ¶
const ( ConcurrencyModeBroadcast = iota // Broadcasting ConcurrencyModeFILO // First-in, last-out ConcurrencyModeLIFO // Last-in, first-out )
Concurrency mode defines the behaviour of channels when there are multiple subscribers. If conflicts occur in FILO and LIFO modes, a 409 Conflict message will be broadcasted to the clients that were kicked out.
const ( PollingMechanismLong = iota // Long-polling PollingMechanismInterval // Interval-polling )
Polling mechanism defines the behaviour of response-cycles.
Variables ¶
var DefaultConfiguration = Configuration{
ChannelCapacity: 20,
GCInterval: 60e9,
MaxChannelIdleTime: 600e9,
PollingTimeout: 20e9,
}
DefaultConfiguration holds some sensible defaults.
Logger is the logging facility used by Pusher
Functions ¶
func New ¶
func New(acceptor Acceptor, config Configuration) (p *pusher)
New creates a new pusher that is ready to be muxed into any ServeMux. The new pusher (and any channel in it's context) will behave according to the given configuration options are acceptor logic.
Types ¶
type Acceptor ¶
Acceptor is a pre-flight mechanism for a) authenticating incoming subscriber/publisher request and b) extracting a channel id from a request. The channel id is gIf an acceptor decides that the request should NOT be allowed to publish/subscribe, then it must return an empty string.
func QueryParameterAcceptor ¶
QueryParameterAcceptor accepts all requests and uses always a provided parameter form the query as the channel id.
func StaticAcceptor ¶
StaticAcceptor accepts all requests and uses always an static channel id.
type Configuration ¶
type Configuration struct { AllowChannelCreation bool // Can channels be created through subscriber locations. ChannelCapacity int // The capacity of the channels (queue length, 0=unlimited). ConcurrencyMode int // The behaviour of channels under concurrent subscribers ContentType string // Override outgoing Content-Type headers. GCInterval int64 // The interval between collecting stale channels (0=disable). MaxChannels int // Maximum amount of channels (0=unlimited). MaxChannelIdleTime int64 // Maximum idle time for a channel (0=unlimited). PollingMechanism int // The behaviour of response-cycles. PollingTimeout int64 // Maximum time for a long-polling connection (0=unlimited). }
Configuration holds various parameters for the server.
type Message ¶
type Message struct { ContentType string // HTTP content-type to use Payload []byte // the body to use Status int // HTTP status code to use // contains filtered or unexported fields }
A Message defines a single application specific data packet, containing the original content-type and body along with a HTTP status code to use when delivering it.
type Stats ¶
type Stats struct { Created int64 // The time the channel was created. Delivered int64 // The amonut of messages delivered. LastPublished int64 // The time the last message was published. LastRequested int64 // The time the last message was requested. Published int64 // The amount of messages published. Subscribers int // The amount of active subscribers. Queued int // The amount of messages queued. }
Stats holds information about a channel.