events

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2018 License: MIT Imports: 1 Imported by: 4

Documentation

Overview

Package events - Contains string constants and structs for API event and error types.

Index

Constants

View Source
const (
	// Subscribe event type
	// Client: Send intent to subscribe to a document
	// Server: Send confirmation that document is now subscribed
	Subscribe = "subscribe"

	// Unsubscribe event type
	// Client: Send intent to unsubscribe from a document
	// Server: Send confirmation that document is now unsubscribed
	Unsubscribe = "unsubscribe"

	// Transforms event type
	// Server: Send intent to transform local copy of document with multiple
	// transforms
	Transforms = "transforms"

	// Transform event type
	// Client: Send intent to transform server copy of document
	// Server: Send intent to transform local copy of document
	Transform = "transform"

	// Correction event type
	// Server: Send correction of prior received transform from client
	Correction = "correction"

	// Metadata event type
	// Client: Send metadata to other users of document
	// Server: Send metadata from other user of document
	Metadata = "metadata"

	// GlobalMetadata event type
	// Client: Send metadata to other users of leaps service
	// Server: Send metadata from other user of leaps service
	GlobalMetadata = "global_metadata"

	// Error event type
	// Server: Send information regarding an API error
	Error = "error"

	// Ping event type
	// Client: Send intent to annoy the server
	Ping = "ping"

	// Pong event type
	// Server: Send confirm of annoyance
	Pong = "pong"
)

All outbound/inbound event types

View Source
const (
	// UserInfo metadata subtype
	// Server: Send a newly connected client a list of existing clients and
	// their subscriptions, as well the users own username and session id
	UserInfo = "user_info"

	// UserConnected metadata type
	// Server: Send on client connect to leaps service to all other clients
	UserConnect = "user_connect"

	// UserDisconnected metadata type
	// Server: Send on client disconnect to leaps service to all other clients
	UserDisconnect = "user_disconnect"

	// UserSubscribe metadata type
	// Server: Send on client subscribe to document to all other clients
	UserSubscribe = "user_subscribe"

	// UserUnsubscribe metadata type
	// Server: Send on client unsubscribe to document to all other clients
	UserUnsubscribe = "user_unsubscribe"

	// CMDList metadata type
	// Server: Send a newly connected client a list of available static commands
	// that can be run through leaps
	CMDList = "cmd_list"

	// CMD metadata type
	// Client: Submit a command to be run by the leaps service
	CMD = "cmd"

	// CMDOutput metadata type
	// Server: Send the result of a command to all clients connected to the
	// leaps service
	CMDOutput = "cmd_output"
)

All explicitly defined outbound/inbound metadata subtypes.

Variables

View Source
var (
	ErrNoSub       = "ERR_NO_SUB"
	ErrSubscribe   = "ERR_SUB"
	ErrExistingSub = "ERR_EXISTING_SUB"
	ErrBadJSON     = "ERR_BAD_JSON"
	ErrTransform   = "ERR_TRANSFORM"
	ErrMetadata    = "ERR_METADATA"
	ErrBadReq      = "ERR_BAD_REQ"
)

Error type strings

Functions

This section is empty.

Types

type APIError

type APIError struct {
	T   string `json:"type"`
	Err string `json:"message"`
}

APIError - Implementation of TypedError for the API.

func (APIError) Error

func (a APIError) Error() string

Error - returns the full error string.

func (APIError) Type

func (a APIError) Type() string

Type - returns the string type.

type CMDData added in v0.8.1

type CMDData struct {
	ID     int    `json:"id"`
	Error  string `json:"error"`
	Stdout string `json:"stdout"`
	Stderr string `json:"stderr"`
}

CMDData contains the id and the results from a command (if applicable).

type CMDListMetadataMessage added in v0.8.1

type CMDListMetadataMessage struct {
	CMDS []string `json:"cmds"`
}

CMDListMetadataMessage is a metadata body which carries a list of statically defined commands available to clients.

type CMDMetadataMessage added in v0.8.1

type CMDMetadataMessage struct {
	CMDData CMDData `json:"cmd"`
}

CMDMetadataMessage is a metadata body which carries the id and output from a command to all clients connected to the leaps service.

type Client

type Client struct {
	Username  string `json:"username"`
	SessionID string `json:"session_id"`
}

Client contains data about a client session.

type CorrectionMessage

type CorrectionMessage struct {
	Document   DocumentStripped `json:"document"`
	Correction TformCorrection  `json:"correction"`
}

CorrectionMessage is an API body encompassing a correction to a submitted transform.

type DocumentFull

type DocumentFull struct {
	ID      string `json:"id"`
	Content string `json:"content"`
	Version int    `json:"version"`
}

DocumentFull contains all data related to a document, including the current version of the content.

type DocumentStripped

type DocumentStripped struct {
	ID string `json:"id"`
}

DocumentStripped contains fields for identifying docs but not carrying its contents.

type ErrorMessage

type ErrorMessage struct {
	Error APIError `json:"error"`
}

ErrorMessage is an API body encompassing an API error.

type GlobalMetadataMessage

type GlobalMetadataMessage struct {
	Client   interface{} `json:"client"`
	Metadata interface{} `json:"metadata"`
}

GlobalMetadataMessage is an API body encompassing a global metadata message, and fields identifying the client source.

type MetadataBody

type MetadataBody struct {
	Type string      `json:"type"`
	Body interface{} `json:"body"`
}

MetadataBody is a message body for typed metadata.

type MetadataMessage

type MetadataMessage struct {
	Document DocumentStripped `json:"document"`
	Client   interface{}      `json:"client"`
	Metadata interface{}      `json:"metadata"`
}

MetadataMessage is an API body encompassing a metadata message, fields identifying the document target, and fields identifying the client source.

type SubscriptionMessage

type SubscriptionMessage struct {
	Document DocumentFull `json:"document"`
}

SubscriptionMessage is an API body encompassing fields identifying a document that has been subscribed as well as its full contents.

type TformCorrection

type TformCorrection struct {
	Version int `json:"version"`
}

TformCorrection contains fields used to correct a transform.

type TransformMessage

type TransformMessage struct {
	Document  DocumentStripped `json:"document"`
	Transform text.OTransform  `json:"transform"`
}

TransformMessage is an API body encompassing a transform and fields identifying the document target.

type TransformsMessage

type TransformsMessage struct {
	Document   DocumentStripped  `json:"document"`
	Transforms []text.OTransform `json:"transforms"`
}

TransformsMessage is an API body encompassing a slice of transforms and fields identifying the document target.

type TypedError

type TypedError interface {
	Type() string
	Error() string
}

TypedError - An error with a type string so that API clients can easily categorise the fault.

func NewAPIError

func NewAPIError(errType, errString string) TypedError

NewAPIError - Creates a type labelled API error.

type UnsubscriptionMessage

type UnsubscriptionMessage struct {
	Document DocumentStripped `json:"document"`
}

UnsubscriptionMessage is an API body encompassing fields identifying a document that has been unsubscribed.

type UserInfoMetadataMessage

type UserInfoMetadataMessage struct {
	// Users is a map of session_id to user map objects
	Users map[string]UserSubscriptions `json:"users"`
}

UserInfoMetadataMessage is a metadata body encompassing a map of connected session_id's and their document subscriptions.

type UserSubscriptions

type UserSubscriptions struct {
	Username      string   `json:"username"`
	Subscriptions []string `json:"subscriptions"`
}

UserSubscriptions contains user identifying information and a list of their active subscriptions (document IDs).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL