cube

package module
v0.0.0-...-46ea109 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: MIT Imports: 3 Imported by: 4

README

cube

Cube handler interface

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorTimeout = errors.New("cube: request timeout")
)

Functions

This section is empty.

Types

type Channel

type Channel string

type Cube

type Cube interface {
	GetParam(param string) string
	GetClass() string
	GetInstanceId() string

	PublishMessage(channel Channel, message Message) error
	CallMethod(channel Channel, request Request, timeout time.Duration) (*Response, error)

	Stop()

	LogDebug(text string) error
	LogError(text string) error
	LogFatal(text string) error
	LogInfo(text string) error
	LogWarning(text string) error
	LogTrace(text string) error
}

type Error

type Error struct {
	Name    string `json:"name"`
	Message string `json:"description"`
}

type HandlerInterface

type HandlerInterface interface {
	OnInitInstance() []InputChannel
	OnStart(instance Cube) error
	OnStop(instance Cube)
	OnReceiveMessage(instance Cube, channel Channel, message Message)
	OnReceiveRequest(instance Cube, channel Channel, request Request) Response
}

type InputChannel

type InputChannel Channel

type Message

type Message struct {
	Id     string           `json:"id"`
	Method string           `json:"method"`
	Params *json.RawMessage `json:"params"`
}

type Request

type Request struct {
	Method string           `json:"method"`
	Params *json.RawMessage `json:"params"`
}

type Response

type Response struct {
	Id     string           `json:"id"`
	Result *json.RawMessage `json:"result"`
	Error  *Error           `json:"error"`
}

func NewErrorResponse

func NewErrorResponse(requestId string, name string, message string) Response

func NewResultResponse

func NewResultResponse(requestId string, result *json.RawMessage) Response

Jump to

Keyboard shortcuts

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