1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-11-30 08:06:40 +02:00
go-micro/network/network.go

46 lines
1.0 KiB
Go
Raw Normal View History

2019-06-17 17:57:53 +02:00
// 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 {
2019-06-17 22:11:39 +02:00
// Node is a network. Network is a node.
Network
2019-06-17 17:57:53 +02:00
}
// 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
}
2019-06-17 19:25:42 +02:00
var (
// TODO: set default network
DefaultNetwork Network
)