socket

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOk          = 0
	StatusErr         = 13
	StatusInternalErr = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Name    string
	Handler ActionFunc
}

type ActionFunc

type ActionFunc func(request Request) Response

type Client

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

func NewClient

func NewClient(socketName string) *Client

func (Client) Send

func (client Client) Send(request Request) (*Response, error)

type Request

type Request struct {
	Action string          `json:"ActionFunc"`
	Args   json.RawMessage `json:"args"`
}

type Response

type Response struct {
	Status int             `json:"status"`
	Error  string          `json:"error,omitempty"`
	Data   json.RawMessage `json:"data"`
}

func NewResponse added in v2.1.2

func NewResponse(status int, data interface{}, errorStr string) Response

type Server

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

func NewServer

func NewServer(socketName string, actions ...Action) *Server

func (*Server) Errors

func (sw *Server) Errors() <-chan error

func (*Server) Serve

func (sw *Server) Serve(ctx context.Context) (err error)

func (*Server) SetHandler

func (sw *Server) SetHandler(name string, action ActionFunc)

Jump to

Keyboard shortcuts

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