polaris

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(o *options)

Option is polaris option.

func WithHealthy

func WithHealthy(healthy bool) Option

WithHealthy with Healthy option.

func WithHeartbeat

func WithHeartbeat(heartbeat bool) Option

WithHeartbeat . with Heartbeat option.

func WithIsolate

func WithIsolate(isolate bool) Option

WithIsolate with Isolate option.

func WithNamespace

func WithNamespace(namespace string) Option

WithNamespace with Namespace option.

func WithProtocol

func WithProtocol(protocol string) Option

WithProtocol with Protocol option.

func WithRetryCount

func WithRetryCount(retryCount int) Option

WithRetryCount with RetryCount option.

func WithServiceToken

func WithServiceToken(serviceToken string) Option

WithServiceToken with ServiceToken option.

func WithTTL

func WithTTL(TTL int) Option

WithTTL with TTL option.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout with Timeout option.

func WithWeight

func WithWeight(weight int) Option

WithWeight with Weight option.

type Registry

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

Registry is polaris registry.

func NewRegistry

func NewRegistry(provider api.ProviderAPI, consumer api.ConsumerAPI, opts ...Option) (r *Registry)

func NewRegistryWithConfig

func NewRegistryWithConfig(conf config.Configuration, opts ...Option) (r *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, serviceInstance *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 Watcher

type Watcher struct {
	ServiceName      string
	Namespace        string
	Ctx              context.Context
	Cancel           context.CancelFunc
	Channel          <-chan model.SubScribeEvent
	ServiceInstances []*registry.ServiceInstance
}

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