tcp

package
v0.0.0-...-46d7ffa Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBody

func DecodeBody(content string, writeTo interface{}) error

func EncodeBody

func EncodeBody(data interface{}) (string, error)

Types

type Frame

type Frame struct {
	FromNodeId  string //id = ip:port
	MessageType MessageType
	Action      actions.Action
	Error       bool
	Body        string
}

type MessageFromCluster

type MessageFromCluster struct {
	Frame          Frame
	ReplyToChannel chan Frame
}

type MessageType

type MessageType rune
const (
	Request  MessageType = 'Q'
	Response MessageType = 'A'
)

type TcpClientsManager

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

func InitTcpClientsManager

func InitTcpClientsManager(nodeId string) *TcpClientsManager

func (*TcpClientsManager) SendMessage

func (c *TcpClientsManager) SendMessage(toNodeId string, messageType MessageType, action actions.Action, body interface{}) (*Frame, error)

type TcpServer

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

func InitServer

func InitServer(nodeIp string, nodePort string) *TcpServer

func (*TcpServer) Run

func (s *TcpServer) Run() chan MessageFromCluster

func (*TcpServer) Shutdown

func (s *TcpServer) Shutdown()

Jump to

Keyboard shortcuts

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