leaps: github.com/Jeffail/leaps/lib/api/events Index | Files

package events

import "github.com/Jeffail/leaps/lib/api/events"

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

Index

Package Files

error.go events.go metadata.go package.go

Constants

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

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

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

type APIError Uses

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

APIError - Implementation of TypedError for the API.

func (APIError) Error Uses

func (a APIError) Error() string

Error - returns the full error string.

func (APIError) Type Uses

func (a APIError) Type() string

Type - returns the string type.

type CMDData Uses

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 Uses

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 Uses

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 Uses

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

Client contains data about a client session.

type CorrectionMessage Uses

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 Uses

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 Uses

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

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

type ErrorMessage Uses

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

ErrorMessage is an API body encompassing an API error.

type GlobalMetadataMessage Uses

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 Uses

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

MetadataBody is a message body for typed metadata.

type MetadataMessage Uses

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 Uses

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 Uses

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

TformCorrection contains fields used to correct a transform.

type TransformMessage Uses

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 Uses

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 Uses

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 Uses

func NewAPIError(errType, errString string) TypedError

NewAPIError - Creates a type labelled API error.

type UnsubscriptionMessage Uses

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

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

type UserInfoMetadataMessage Uses

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 Uses

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).

Package events imports 1 packages (graph) and is imported by 2 packages. Updated 2018-02-20. Refresh now. Tools for package owners.