registry

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const OptionKey = "options"

Variables

This section is empty.

Functions

func RegisterDriver

func RegisterDriver(scheme string, drv Driver)

RegisterDriver register a new Registry could be: conf.Configurable,and will be lazy loaded in server.Apply function

func TLS

func TLS(basedir, sslCertificate, sslCertificateKey string) *tls.Config

Types

type DialOption added in v0.0.3

type DialOption interface {
	// contains filtered or unexported methods
}

DialOption is the options for client dial when using registry resolver.

type DialOptions added in v0.0.3

type DialOptions struct {
	// namespace is the namespace of the service.
	Namespace string `json:"namespace" yaml:"namespace"`
	// ServiceName is the target server name, may omit leading slash
	ServiceName string `json:"serviceName" yaml:"serviceName"`
	// Version is the target server version, may omit leading slash
	Version string `json:"version" yaml:"version"`
	// Metadata holds the metadata of the service,registry driver parse it to match itself protocol
	Metadata map[string]string `json:"metadata" yaml:"metadata"`
}

DialOptions is the options for client dial when using registry resolver. it includes the common options for service discovery and grpc dial.

func TargetToOptions deprecated added in v0.0.3

func TargetToOptions(target resolver.Target) (*DialOptions, error)

TargetToOptions parse resolver target to DialOptions

Deprecated: registry driver should provide a function to instead

type Driver added in v0.0.3

type Driver interface {
	// CreateRegistry create a registry which for server side
	CreateRegistry(config *conf.Configuration) (Registry, error)
	// ResolverBuilder returns a resolver.Builder for client side
	ResolverBuilder(config *conf.Configuration) (resolver.Builder, error)
}

Driver is the registry driver interface

func GetRegistry

func GetRegistry(scheme string) (Driver, bool)

GetRegistry get a registry by scheme

type Registry

type Registry interface {
	// Register a service node
	Register(serviceInfo *ServiceInfo) error
	// Unregister a service node
	Unregister(serviceInfo *ServiceInfo) error
	// TTL returns the time to live of the service node, if it is not available, return 0.
	// every tick will call Register function to refresh.
	TTL() time.Duration
	Close()
}

Registry provides an interface for service discovery

type ServiceInfo added in v0.0.3

type ServiceInfo struct {
	Name      string            `json:"name" yaml:"name"`
	Namespace string            `json:"namespace" yaml:"namespace"`
	Version   string            `json:"version" yaml:"version"`
	Host      string            `json:"host" yaml:"host"`
	Port      int               `json:"port" yaml:"port"`
	Protocol  string            `json:"protocol" yaml:"protocol"`
	Metadata  map[string]string `json:"metadata" yaml:"metadata"`
}

ServiceInfo is the service information

func (ServiceInfo) Address added in v0.0.3

func (si ServiceInfo) Address() string

Address is the address of the service,example: host:port,ip:port

func (ServiceInfo) BuildKey added in v0.0.3

func (si ServiceInfo) BuildKey() string

func (ServiceInfo) ToAttributes added in v0.0.3

func (si ServiceInfo) ToAttributes() *attributes.Attributes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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