Documentation ¶
Index ¶
- func LaunchWebsocketTextModel(h *HTTPTextModel, socket *websocket.Conn, binder *lib.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 *lib.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"` }
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"` DocID string `json:"document_id,omitempty"` UserID string `json:"user_id,omitempty"` Document *lib.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) (*lib.BinderPortal, error) // NewDocument - Create and return a binder portal to a new document NewDocument(string, string, *lib.Document) (*lib.BinderPortal, error) // GetLogger - Obtain a reference to the LeapsLogger held by our curator GetLogger() *lib.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 *lib.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 *lib.OTransform `json:"transform,omitempty"` Position *int64 `json:"position,omitempty"` Message string `json:"message,omitempty"` }
LeapTextClientMessage - A structure that defines a message format to expect from clients connected to a text model. Commands can currently be 'submit' (submit a transform to a bound document), or 'update' (submit an update to the users cursor position).
type LeapTextServerMessage ¶
type LeapTextServerMessage struct { Type string `json:"response_type"` Transforms []lib.OTransform `json:"transforms,omitempty"` Updates []lib.UserUpdate `json:"user_updates,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), 'update' (an update to a users status) 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 *lib.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.