Documentation
¶
Overview ¶
Package api - Contains network API implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CuratorSession ¶
type CuratorSession struct {
// contains filtered or unexported fields
}
CuratorSession - An API gateway between a client and a leaps curator. This gateway is responsible for tracking a client session as it attempts to create, connect to and edit documents.
func NewCuratorSession ¶
func NewCuratorSession( username, uuid string, emitter Emitter, cur curator.Type, timeout time.Duration, logger log.Modular, stats metrics.Aggregator, ) *CuratorSession
NewCuratorSession - Creates a curator gateway API for a user IO session that binds to events from the provided network IO emitter. Currently the API is limited to single document access, this could, however, be changed later.
type Emitter ¶
type Emitter interface {
// OnReceive - Register a handler for a particular incoming event type.
OnReceive(reqType string, handler RequestHandler)
// OnSend - Register a handler for a particular outgoing event type.
OnSend(resType string, handler ResponseHandler)
// OnClose - Register an event handler for a close event.
OnClose(eventHandler EventHandler)
// Send - Send data out to the client.
Send(resType string, body interface{}) error
}
Emitter - To be instantiated for each connected client. Allows components to implement the leaps service API by registering their request and event handlers. The emitter then handles networked traffic and brokers incoming requests to those registered components. All incoming messages are expected to be of the JSON format:
{
"type": "<type_string>",
"body": {...}
}
Handlers for request types are given the unparsed JSON body of the request. It is guaranteed that events will NOT be triggered in parallel, although they are not guaranteed to come from the same goroutine.
type EventHandler ¶
type EventHandler func()
EventHandler - Called on a connection related event (open, close, etc)
type GlobalMetadataBroker ¶
type GlobalMetadataBroker struct {
// contains filtered or unexported fields
}
GlobalMetadataBroker - The leaps API defines events that are outside of the functionality of curators and binders, such as chat messages and user join/leave notifications. The GlobalMetadataBroker implements these functions by managing references to open Emitters.
func NewGlobalMetadataBroker ¶
func NewGlobalMetadataBroker( timeout time.Duration, logger log.Modular, stats metrics.Aggregator, ) *GlobalMetadataBroker
NewGlobalMetadataBroker - Create a new instance of an event broker.
func (*GlobalMetadataBroker) NewEmitter ¶
func (b *GlobalMetadataBroker) NewEmitter(username, uuid string, e Emitter)
NewEmitter - Register a new emitter to the broker, the emitter will begin receiving globally broadcast events from other emitters.
type RequestHandler ¶
type RequestHandler func(body []byte) events.TypedError
RequestHandler - Called when a request has been received, receives the body of the request and returns a TypedError indicating whether the handler was successful. Errors are sent back to the client.
type ResponseHandler ¶
type ResponseHandler func(body interface{}) bool
ResponseHandler - Called when an outgoing response is about to be sent, receives the body of the response and returns a bool indicating whether the response should be sent (false == do not send).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package events - Contains string constants and structs for API event and error types.
|
Package events - Contains string constants and structs for API event and error types. |
|
Package io - Contains network api.Emitter implementations for io types.
|
Package io - Contains network api.Emitter implementations for io types. |