polaris

package module
v2.0.0-...-a803e9d Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLimitExceed = errors.New(429, "RATELIMIT", "service unavailable due to rate limit exceeded")
)

ErrLimitExceed is service unavailable due to rate limit exceeded.

Functions

func Ratelimit

func Ratelimit(l Limiter) middleware.Middleware

Ratelimit Request rate limit middleware

Types

type ConfigOption

type ConfigOption func(o *configOptions)

ConfigOption is polaris config option.

func WithConfigFile

func WithConfigFile(file ...File) ConfigOption

WithConfigFile with polaris config file

type ConfigWatcher

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

func (*ConfigWatcher) Next

func (w *ConfigWatcher) Next() ([]*config.KeyValue, error)

func (*ConfigWatcher) Stop

func (w *ConfigWatcher) Stop() error

type File

type File struct {
	Name  string
	Group string
}

type Limiter

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

func (*Limiter) Allow

func (l *Limiter) Allow(method string, argument ...model.Argument) (ratelimit.DoneFunc, error)

Allow interface impl

type LimiterOption

type LimiterOption func(*limiterOptions)

LimiterOption function for polaris limiter

func WithLimiterNamespace

func WithLimiterNamespace(namespace string) LimiterOption

WithLimiterNamespace with limiter namespace.

func WithLimiterRetryCount

func WithLimiterRetryCount(retryCount int) LimiterOption

WithLimiterRetryCount with limiter retryCount.

func WithLimiterService

func WithLimiterService(service string) LimiterOption

WithLimiterService with limiter service.

func WithLimiterTimeout

func WithLimiterTimeout(timeout time.Duration) LimiterOption

WithLimiterTimeout with limiter arguments.

func WithLimiterToken

func WithLimiterToken(token uint32) LimiterOption

WithLimiterToken with limiter token.

type Option

type Option func(o *Polaris)

Option is polaris option.

func WithNamespace

func WithNamespace(ns string) Option

WithNamespace with polaris global testNamespace

func WithService

func WithService(service string) Option

WithService set the current service name

type Polaris

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

func New

func New(sdk api.SDKContext, opts ...Option) Polaris

New polaris Service governance.

func (*Polaris) Config

func (p *Polaris) Config(opts ...ConfigOption) (config.Source, error)

func (*Polaris) Limiter

func (p *Polaris) Limiter(opts ...LimiterOption) (r Limiter)

func (*Polaris) NodeFilter

func (p *Polaris) NodeFilter(opts ...RouterOption) selector.NodeFilter

NodeFilter polaris dynamic router selector

func (*Polaris) Registry

func (p *Polaris) Registry(opts ...RegistryOption) (r *Registry)

type Registry

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

Registry is polaris registry.

func (*Registry) Deregister

func (r *Registry) Deregister(_ context.Context, serviceInstance *registry.ServiceInstance) error

Deregister the registration.

func (*Registry) GetService

func (r *Registry) GetService(_ context.Context, serviceName string) ([]*registry.ServiceInstance, error)

GetService return the service instances in memory according to the service name.

func (*Registry) Register

func (r *Registry) Register(_ context.Context, instance *registry.ServiceInstance) error

Register the registration.

func (*Registry) Watch

func (r *Registry) Watch(ctx context.Context, serviceName string) (registry.Watcher, error)

Watch creates a watcher according to the service name.

type RegistryOption

type RegistryOption func(o *registryOptions)

RegistryOption is polaris option.

func WithRegistryHealthy

func WithRegistryHealthy(healthy bool) RegistryOption

WithRegistryHealthy with Healthy option.

func WithRegistryIsolate

func WithRegistryIsolate(isolate bool) RegistryOption

WithRegistryIsolate with Isolate option.

func WithRegistryRetryCount

func WithRegistryRetryCount(retryCount int) RegistryOption

WithRegistryRetryCount with RetryCount option.

func WithRegistryServiceToken

func WithRegistryServiceToken(serviceToken string) RegistryOption

WithRegistryServiceToken with ServiceToken option.

func WithRegistryTTL

func WithRegistryTTL(TTL int) RegistryOption

WithRegistryTTL with TTL option.

func WithRegistryTimeout

func WithRegistryTimeout(timeout time.Duration) RegistryOption

WithRegistryTimeout with Timeout option.

func WithRegistryWeight

func WithRegistryWeight(weight int) RegistryOption

WithRegistryWeight with Weight option.

type RouterOption

type RouterOption func(o *router)

func WithRouterService

func WithRouterService(service string) RouterOption

WithRouterService set the caller service name used by the route

type Watcher

type Watcher struct {
	ServiceName string
	Namespace   string
	Ctx         context.Context
	Cancel      context.CancelFunc
	Channel     <-chan model.SubScribeEvent

	ServiceInstances map[string][]model.Instance
	// contains filtered or unexported fields
}

func (*Watcher) Next

func (w *Watcher) Next() ([]*registry.ServiceInstance, error)

Next returns services in the following two cases: 1.the first time to watch and the service instance list is not empty. 2.any service instance changes found. if the above two conditions are not met, it will block until context deadline exceeded or canceled

func (*Watcher) Stop

func (w *Watcher) Stop() error

Stop close the watcher.

Jump to

Keyboard shortcuts

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