servicediscovery

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInit         = errors.New("init error")
	ErrDuplicateRun = errors.New("duplicate runs")
	ErrInternal     = errors.New("internal error")
	ErrMarshal      = errors.New("marshal error")
)

Functions

This section is empty.

Types

type DiscoveryCallback

type DiscoveryCallback func(status HealthStatus)

type DiscoveryErrCallback

type DiscoveryErrCallback func(err error)

type HealthStatus

type HealthStatus struct {
	Identity       Identity
	IsAvailble     bool
	LastHeartbeat  time.Time
	AvailableUntil time.Time
}

HealthStatus is the service status.

type Identity

type Identity struct {
	Namespace string
	Service   string
	Instance  string
}

Identity is the service identity managed by the service discovery.

type Operator

type Operator interface {
	ServiceProviderOperator
	ServiceConsumerOperator
}

Operator is the interface that should be implmented by the underlying implementation for both ServiceProvider and ServiceConsume.

type RegisterErrCallback

type RegisterErrCallback func(err error)

type ServiceConsumer

type ServiceConsumer interface {
	List(ctx context.Context) ([]HealthStatus, error)
	Run(ctx context.Context) error
}

ServiceConsumer consumes services via the service discovery.

func NewServicConsumer

func NewServicConsumer(option ServiceConsumerOption) (ServiceConsumer, error)

type ServiceConsumerOperator

type ServiceConsumerOperator interface {
	ListHealthStatus(ctx context.Context, identity Identity) ([]HealthStatus, error)
	DeregisterHealthStatus(ctx context.Context, identity Identity) error
}

ServiceConsumerOperator is the interface that should be implmented by the underlying implementation for ServiceConsume.

type ServiceConsumerOption

type ServiceConsumerOption struct {
	Identity                Identity
	DiscoveryDuration       time.Duration
	DiscoveryCallback       DiscoveryCallback
	DiscoveryErrCallback    DiscoveryErrCallback
	ServiceConsumerOperator ServiceConsumerOperator
}

ServiceConsumerOption defines the behavior of the service consumer.

type ServiceProvider

type ServiceProvider interface {
	Run(ctx context.Context) error
}

ServiceProvider provides a service via the service discovery.

func NewServiceProvider

func NewServiceProvider(option ServiceProviderOption) (ServiceProvider, error)

type ServiceProviderOperator

type ServiceProviderOperator interface {
	RegisterHealthStatus(ctx context.Context, status HealthStatus) error
}

ServiceProviderOperator is the interface that should be implmented by the underlying implementation for ServiceProvider.

type ServiceProviderOption

type ServiceProviderOption struct {
	Identity                Identity
	HeartbeatDuration       time.Duration
	AvailableDuration       time.Duration
	RegisterErrCallback     RegisterErrCallback
	ServiceProviderOperator ServiceProviderOperator
}

ServiceProviderOption defines the behavior of the service provider.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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