router

package
v2.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router struct

func New

func New() *Router

New returns the router

func (*Router) AddRoute

func (r *Router) AddRoute(
	serverType string,
	routingFunction RoutingFunc,
)

AddRoute adds a routing function to a server type

func (*Router) Route

func (r *Router) Route(
	ctx context.Context,
	rpcType protos.RPCType,
	svType string,
	route *route.Route,
	msg *message.Message,
) (*cluster.Server, error)

Route gets the right server to use in the call

func (*Router) SetServiceDiscovery

func (r *Router) SetServiceDiscovery(sd cluster.ServiceDiscovery)

SetServiceDiscovery sets the sd client

type RoutingFunc

type RoutingFunc func(
	ctx context.Context,
	route *route.Route,
	payload []byte,
	servers map[string]*cluster.Server,
) (*cluster.Server, error)

RoutingFunc defines a routing function

Jump to

Keyboard shortcuts

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