codec

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// heartbeat between controller and edge
	CmdHeartbeat

	// edge register to controller
	CmdRegister

	// controller tell edge that new edge join
	CmdAdd

	// controller tell edge that edge leave
	CmdDel

	// edge report subhost of it to controller
	CmdReport

	// alarm report
	CmdAlarm

	// add route
	CmdAddRoute

	// del route
	CmdDelRoute
)

Variables

This section is empty.

Functions

func ReadJSON

func ReadJSON(conn net.Conn, obj interface{}) error

ReadJSON wraps Read with json decoder

func Write

func Write(conn net.Conn, cmd int, body []byte) error

Write to net connection cmd: header.cmd body: payload

func WriteJSON

func WriteJSON(conn net.Conn, cmd int, obj interface{}) error

WriteJSON wraps Write with json encoder

Types

type AddRouteMsg added in v1.2.1

type AddRouteMsg struct {
	// dst cidr
	Cidr string
	// next hop edge listen address
	// ip:port
	Nexthop string
}

controller deploy route added to edges

type BroadcastOfflineMsg

type BroadcastOfflineMsg struct {
	// offlined edge host address
	ListenAddr string

	// offlined edge network subnet
	Cidr string
}

broadcase edge offline once edge keepalive faile controller will broadcase edge offline msg to all online edges

type BroadcastOnlineMsg

type BroadcastOnlineMsg struct {
	// onlined edge listen address(udp://ip:port)
	ListenAddr string

	// offline edge network subnet(192.168.10.0/24)
	Cidr string
}

broadcast edge online once edge register success controller will broadcast edge online msg to all online edges.

type CSPInfo added in v1.2.1

type CSPInfo struct {
	CspType      proto.CSPType
	AccessKey    string
	AccessSecret string
}

type DelRouteMsg added in v1.2.1

type DelRouteMsg AddRouteMsg

controller deploy route deleted to edges

type Edge added in v1.2.1

type Edge struct {
	ListenAddr string
	Cidr       string
}

edge information

type Header [4]byte

version: 1byte cmd: 1byte body len: 2bytes

func Read

func Read(conn net.Conn) (Header, []byte, error)

Read from net connection return header, body and error

func (Header) Bodylen

func (h Header) Bodylen() int

func (Header) Cmd

func (h Header) Cmd() int

func (Header) Version

func (h Header) Version() int

type Heartbeat

type Heartbeat struct{}

type RegisterReply

type RegisterReply struct {
	EdgeList []*Edge
	CSPInfo  *CSPInfo
	Routes   []*proto.Route
}

reply for edge register req

func (*RegisterReply) String

func (r *RegisterReply) String() string

type RegisterReq

type RegisterReq struct {
	// edge name
	Name      string
	SecretKey string
	PublicIP  string
}

edge register req

type ReportMsg added in v1.2.1

type ReportMsg struct {
	Timestamp  int64
	CPU        int32
	Mem        int32
	TrafficIn  int64
	TrafficOut int64
}

edge report host edge report host information to controller controller get topology

host1                    host1'
     \                  /
      edge1 ---- edge2
     /                  \
host2                    host2'

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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