Documentation ¶
Index ¶
- Variables
- func InitPolarisContext(cnf *conf.Configuration) (cfg config.Configuration, ctx api.SDKContext, err error)
- func NewBalancerBuilder(name string, ctx api.SDKContext) balancer.Builder
- func PolarisContext() (ctx api.SDKContext, err error)
- func RateLimitUnaryServerInterceptor(cfg *conf.Configuration) grpc.UnaryServerInterceptor
- func SetPolarisContextOnceByConfig(cfg config.Configuration) (err error)
- func SetReportInfoAnalyzer(analyzer ReportInfoAnalyzer)
- type Driver
- func (drv *Driver) CreateRegistry(cnf *conf.Configuration) (registry.Registry, error)
- func (drv *Driver) GetRegistry(name string) (registry.Registry, error)
- func (drv *Driver) ResolverBuilder(cnf *conf.Configuration) (resolver.Builder, error)
- func (drv *Driver) WithDialOptions(registryOpt registry.DialOptions) (opts []grpc.DialOption, err error)
- type LBConfig
- type Options
- type RateLimitInterceptor
- type RegisterContext
- type Registry
- func (r *Registry) Apply(cnf *conf.Configuration)
- func (r *Registry) Close()
- func (r *Registry) GetServiceInfos(service string) ([]*registry.ServiceInfo, error)
- func (r *Registry) Register(serviceInfo *registry.ServiceInfo) error
- func (r *Registry) TTL() time.Duration
- func (r *Registry) Unregister(serviceInfo *registry.ServiceInfo) error
- type ReportInfoAnalyzer
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultNamespace default namespace when namespace is not set DefaultNamespace = "default" // LoadBalanceConfig config for do the balance LoadBalanceConfig = fmt.Sprintf("{\n \"loadBalancingConfig\": [ { \"%s\": {} } ]}", scheme) )
var ( // ErrorPolarisServiceRouteRuleEmpty error service route rule is empty ErrorPolarisServiceRouteRuleEmpty = errors.New("service route rule is empty") )
Functions ¶
func InitPolarisContext ¶
func InitPolarisContext(cnf *conf.Configuration) (cfg config.Configuration, ctx api.SDKContext, err error)
InitPolarisContext create polaris context by config
func NewBalancerBuilder ¶
func NewBalancerBuilder(name string, ctx api.SDKContext) balancer.Builder
NewBalancerBuilder creates a new polaris balancer builder
func PolarisContext ¶
func PolarisContext() (ctx api.SDKContext, err error)
PolarisContext get or init the global polaris context
func RateLimitUnaryServerInterceptor ¶
func RateLimitUnaryServerInterceptor(cfg *conf.Configuration) grpc.UnaryServerInterceptor
RateLimitUnaryServerInterceptor returns a new unary server interceptors that performs per-method rate limiting.
func SetPolarisContextOnceByConfig ¶
func SetPolarisContextOnceByConfig(cfg config.Configuration) (err error)
SetPolarisContextOnceByConfig set polaris context by config, if polaris context has init then do nothing
func SetReportInfoAnalyzer ¶
func SetReportInfoAnalyzer(analyzer ReportInfoAnalyzer)
SetReportInfoAnalyzer sets report info analyzer
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver implementation of registry.Driver. It is used to create a polaris registry
func (*Driver) CreateRegistry ¶
CreateRegistry creates a polaris registry.
func (*Driver) ResolverBuilder ¶
ResolverBuilder creates a polaris resolver builder.
func (*Driver) WithDialOptions ¶
func (drv *Driver) WithDialOptions(registryOpt registry.DialOptions) (opts []grpc.DialOption, err error)
WithDialOptions returns the default dial options for the grpc Polaris GRPC Client.
type LBConfig ¶
type LBConfig struct { serviceconfig.LoadBalancingConfig `json:"-"` HashKey string `json:"hash_key"` LbPolicy string `json:"lb_policy"` }
LBConfig is the LB config for the polaris policy.
type Options ¶
type Options struct { // TTL must between (0s, 60s) see: polaris.yaml TTL time.Duration `json:"ttl" yaml:"ttl"` }
Options is the options for the polaris registry
type RateLimitInterceptor ¶
type RateLimitInterceptor struct {
// contains filtered or unexported fields
}
RateLimitInterceptor is a gRPC interceptor that implements rate limiting.
func NewRateLimitOptions ¶
func NewRateLimitOptions() *RateLimitInterceptor
func (*RateLimitInterceptor) Apply ¶
func (rl *RateLimitInterceptor) Apply(cnf *conf.Configuration)
type RegisterContext ¶
type RegisterContext struct {
// contains filtered or unexported fields
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Apply ¶
func (r *Registry) Apply(cnf *conf.Configuration)
Apply the configuration to the registry and set the first config as the default global config
func (*Registry) GetServiceInfos ¶
func (r *Registry) GetServiceInfos(service string) ([]*registry.ServiceInfo, error)
GetServiceInfos implements the registry interface
func (*Registry) Unregister ¶
func (r *Registry) Unregister(serviceInfo *registry.ServiceInfo) error
Unregister the service from the registry if the service is not registered, return nil