2019-08-05 20:04:47 +03:00
|
|
|
// Package network is for creating internetworks
|
|
|
|
package network
|
2019-08-20 14:48:51 +03:00
|
|
|
|
|
|
|
import (
|
2020-08-19 17:47:17 +03:00
|
|
|
"github.com/unistack-org/micro/v3/client"
|
|
|
|
"github.com/unistack-org/micro/v3/server"
|
2019-08-20 14:48:51 +03:00
|
|
|
)
|
|
|
|
|
2020-01-14 21:12:36 +03:00
|
|
|
// Error is network node errors
|
|
|
|
type Error interface {
|
|
|
|
// Count is current count of errors
|
|
|
|
Count() int
|
|
|
|
// Msg is last error message
|
|
|
|
Msg() string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Status is node status
|
|
|
|
type Status interface {
|
|
|
|
// Error reports error status
|
|
|
|
Error() Error
|
|
|
|
}
|
|
|
|
|
2019-09-02 19:06:21 +03:00
|
|
|
// Node is network node
|
|
|
|
type Node interface {
|
|
|
|
// Id is node id
|
|
|
|
Id() string
|
|
|
|
// Address is node bind address
|
|
|
|
Address() string
|
2019-09-10 03:14:23 +03:00
|
|
|
// Peers returns node peers
|
|
|
|
Peers() []Node
|
2019-09-02 19:06:21 +03:00
|
|
|
// Network is the network node is in
|
|
|
|
Network() Network
|
2020-01-14 21:12:36 +03:00
|
|
|
// Status returns node status
|
|
|
|
Status() Status
|
2019-09-02 19:06:21 +03:00
|
|
|
}
|
|
|
|
|
2019-08-20 14:48:51 +03:00
|
|
|
// Network is micro network
|
|
|
|
type Network interface {
|
2019-09-02 14:39:26 +03:00
|
|
|
// Node is network node
|
|
|
|
Node
|
2019-10-13 14:38:13 +03:00
|
|
|
// Initialise options
|
|
|
|
Init(...Option) error
|
2019-09-02 13:42:45 +03:00
|
|
|
// Options returns the network options
|
|
|
|
Options() Options
|
2019-08-20 14:48:51 +03:00
|
|
|
// 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
|
|
|
|
}
|