update the network interface

This commit is contained in:
Asim Aslam 2019-06-22 16:51:20 +01:00
parent 1b4005e9a5
commit 2d91ba411e

View File

@ -5,13 +5,17 @@ import (
"github.com/micro/go-micro/config/options" "github.com/micro/go-micro/config/options"
) )
// Network is an interface defining networks or graphs // Network is an interface defining a network
type Network interface { type Network interface {
options.Options options.Options
// Id of this node // Id of this node
Id() uint64 Id() string
// Connect to a node // Address of the network
Connect(id uint64) (Link, error) Address() string
// Connect to the network
Connect() (Node, error)
// Peer with a neighboring network
Peer(Network) (Link, error)
// Close the network connection // Close the network connection
Close() error Close() error
// Accept messages on the network // Accept messages on the network
@ -22,15 +26,15 @@ type Network interface {
Links() ([]Link, error) Links() ([]Link, error)
} }
// Node represents a network node // Node represents a single node on a network
type Node interface { type Node interface {
// Node is a network. Network is a node. // Node is a network. Network is a node.
Network Network
} }
// Link is a connection to another node // Link is a connection between one network and another
type Link interface { type Link interface {
// remote node // remote node the link is to
Node Node
// length of link which dictates speed // length of link which dictates speed
Length() int Length() int
@ -39,7 +43,12 @@ type Link interface {
} }
// Message is the base type for opaque data // Message is the base type for opaque data
type Message []byte type Message struct {
// Headers which provide local/remote info
Header map[string]string
// The opaque data being sent
Data []byte
}
var ( var (
// TODO: set default network // TODO: set default network