Documentation
¶
Index ¶
- func LaunchWebsocketTextModel(h *HTTPTextModel, socket *websocket.Conn, binder *leaplib.BinderPortal)
- type HTTPBinderConfig
- type HTTPServer
- type HTTPServerConfig
- type HTTPTextModel
- type LeapClientMessage
- type LeapLocator
- type LeapServerMessage
- type LeapTextClientMessage
- type LeapTextServerMessage
- type StatsServer
- type StatsServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LaunchWebsocketTextModel ¶
func LaunchWebsocketTextModel(h *HTTPTextModel, socket *websocket.Conn, binder *leaplib.BinderPortal)
LaunchWebsocketTextModel - Launches a text model that wraps a connected websocket around a BinderPortal representing a text document.
Types ¶
type HTTPBinderConfig ¶
type HTTPBinderConfig struct {
BindSendTimeout int `json:"bind_send_timeout_ms"`
}
HTTPBinderConfig - Options for individual binders (one for each socket connection)
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer - A construct designed to take a LeapLocator (a structure for finding and binding to leap documents) and bind it to http clients.
func CreateHTTPServer ¶
func CreateHTTPServer(locator LeapLocator, config HTTPServerConfig, mux *http.ServeMux) (*HTTPServer, error)
CreateHTTPServer - Create a new leaps HTTPServer, optionally registers to a custom http.ServeMux, or set this to nil to use the default http mux (recommended).
func (*HTTPServer) Listen ¶
func (h *HTTPServer) Listen() error
Listen - Bind to the http endpoint as per configured address, and begin serving requests. This is simply a helper function that calls http.ListenAndServe
func (*HTTPServer) Stop ¶
func (h *HTTPServer) Stop()
Stop - Stop serving web requests and close the HTTPServer.
type HTTPServerConfig ¶
type HTTPServerConfig struct {
StaticPath string `json:"static_path"`
Path string `json:"socket_path"`
Address string `json:"address"`
StaticFilePath string `json:"www_dir"`
Binder HTTPBinderConfig `json:"binder"`
BindSendTimeout int `json:"bind_send_timeout_ms"`
}
HTTPServerConfig - Holds configuration options for the HTTPServer.
func DefaultHTTPServerConfig ¶
func DefaultHTTPServerConfig() HTTPServerConfig
DefaultHTTPServerConfig - Returns a fully defined HTTPServer configuration with the default values for each field.
type HTTPTextModel ¶
type HTTPTextModel struct {
// contains filtered or unexported fields
}
HTTPTextModel - an HTTP model that connects a binder of a text document to a client.
type LeapClientMessage ¶
type LeapClientMessage struct {
Command string `json:"command"`
Token string `json:"token"`
ID string `json:"document_id,omitempty"`
Document *leaplib.Document `json:"leap_document,omitempty"`
}
LeapClientMessage - A structure that defines a message format to expect from clients. Commands can be 'create' (init with new document) or 'find' (init with existing document).
type LeapLocator ¶
type LeapLocator interface {
// FindDocument - Find and return a binder portal to an existing document
FindDocument(string, string) (*leaplib.BinderPortal, error)
// NewDocument - Create and return a binder portal to a new document
NewDocument(string, *leaplib.Document) (*leaplib.BinderPortal, error)
// GetLogger - Obtain a reference to the LeapsLogger held by our curator
GetLogger() *leaplib.LeapsLogger
// Close - Close the LeapLocator
Close()
}
LeapLocator - An interface capable of locating and creating leaps documents. This can either be a curator, which deals with documents on the local service, or a TBD, which load balances between servers of curators.
type LeapServerMessage ¶
type LeapServerMessage struct {
Type string `json:"response_type"`
Document *leaplib.Document `json:"leap_document,omitempty"`
Version *int `json:"version,omitempty"`
Error string `json:"error,omitempty"`
}
LeapServerMessage - A structure that defines a response message from the server to a client. Type can be 'document' (init response) or 'error' (an error message to display to the client).
type LeapTextClientMessage ¶
type LeapTextClientMessage struct {
Command string `json:"command"`
Transform leaplib.OTransform `json:"transform,omitempty"`
}
LeapTextClientMessage - A structure that defines a message format to expect from clients connected to a text model. Commands can currently only be 'submit' (submit a transform to a bound document).
type LeapTextServerMessage ¶
type LeapTextServerMessage struct {
Type string `json:"response_type"`
Transforms []leaplib.OTransform `json:"transforms,omitempty"`
Version *int `json:"version,omitempty"`
Error string `json:"error,omitempty"`
}
LeapTextServerMessage - A structure that defines a response message from a text model to a client. Type can be 'transforms' (continuous delivery), 'correction' (actual version of a submitted transform), or 'error' (an error message to display to the client).
type StatsServer ¶
type StatsServer struct {
// contains filtered or unexported fields
}
StatsServer - A server constructed to present an HTTP endpoint for obtaining live statics regarding the leaps server. Requires a reference to the logger shared with the Curator object at the center of the service.
func CreateStatsServer ¶
func CreateStatsServer(logger *leaplib.LeapsLogger, config StatsServerConfig) (*StatsServer, error)
CreateStatsServer - Create a new leaps StatsServer.
func (*StatsServer) Listen ¶
func (s *StatsServer) Listen() error
Listen - Bind to the configured http endpoint and begin serving requests.
func (*StatsServer) ServeHTTP ¶
func (s *StatsServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
StatsHandler - The StatsServer request handler.
type StatsServerConfig ¶
type StatsServerConfig struct {
StaticPath string `json:"static_path"`
Path string `json:"stats_path"`
Address string `json:"address"`
StaticFilePath string `json:"www_dir"`
StatsTimeout int `json:"stat_timeout_ms"`
RequestTimeout int `json:"request_timeout_s"`
}
StatsServerConfig - Holds configuration options for the StatsServer
func DefaultStatsServerConfig ¶
func DefaultStatsServerConfig() StatsServerConfig
DefaultStatsServerConfig - Returns a fully defined StatsServer configuration with the default values for each field.