dispatcher

package
v0.0.0-...-8e9553d Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caller

type Caller interface {
	Call(bgcaction.Action, []interface{}) (interface{}, error)
}

type Dispatcher

type Dispatcher interface {
	// Dispatch interprets request bytes, executes request, captures response and return response bytes.
	// It panics if built-in errors fail to serialize.
	Dispatch([]byte) []byte
}

type JSON

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

func NewJSON

func NewJSON(
	actionFactory bgcaction.Factory,
	caller Caller,
	logger bgcapi.MultiLogger,
) JSON

func (JSON) Dispatch

func (c JSON) Dispatch(reqBytes []byte) []byte

type JSONCaller

type JSONCaller struct{}

JSONCaller unmarshals call arguments with json package and calls action.Run

func NewJSONCaller

func NewJSONCaller() JSONCaller

func (JSONCaller) Call

func (r JSONCaller) Call(action bgcaction.Action, args []interface{}) (value interface{}, err error)

type Request

type Request struct {
	Method    string        `json:"method"`
	Arguments []interface{} `json:"arguments"`
}

type Response

type Response struct {
	Result interface{}    `json:"result"`
	Error  *ResponseError `json:"error"`

	Log string `json:"log"`
}

type ResponseError

type ResponseError struct {
	Type    string `json:"type"`
	Message string `json:"message"`

	CanRetry bool `json:"ok_to_retry"`
}

func (ResponseError) Error

func (r ResponseError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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