network

package
v0.0.0-...-75fa6d2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2019 License: GPL-3.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

View Source
const BufferSize = 1024 * 1024 * 2
View Source
const MaxMessageSize = 1024 * 1024 * 2

2 MB

View Source
const WriteWait = 30 * time.Second

Variables

This section is empty.

Functions

func RegisterStorage

func RegisterStorage(s Storage)

Types

type Peer

type Peer struct {
	Addr     string
	Rank     int
	Last     time.Time
	Recv     chan []byte
	Send     chan []byte
	IsServer bool
	// contains filtered or unexported fields
}

func NewPeer

func NewPeer(addr string, rank int) *Peer

func (*Peer) Save

func (c *Peer) Save()

type Server

type Server struct {
	Peers map[string]*Peer
	In    chan *Peer
	Out   chan *Peer
}

func NewServer

func NewServer() *Server

func (*Server) Connect

func (s *Server) Connect(peer *Peer) error

func (*Server) Serve

func (s *Server) Serve()

type Storage

type Storage interface {
	CountOfPeers() int
	GetPeer(addr string) *Peer
	GetPeers(count int) []*Peer
	SavePeer(peer *Peer)
	DeletePeer(peer *Peer)
}

func SharedStorage

func SharedStorage() Storage

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳