router

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 6 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientFactory

type ClientFactory interface {
	GetLocalClient() interface{}
	MakeRemoteClient(client thrift.TChanClient) interface{}
}

A ClientFactory is able to provide an implementation of a TChan[Service] interface that can dispatch calls to the actual implementation. This could be both a local or a remote implementation of the interface based on the dest provided

type ClientResult added in v0.8.5

type ClientResult struct {
	HostPort string
	Client   interface{}
	IsRemote bool
}

ClientResult is a struct that contains a reference to the actual callable client and a bool indicating whether or not that client is local or remote.

type Router

type Router interface {
	// GetClient provides the caller with a client for a given key. At the same
	// time it will inform the caller if the client is a remote client or a
	// local client via the isRemote return value.
	GetClient(key string) (client interface{}, isRemote bool, err error)
	// GetNClients provides the caller with an ordered slice of clients for a
	// given key. Each result is a struct with a reference to the actual client
	// and a bool indicating whether or not that client is a remote client or a
	// local client.
	GetNClients(key string, n int) (clients []ClientResult, err error)
}

A Router creates instances of TChannel Thrift Clients via the help of the ClientFactory

func New

func New(rp ringpop.Interface, f ClientFactory, ch *tchannel.Channel) Router

New creates an instance that validates the Router interface. A Router will be used to get implementations of service interfaces that implement a distributed microservice.

Jump to

Keyboard shortcuts

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