network

package
v0.0.0-...-5e24cfe Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package network implements micro network node

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lookup

func Lookup(ctx context.Context, req client.Request, opts client.CallOptions) ([]string, error)

Lookup provides a lookup function that checks for namespace as the Micro-Namespace header

Types

type Error

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

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

var (
	// DefaultNetwork implementation
	DefaultNetwork Network
)

type Node

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

type Option func(*Options)

func Address

func Address(a string) Option

Address sets the network address

func Advertise(a string) Option

Advertise sets the address to advertise

func Id

func Id(id string) Option

Id sets the id of the network node

func Name

func Name(n string) Option

Name sets the network name

func Nodes

func Nodes(n ...string) Option

Nodes is a list of nodes to connect to

func Proxy

func Proxy(p proxy.Proxy) Option

Proxy sets the network proxy

func Router

func Router(r router.Router) Option

Router sets the network router

func Tunnel

func Tunnel(t tunnel.Tunnel) Option

Tunnel sets the network tunnel

type Options

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
}

Options configure network

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns network default options

type Status

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

Status is node status

Directories

Path Synopsis
Package resolver resolves network names to addresses
Package resolver resolves network names to addresses
dns
Package dns resolves names to dns records
Package dns resolves names to dns records
dnssrv
Package dns srv resolves names to dns srv records
Package dns srv resolves names to dns srv records
http
Package http resolves names to network addresses using a http request
Package http resolves names to network addresses using a http request
noop
Package noop is a noop resolver
Package noop is a noop resolver
registry
Package registry resolves names using the go-micro registry
Package registry resolves names using the go-micro registry
static
Package static is a static resolver
Package static is a static resolver
Package transport is an interface for synchronous connection based communication
Package transport is an interface for synchronous connection based communication
grpc
Package grpc provides a grpc transport
Package grpc provides a grpc transport
memory
Package memory is an in-memory transport
Package memory is an in-memory transport
Package tunnel provides gre network tunnelling
Package tunnel provides gre network tunnelling
broker
Package broker is a tunnel broker
Package broker is a tunnel broker
transport
Package transport provides a tunnel transport
Package transport provides a tunnel transport

Jump to

Keyboard shortcuts

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