Documentation ¶
Overview ¶
Package unifrost is a small package for relaying pubsub messages to the web via SSE(EventSource). It is loosely based on Twitter's implementation for real-time event-streaming in their new web app.
It uses GO CDK (gocloud.dev) for pubsub, so it supports various vendors ->
Google Cloud Pub/Sub Amazon Simple Queueing Service (SQS) (Pending) Azure Service Bus (Pending) RabbitMQ NATS Kafka In-memory (Only for testing)
Index ¶
- Variables
- type Client
- type Option
- type Streamer
- func (streamer *Streamer) Close(ctx context.Context) error
- func (streamer *Streamer) GetClient(ctx context.Context, clientID string) *Client
- func (streamer *Streamer) NewClient(ctx context.Context) (*Client, error)
- func (streamer *Streamer) NewCustomClient(ctx context.Context, clientID string) (*Client, error)
- func (streamer *Streamer) RemoveClient(ctx context.Context, clientID string) error
- func (streamer *Streamer) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (streamer *Streamer) Subscribe(ctx context.Context, clientID string, topic string) error
- func (streamer *Streamer) TotalClients(ctx context.Context) int
- func (streamer *Streamer) Unsubscribe(ctx context.Context, clientID string, topic string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoClient is returned if the client-id is not registered in the streamer. ErrNoClient = errors.New("streamer: Client doesn't exists") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ID string // contains filtered or unexported fields }
Client is a top-level struct that manages all the topics.
type Streamer ¶
type Streamer struct {
// contains filtered or unexported fields
}
Streamer is a top-level struct that will handle all the clients and subscriptions. It implements the http.Handler interface for easy working with the server.
func NewStreamer ¶
func NewStreamer(subClient drivers.SubscriberClient, options ...Option) (*Streamer, error)
NewStreamer is the construtor for Streamer struct
func (*Streamer) Close ¶
Close method closes the streamer and also closes all the connected clients.
func (*Streamer) GetClient ¶
GetClient method returns the client instance of the specified clientID.
func (*Streamer) NewCustomClient ¶
NewCustomClient method creates a new client with the specified clientID.
func (*Streamer) RemoveClient ¶
RemoveClient method removes the client from streamer and closes it.
func (*Streamer) ServeHTTP ¶
func (streamer *Streamer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is the http handler for eventsource. For connecting query parameter 'id' is required i.e client-id.
func (*Streamer) Subscribe ¶
Subscribe method subscribes the specified client to the specified topic. If specified client doesn't exists ErrNoClient error is returned.
func (*Streamer) TotalClients ¶
TotalClients method returns the number of client connected to the streamer.
func (*Streamer) Unsubscribe ¶
Unsubscribe method unsubscribes the specified client to the specified topic and shutdowns the subscription. If specified client doesn't exists ErrNoClient error is returned.
Directories ¶
Path | Synopsis |
---|---|
Package drivers encapsulates all the drivers required under a single easy to use interface.
|
Package drivers encapsulates all the drivers required under a single easy to use interface. |
examples
|
|