channel

package
v0.0.0-...-f12bd69 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdPort = 65501
	EvtPort = 65502
)

Channel ports

Variables

View Source
var (
	ErrNoData           = errors.New("no data")
	ErrFrameTIDMismatch = errors.New("frame TID mismatch")
	ErrFrameUnexpected  = errors.New("unexpected frame type")
	ErrRemoteError      = errors.New("remote error")
	ErrWaitTimeout      = errors.New("wait timeout")
	ErrFrameMalformed   = errors.New("malformed frame")
)

Functions

func GenerateTID

func GenerateTID() string

Types

type Client

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

func NewClient

func NewClient(addr string, connectWait, connectTimeout, readTimeout, writeTimeout int) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Read

func (c *Client) Read(retries uint) (*Frame, error)

func (*Client) Write

func (c *Client) Write(frame *Frame, retries uint) (n int, err error)

type CommandClient

type CommandClient struct {
	*Client
}

func NewCommandClient

func NewCommandClient(addr string, connectWait, connectTimeout, readTimeout, writeTimeout int) (*CommandClient, error)

func (*CommandClient) Call

func (c *CommandClient) Call(data []byte, retries uint) ([]byte, error)

type CommandServer

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

func NewCommandServer

func NewCommandServer(addr string, handler RequestHandler) *CommandServer

func (*CommandServer) OnConnection

func (s *CommandServer) OnConnection(conn net.Conn)

func (*CommandServer) SetReqHandler

func (s *CommandServer) SetReqHandler(handler RequestHandler)

func (*CommandServer) WaitForConnection

func (s *CommandServer) WaitForConnection()

type ConnectionHandler

type ConnectionHandler interface {
	OnConnection(conn net.Conn)
}

type EventClient

type EventClient struct {
	*Client
}

func NewEventClient

func NewEventClient(addr string, connectWait, connectTimeout, readTimeout int) (*EventClient, error)

func (*EventClient) Next

func (c *EventClient) Next(retries uint) ([]byte, string, error)

type EventServer

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

func NewEventServer

func NewEventServer(addr string) *EventServer

func (*EventServer) OnConnection

func (s *EventServer) OnConnection(conn net.Conn)

func (*EventServer) Publish

func (s *EventServer) Publish(data []byte, retries uint) error

func (*EventServer) WaitForConnection

func (s *EventServer) WaitForConnection()

type Frame

type Frame struct {
	TID  string          `json:"tid"`
	Type FrameType       `json:"type"`
	Body json.RawMessage `json:"body,omitempty"`
}

type FrameType

type FrameType string

FrameType is a Frame struct type

const (
	RequestFrameType  FrameType = "ft.request"
	ResponseFrameType FrameType = "ft.response"
	EventFrameType    FrameType = "ft.event"
	ErrorFrameType    FrameType = "ft.error"
	ControlFrameType  FrameType = "ft.control"
)

Supported frame types

type RequestHandler

type RequestHandler interface {
	OnRequest(data []byte) ([]byte, error)
}

type Server

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

func NewServer

func NewServer(addr string) *Server

func (*Server) SetConnHandler

func (s *Server) SetConnHandler(handler ConnectionHandler)

func (*Server) Start

func (s *Server) Start(async bool) error

func (*Server) Stop

func (s *Server) Stop()

Jump to

Keyboard shortcuts

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