topo

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CmdSet = 3
View Source
const Name = "Topo"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addrs    []string
	Interval int64 // second
	Topic    string
}

type Event

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

type Peer

type Peer struct {
	*p2p.Peer
	// contains filtered or unexported fields
}

type Topo

type Topo struct {
	Pivot string              `json:"pivot,omitempty"`
	Peers []*p2p.ConnProperty `json:"peers,omitempty"`
	Time  UnixTime            `json:"time,omitempty"`
}

func (*Topo) Deserialize

func (t *Topo) Deserialize(buf []byte) error

func (*Topo) Json

func (t *Topo) Json() []byte

report to kafka

func (*Topo) Serialize

func (t *Topo) Serialize() ([]byte, error)

add Hash(32bit) to Front, use for determine if it has been received

type Topology

type Topology struct {
	*Config
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) *Topology

func (*Topology) Handle

func (t *Topology) Handle(p *p2p.Peer, rw *p2p.ProtoFrame) error

func (*Topology) Protocol

func (t *Topology) Protocol() *p2p.Protocol

func (*Topology) Receive

func (t *Topology) Receive(msg *p2p.Msg, sender *Peer)

func (*Topology) Start

func (t *Topology) Start(p2p p2p.Server) error

func (*Topology) Stop

func (t *Topology) Stop()

func (*Topology) Topology

func (t *Topology) Topology() *Topo

the first item is self url

type UnixTime

type UnixTime time.Time

@section topo

func (UnixTime) MarshalJSON

func (t UnixTime) MarshalJSON() ([]byte, error)

func (UnixTime) Unix

func (t UnixTime) Unix() int64

func (*UnixTime) UnmarshalJSON

func (t *UnixTime) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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