Documentation
¶
Index ¶
- Constants
- type Balancer
- type Client
- func (s *Client) Close() error
- func (s *Client) Connect() error
- func (s *Client) OnConnect(fn func(*Client))
- func (s *Client) OnDisconnect(fn func(*Client))
- func (s *Client) OnError(fn func(*Client, error))
- func (s *Client) OnInbound(fn func(*Client, *Message))
- func (s *Client) OnOutbound(fn func(*Client, []byte))
- func (s *Client) Request(method string, args ...any) *Response
- func (s *Client) Send(msg *Message) error
- func (s *Client) Start() error
- func (s *Client) ToJson() et.Json
- type Config
- type Console
- type HandlerFunc
- type HeartbeatArgs
- type HeartbeatReply
- type Message
- type Mode
- type Msg
- type Node
- func (s *Node) AddNode(addr string)
- func (s *Node) Broadcast(destination []string, tp int, message any)
- func (s *Node) Close()
- func (s *Node) Error(c *Client, err error) error
- func (s *Node) GetMethod() et.Json
- func (s *Node) GetPeers() []*Client
- func (s *Node) Mount(service Service) error
- func (s *Node) Next() *Client
- func (s *Node) OnBecomeLeader(fn func(*Node))
- func (s *Node) OnChangeLeader(fn func(*Node))
- func (s *Node) OnConnect(fn func(*Client))
- func (s *Node) OnDisconnect(fn func(*Client))
- func (s *Node) OnError(fn func(*Client, error))
- func (s *Node) OnInbox(fn func(*Msg))
- func (s *Node) OnSend(fn func(*Msg))
- func (s *Node) RemoveNode(addr string)
- func (s *Node) Request(to *Client, method string, args ...any) *Response
- func (s *Node) ResponseError(msg *Msg, err error) error
- func (s *Node) Send(to *Client, tp int, message any) error
- func (s *Node) SendError(to *Client, err error) error
- func (s *Node) Start() (err error)
- type Raft
- type RequestVoteArgs
- type RequestVoteReply
- type Response
- type ResponseBool
- type Service
- type Status
- type Tcp
Constants ¶
const ( BytesMessage int = 0 TextMessage int = 1 ACKMessage int = 13 CloseMessage int = 15 ErrorMessage int = 17 Heartbeat int = 19 RequestVote int = 21 Method int = 23 )
const (
PingMehtod string = "Tcp.Ping"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v1.0.15
type Client struct {
CreatedAt time.Time `json:"created_at"`
ID string `json:"id"`
Addr string `json:"addr"`
LocalAddr string `json:"local_addr"`
RemoteAddr string `json:"remote_addr"`
Status Status `json:"status"`
Ctx et.Json `json:"-"`
// contains filtered or unexported fields
}
func (*Client) OnDisconnect ¶ added in v1.0.15
* * OnDisconnect * @param fn func(*Client) *
func (*Client) OnOutbound ¶ added in v1.0.15
* * OnOutbound * @param fn func(*Client, []byte) *
func (*Client) Request ¶ added in v1.0.15
* * Request * @param method string, args ...any * @return *Response *
type Config ¶ added in v1.0.15
type Config struct {
Nodes []string `json:"nodes"`
// contains filtered or unexported fields
}
type HandlerFunc ¶ added in v1.0.15
type HeartbeatArgs ¶ added in v1.0.15
type HeartbeatReply ¶ added in v1.0.15
type Message ¶ added in v1.0.15
type Message struct {
ID string `json:"id"`
Type int `json:"type"`
Method string `json:"method"`
Payload []byte `json:"payload"`
Error string `json:"error"`
Args []any `json:"args"`
IsResponse bool `json:"is_response"`
}
func NewMessage ¶ added in v1.0.15
* * NewMessage *
func (*Message) GetArgs ¶ added in v1.0.15
* * AnyGet: Gets a value from an array * @param args []any, dest ...any * @return error *
type Msg ¶ added in v1.0.15
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) Broadcast ¶ added in v1.0.15
* * Broadcast * @param destination []string * @param msg []byte *
func (*Node) OnBecomeLeader ¶ added in v1.0.15
* * OnBecomeLeader * @param fn func(*Node) *
func (*Node) OnChangeLeader ¶ added in v1.0.15
* * OnChangeLeader * @param fn func(*Node) *
func (*Node) OnDisconnect ¶ added in v1.0.15
* * OnDisconnect * @param fn func(*Client) *
func (*Node) RemoveNode ¶ added in v1.0.15
* * RemoveNode * @param addr string *
func (*Node) Request ¶ added in v1.0.15
* * Request * @param to *Client, method string, args ...any * @return *Response *
func (*Node) ResponseError ¶ added in v1.0.15
* * ResponseError * @param to *Client, id string, err error * @return error *
func (*Node) Send ¶ added in v1.0.15
* * Send * @param to *Client, tp int, message any * @return error *
type RequestVoteArgs ¶ added in v1.0.15
type RequestVoteReply ¶ added in v1.0.15
type Response ¶ added in v1.0.15
func TcpResponse ¶ added in v1.0.15
* * TcpResponse * @param res ...any * @return *Response *
type ResponseBool ¶ added in v1.0.15
type Tcp ¶ added in v1.0.15
type Tcp struct {
Ping HandlerFunc
// contains filtered or unexported fields
}