go-micro: github.com/micro/go-micro/network Index | Files | Directories

package network

import "github.com/micro/go-micro/network"

Package network is for creating internetworks

Index

Package Files

default.go network.go node.go options.go

Variables

var (
    // NetworkChannel is the name of the tunnel channel for passing network messages
    NetworkChannel = "network"
    // ControlChannel is the name of the tunnel channel for passing control message
    ControlChannel = "control"
    // DefaultLink is default network link
    DefaultLink = "network"
    // MaxConnections is the max number of network client connections
    MaxConnections = 3
    // MaxPeerErrors is the max number of peer errors before we remove it from network graph
    MaxPeerErrors = 3
)
var (
    // ErrClientNotFound is returned when client for tunnel channel could not be found
    ErrClientNotFound = errors.New("client not found")
    // ErrPeerLinkNotFound is returned when peer link could not be found in tunnel Links
    ErrPeerLinkNotFound = errors.New("peer link not found")
    // ErrPeerMaxExceeded is returned when peer has reached its max error count limit
    ErrPeerMaxExceeded = errors.New("peer max errors exceeded")
)
var (
    // DefaultName is default network name
    DefaultName = "go.micro"
    // DefaultAddress is default network address
    DefaultAddress = ":0"
    // ResolveTime defines time interval to periodically resolve network nodes
    ResolveTime = 1 * time.Minute
    // AnnounceTime defines time interval to periodically announce node neighbours
    AnnounceTime = 1 * time.Second
    // KeepAliveTime is the time in which we want to have sent a message to a peer
    KeepAliveTime = 30 * time.Second
    // SyncTime is the time a network node requests full sync from the network
    SyncTime = 1 * time.Minute
    // PruneTime defines time interval to periodically check nodes that need to be pruned
    // due to their not announcing their presence within this time interval
    PruneTime = 90 * time.Second
)
var (
    // ErrPeerExists is returned when adding a peer which already exists
    ErrPeerExists = errors.New("peer already exists")
    // ErrPeerNotFound is returned when a peer could not be found in node topology
    ErrPeerNotFound = errors.New("peer not found")
)
var (
    // MaxDepth defines max depth of peer topology
    MaxDepth uint = 3
)

func PeersToProto Uses

func PeersToProto(node Node, depth uint) *pb.Peer

PeersToProto returns node peers graph encoded into protobuf

func UnpackPeerTopology Uses

func UnpackPeerTopology(pbPeer *pb.Peer, lastSeen time.Time, depth uint) *node

UnpackPeerTopology unpacks pb.Peer into node topology of given depth

type Error Uses

type Error interface {
    // Count is current count of errors
    Count() int
    // Msg is last error message
    Msg() string
}

Error is network node errors

type Network Uses

type Network interface {
    // Node is network node
    Node
    // Initialise options
    Init(...Option) error
    // Options returns the network options
    Options() Options
    // Name of the network
    Name() string
    // Connect starts the resolver and tunnel server
    Connect() error
    // Close stops the tunnel and resolving
    Close() error
    // Client is micro client
    Client() client.Client
    // Server is micro server
    Server() server.Server
}

Network is micro network

func NewNetwork Uses

func NewNetwork(opts ...Option) Network

NewNetwork returns a new network interface

type Node Uses

type Node interface {
    // Id is node id
    Id() string
    // Address is node bind address
    Address() string
    // Peers returns node peers
    Peers() []Node
    // Network is the network node is in
    Network() Network
    // Status returns node status
    Status() Status
}

Node is network node

type Option Uses

type Option func(*Options)

func Address Uses

func Address(a string) Option

Address sets the network address

func Advertise(a string) Option

Advertise sets the address to advertise

func Id Uses

func Id(id string) Option

Id sets the id of the network node

func Name Uses

func Name(n string) Option

Name sets the network name

func Nodes Uses

func Nodes(n ...string) Option

Nodes is a list of nodes to connect to

func Proxy Uses

func Proxy(p proxy.Proxy) Option

Proxy sets the network proxy

func Resolver Uses

func Resolver(r resolver.Resolver) Option

Resolver is the network resolver

func Router Uses

func Router(r router.Router) Option

Router sets the network router

func Tunnel Uses

func Tunnel(t tunnel.Tunnel) Option

Tunnel sets the network tunnel

type Options Uses

type Options struct {
    // Id of the node
    Id  string
    // Name of the network
    Name string
    // Address to bind to
    Address string
    // Advertise sets the address to advertise
    Advertise string
    // Nodes is a list of nodes to connect to
    Nodes []string
    // Tunnel is network tunnel
    Tunnel tunnel.Tunnel
    // Router is network router
    Router router.Router
    // Proxy is network proxy
    Proxy proxy.Proxy
    // Resolver is network resolver
    Resolver resolver.Resolver
}

Options configure network

func DefaultOptions Uses

func DefaultOptions() Options

DefaultOptions returns network default options

type Status Uses

type Status interface {
    // Error reports error status
    Error() Error
}

Status is node status

Directories

PathSynopsis
resolverPackage resolver resolves network names to addresses
resolver/dnsPackage dns resolves names to dns records
resolver/dnssrvPackage dns srv resolves names to dns srv records
resolver/httpPackage http resolves names to network addresses using a http request
resolver/registryPackage registry resolves names using the go-micro registry
resolver/staticPackage static is a static resolver
service/proto

Package network imports 32 packages (graph) and is imported by 3 packages. Updated 2020-03-15. Refresh now. Tools for package owners.