registrator

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2023 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HealthKind

type HealthKind string
const (
	HealthKindTTL  HealthKind = "ttl"
	HealthKindGRPC HealthKind = "grpc"
)

type Option

type Option func(Registrator)

Option can be used to manipulate Register config.

type Options

type Options struct {
	//Scheme                    *runtime.Scheme
	ServiceDiscoveryDcName    string
	ServiceDiscovery          discovery.ServiceDiscoveryType
	ServiceDiscoveryNamespace string
	Address                   string
}

type Registrator

type Registrator interface {
	//options
	// add a logger to the Registrator
	//WithLogger(log logging.Logger)
	// Register
	Register(ctx context.Context, s *Service)
	// DeRegister
	DeRegister(ctx context.Context, id string)
	// Query
	Query(ctx context.Context, serviceName string, tags []string) ([]*Service, error)
	// GetEndpointAddress returns the address/port of the serviceEndpoint
	GetEndpointAddress(ctx context.Context, serviceName string, tags []string) (string, error)
	// Watch
	// 1 channel per service to watch
	Watch(ctx context.Context, serviceName string, tags []string, opts WatchOptions) chan *ServiceResponse
	// all services through 1 channel
	WatchCh(ctx context.Context, serviceName string, tags []string, opts WatchOptions, ch chan *ServiceResponse)
	//
	StopWatch(serviceName string)
}

TargetController defines the interfaces for the target controller

func New

func New(ctx context.Context, config *rest.Config, o *Options) (Registrator, error)

type Service

type Service struct {
	Name         string       // service name
	ID           string       // service instance
	Port         int          // service port
	Address      string       // service address
	Tags         []string     // service tags
	HealthChecks []HealthKind // what type of health check kinds are needed to test the service
}

type ServiceResponse

type ServiceResponse struct {
	ServiceName      string
	ServiceInstances []*Service
	Err              error
}

type WatchOptions

type WatchOptions struct {
	// RetriveServices defines if service details are required
	// as part of ServiceResponse(s)
	RetriveServices bool
}

Jump to

Keyboard shortcuts

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