micro/network/network.go
2019-06-17 21:11:39 +01:00

46 lines
1.0 KiB
Go

// Package network is an interface for defining a network overlay
package network
import (
"github.com/micro/go-micro/config/options"
)
type Network interface {
options.Options
// Id of this network
Id() string
// Connect to the network with id
Connect(id string) error
// Close the network connection
Close() error
// Accept messages
Accept() (*Message, error)
// Send a message
Send(*Message) error
// Advertise a service on this network
Advertise(service string) error
// Retrieve list of nodes for a service
Nodes(service string) ([]Node, error)
}
// Node represents a network node
type Node interface {
// Node is a network. Network is a node.
Network
}
// Message is a message sent over the network
type Message struct {
// Headers are the routing headers
// e.g Micro-Service, Micro-Endpoint, Micro-Network
// see https://github.com/micro/development/blob/master/protocol.md
Header map[string]string
// Body is the encaspulated payload
Body []byte
}
var (
// TODO: set default network
DefaultNetwork Network
)