router

package
v0.0.0-...-26b160e Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

Router GoDoc

The router is a client library for global service load balancing. Go-micro uses client side load balancing with the Selector interface but most implementation only provide a single view point of the environment, from the service itself. The router library talks to a backend service which aggregates metrics from all services and relays back routing information.

Interface

// The router is the client interface for 
// global service load balancing (GSLB).
// Metrics are batched and published to
// a router which has a view of the whole
// system.
type Router interface {
	// Provides the selector interface
	selector.Selector
	// Return stats maintained here
	Stats() ([]*Stats, error)
	// Record stats for a request - too many args ugh
	Record(r Request, node *registry.Node, d time.Duration, err error)
}

type Stats struct {
	Service   *registry.Service
	Client    *registry.Service
	Timestamp int64
	Duration  int64
	// TODO:
	// Selected
	// Endpoints
}

func NewRouter(opts ...selector.Option) Router {
	return newOS(opts...)
}

Supported Backends

Documentation

Overview

common route for subscribe and publish

Package router is an interface for global service routing.

Index

Constants

This section is empty.

Variables

View Source
var (
	StatsTopic  = "micro.router.stats"
	LabelPrefix = "X-Micro-Label-"
)

Functions

func Client

func Client(c client.Client) selector.Option

func NewContext

func NewContext(ctx context.Context, c Router) context.Context

func NewLabelWrapper

func NewLabelWrapper(c client.Client) client.Client

func Server

func Server(s server.Server) selector.Option

Types

type Request

type Request interface {
	Service() string
	Method() string
}

Could be client or server request

type Router

type Router interface {
	// Provides the selector interface
	selector.Selector
	// Return stats maintained here
	Stats() ([]*Stats, error)
	// Record stats for a request - too many args ugh
	Record(r Request, node *registry.Node, d time.Duration, err error)
}

The router is the client interface to a global service loadbalancer (GSLB). Metrics are batched and published to a router which has a view of the whole system.

func FromContext

func FromContext(ctx context.Context) (Router, bool)

func NewRouter

func NewRouter(opts ...selector.Option) Router

type Stats

type Stats struct {
	Service   *registry.Service
	Client    *registry.Service
	Timestamp int64
	Duration  int64
}

Directories

Path Synopsis
Package go_micro_os_router is a generated protocol buffer package.
Package go_micro_os_router is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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