shared

package
v0.0.0-...-076f285 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2017 License: Apache-2.0 Imports: 8 Imported by: 38

Documentation

Index

Constants

View Source
const (
	ErrorCodeParseError     = ResponseErrorCodes(-32700)
	ErrorCodeInvalidRequest = ResponseErrorCodes(-32600)
	ErrorCodeMethodNotFound = ResponseErrorCodes(-32601)
	ErrorCodeInvalidParams  = ResponseErrorCodes(-32602)
	ErrorCodeInternalError  = ResponseErrorCodes(-32603)
	ErrorCodeServerError    = ResponseErrorCodes(-32000)
)
View Source
const (
	StatusCodeSuccess     = ResponseStatusCodes(0)
	StatusCodeError       = ResponseStatusCodes(1)
	StatusCodeFallThrough = ResponseStatusCodes(2)
	StatusCodeAsync       = ResponseStatusCodes(3)
)

Variables

This section is empty.

Functions

func Handler

func Handler(fn func(*Connection)) http.Handler

func ThrowError

func ThrowError(msg string)

func ThrowWarning

func ThrowWarning(msg string)

func TryRecoverFromPanic

func TryRecoverFromPanic(conn *Connection)

func WrapFunctionForPanicRecover

func WrapFunctionForPanicRecover(fn func(), conn *Connection) func()

Types

type Agenter

type Agenter interface {
	Name() string
	ProcessCommand(int64, string, string, *json.RawMessage)
}

type Commander

type Commander interface {
	Initalize(targetId string, responseId int64, conn *Connection)
}

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) Closed

func (c *Connection) Closed() bool

func (*Connection) RegisterAgent

func (c *Connection) RegisterAgent(agent Agenter)

func (*Connection) Send

func (c *Connection) Send(event Notification)

func (*Connection) SendErrorResult

func (c *Connection) SendErrorResult(id int64, targetId string, errorCode ResponseErrorCodes, message string)

func (*Connection) SendResult

func (c *Connection) SendResult(id int64, targetId string, result interface{})

func (*Connection) SendToTarget

func (c *Connection) SendToTarget(targetId string, event interface{})

func (*Connection) SetupCommand

func (c *Connection) SetupCommand(id int64, targetId string, data *json.RawMessage, out Commander)

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (Error) Error

func (e Error) Error() string

type Notification

type Notification struct {
	Method string      `json:"method"`
	Params interface{} `json:"params,omitempty"`
}

type ReceivedCommand

type ReceivedCommand struct {
	Id     int64            `json:"id"`
	Method string           `json:"method"`
	Params *json.RawMessage `json:"params,omitempty"`
}

type Response

type Response struct {
	Id     int64               `json:"id"`
	Result interface{}         `json:"result"`
	Status ResponseStatusCodes `json:"status,omitempty"`
	Error  *ResponseError      `json:"error,omitempty"`
}

type ResponseError

type ResponseError struct {
	Code    ResponseErrorCodes `json:"code"`
	Message string             `json:"message"`
}

type ResponseErrorCodes

type ResponseErrorCodes int64

type ResponseStatusCodes

type ResponseStatusCodes int64

type Warning

type Warning struct {
	// contains filtered or unexported fields
}

func (Warning) Error

func (w Warning) Error() string

Jump to

Keyboard shortcuts

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