mesh

package module
v0.0.0-...-76c52b3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2018 License: MIT Imports: 13 Imported by: 7

README

mesh

service mesh implement

Documentation

Index

Constants

View Source
const (
	PINWE = 0x11BC
)

PINWE .

Variables

View Source
var (
	ErrServiceNotFound = errors.New("service not found")
	ErrNetworkClosed   = errors.New("underground network closed")
)

Builtin errors

View Source
var (
	ProtocolServiceHub    = "/dynamicgo/mesh/hub/1.0.0"
	ProtocolConfigService = "/dynamicgo/mesh/config/1.0.0"
)

Builtin protocols

View Source
var (
	ErrFormat = errors.New("invalid peer address format")
)

Errors

Functions

func RegisterNetwork

func RegisterNetwork(name string, network NetworkPlugin)

RegisterNetwork register network plugin

Types

type Agent

type Agent interface {
	Network() Network
	Stop() error
	RegisterService(name string, options ...grpc.ServerOption) (Service, error)
	FindService(name string, options ...grpc.DialOption) (*grpc.ClientConn, error)
}

Agent microsrevice mesh agent node

type Dialer

type Dialer interface {
	Dial(ctx context.Context, serviceName string, options ...grpc.DialOption) (*grpc.ClientConn, error)
	Network() Network
}

Dialer .

func NewDialer

func NewDialer(network Network, balancer DialerBalancer) Dialer

NewDialer .

type DialerBalancer

type DialerBalancer interface {
	NextPeer(serviceName string) (*Peer, error)
}

DialerBalancer .

func DefaultBalancer

func DefaultBalancer(peers []*Peer) DialerBalancer

DefaultBalancer .

type Network

type Network interface {
	Stop() error
	Listen(serviceName string) (net.Listener, error)
	Dial(peer *Peer, serviceName string, timeout time.Duration) (net.Conn, error)
	ID() string
	Peer() *Peer
}

Network .

type NetworkPlugin

type NetworkPlugin func(ctx context.Context, config config.Config) (Network, error)

NetworkPlugin .

func GetNetworkPlugin

func GetNetworkPlugin() (NetworkPlugin, error)

GetNetworkPlugin .

type Peer

type Peer struct {
	ID    string
	Addrs []multiaddr.Multiaddr
}

Peer peer info struct

func AddrsToPeers

func AddrsToPeers(addrs []string) (peers []*Peer, err error)

AddrsToPeers .

func MergePeers

func MergePeers(peers []*Peer) []*Peer

MergePeers merge peers with same id

func ParseMeshAddr

func ParseMeshAddr(name string) (*Peer, error)

ParseMeshAddr parse mesh address to peer object

func (*Peer) MeshAddrs

func (peer *Peer) MeshAddrs() (addrs []string)

MeshAddrs convert peer to mesh addresses

type Service

type Service interface {
	Run(main ServiceMain, options ...ServiceOption) error
}

Service .

type ServiceConfig

type ServiceConfig struct {
	ConfigSources []source.Source
	RemoteConfig  bool
}

ServiceConfig .

type ServiceMain

type ServiceMain func(agent Agent, server *grpc.Server, config config.Config) error

ServiceMain service main entry

type ServiceOption

type ServiceOption func(config *ServiceConfig)

ServiceOption .

func NoRemoteConfig

func NoRemoteConfig() ServiceOption

NoRemoteConfig ignore load config from admin

func WithConfig

func WithConfig(source source.Source) ServiceOption

WithConfig load service with input config ,multi WithConfig option will auto merged

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL