Documentation ¶
Overview ¶
Package servicerouter is service router which filters server instances. It is between service discovery and load balance.
Index ¶
- func Register(name string, s ServiceRouter)
- func SetDefaultServiceRouter(s ServiceRouter)
- type NoopServiceRouter
- type Option
- func WithContext(ctx context.Context) Option
- func WithDestinationEnvName(envName string) Option
- func WithDestinationMetadata(key string, val string) Option
- func WithDestinationSetName(destinationSetName string) Option
- func WithDisableServiceRouter() Option
- func WithEnvKey(key string) Option
- func WithEnvTransfer(envTransfer string) Option
- func WithNamespace(namespace string) Option
- func WithSourceEnvName(envName string) Option
- func WithSourceMetadata(key string, val string) Option
- func WithSourceNamespace(namespace string) Option
- func WithSourceServiceName(serviceName string) Option
- func WithSourceSetName(sourceSetName string) Option
- type Options
- type ServiceRouter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(name string, s ServiceRouter)
Register registers a named service router.
func SetDefaultServiceRouter ¶
func SetDefaultServiceRouter(s ServiceRouter)
SetDefaultServiceRouter set the default service router.
Types ¶
type NoopServiceRouter ¶
type NoopServiceRouter struct { }
NoopServiceRouter is the noop service router.
type Option ¶
type Option func(*Options)
Option modifies the Options.
func WithContext ¶
WithContext returns an Option which sets request context.
func WithDestinationEnvName ¶
WithDestinationEnvName returns an Option which sets callee environment name.
func WithDestinationMetadata ¶
WithDestinationMetadata returns an Option which sets callee metadata.
func WithDestinationSetName ¶
WithDestinationSetName returns an Option which sets callee set name.
func WithDisableServiceRouter ¶
func WithDisableServiceRouter() Option
WithDisableServiceRouter returns an Option which disables service router.
func WithEnvKey ¶
WithEnvKey returns an Option which sets environment key.
func WithEnvTransfer ¶
WithEnvTransfer returns an Option which sets transparent environment information.
func WithNamespace ¶
WithNamespace returns an Option which sets namespace.
func WithSourceEnvName ¶
WithSourceEnvName returns an Option which sets caller environment name.
func WithSourceMetadata ¶
WithSourceMetadata returns an Option which sets caller metadata.
func WithSourceNamespace ¶
WithSourceNamespace returns an Option which sets caller namespace.
func WithSourceServiceName ¶
WithSourceServiceName returns an Option which sets caller service name.
func WithSourceSetName ¶
WithSourceSetName returns an Option which sets caller set name.
type Options ¶
type Options struct { Ctx context.Context SourceSetName string DestinationSetName string DisableServiceRouter bool Namespace string SourceNamespace string SourceServiceName string SourceEnvName string DestinationEnvName string EnvTransfer string EnvKey string SourceMetadata map[string]string DestinationMetadata map[string]string }
Options defines the call options.
type ServiceRouter ¶
type ServiceRouter interface {
Filter(serviceName string, nodes []*registry.Node, opt ...Option) ([]*registry.Node, error)
}
ServiceRouter is the interface that defines the service router.
var DefaultServiceRouter ServiceRouter = &NoopServiceRouter{}
DefaultServiceRouter is the default service router which is initialized by configuration.