Documentation ¶
Index ¶
- Variables
- func Ratelimit(l Limiter) middleware.Middleware
- type ConfigOption
- type ConfigWatcher
- type File
- type Limiter
- type LimiterOption
- type Option
- type Polaris
- type Registry
- func (r *Registry) Deregister(_ context.Context, serviceInstance *registry.ServiceInstance) error
- func (r *Registry) GetService(_ context.Context, serviceName string) ([]*registry.ServiceInstance, error)
- func (r *Registry) Register(_ context.Context, instance *registry.ServiceInstance) error
- func (r *Registry) Watch(ctx context.Context, serviceName string) (registry.Watcher, error)
- type RegistryOption
- func WithRegistryHealthy(healthy bool) RegistryOption
- func WithRegistryIsolate(isolate bool) RegistryOption
- func WithRegistryRetryCount(retryCount int) RegistryOption
- func WithRegistryServiceToken(serviceToken string) RegistryOption
- func WithRegistryTTL(TTL int) RegistryOption
- func WithRegistryTimeout(timeout time.Duration) RegistryOption
- func WithRegistryWeight(weight int) RegistryOption
- type RouterOption
- type Watcher
Constants ¶
This section is empty.
Variables ¶
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) Stop ¶
func (w *ConfigWatcher) Stop() error
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 ¶
WithNamespace with polaris global testNamespace
type Polaris ¶
type Polaris struct {
// contains filtered or unexported fields
}
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 ¶
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.
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