registry

package
v0.0.0-...-608e6a2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegisterType_name = map[int32]string{
		0: "REGISTER_TYPE_MEMORY",
		1: "REGISTER_TYPE_ETCD",
	}
	RegisterType_value = map[string]int32{
		"REGISTER_TYPE_MEMORY": 0,
		"REGISTER_TYPE_ETCD":   1,
	}
)

Enum value maps for RegisterType.

View Source
var File_trellis_tech_trellis_v1_proto_registry_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Config

type Config struct {
	RegisterType   RegisterType `yaml:"register_type" json:"register_type"`
	RegisterPrefix string       `yaml:"register_prefix" json:"register_prefix"`
	RetryTimes     int          `yaml:"retry_times" json:"retry_times"`

	RegisterServices `yaml:",inline" json:",inline"`
	WatchServices    []*WatchService `yaml:"watch_services" json:"watch_services"`

	ETCDConfig etcd.Config `yaml:"etcd_config" json:"etcd_config"`
}

func (*Config) ParseFlagsWithPrefix

func (cfg *Config) ParseFlagsWithPrefix(prefix string, f *flag.FlagSet)

ParseFlagsWithPrefix adds the flags required to config this to the given FlagSet.

type NewRegistryFunc

type NewRegistryFunc func(...Option) (Registry, error)

NewRegistryFunc new registry function

type Option

type Option func(*Options)

Option initial options' functions

func EtcdConfig

func EtcdConfig(c *etcd.Config) Option

func Prefix

func Prefix(pre string) Option

func RetryTimes

func RetryTimes(times int) Option

type Options

type Options struct {
	Prefix     string
	ETCDConfig *etcd.Config
	RetryTimes int
}

Options new registry Options

type ProcessService

type ProcessService interface {
	Register(*ServiceNode) error
	Deregister(*ServiceNode) error
	Watch(*service.Service) (Watcher, error)
}

ProcessService Process register service

type RegisterServices

type RegisterServices struct {
	RegisterServiceNodes []*ServiceNode `yaml:"register_service_nodes" json:"register_service_nodes"`
}

type RegisterType

type RegisterType int32
const (
	RegisterType_REGISTER_TYPE_MEMORY RegisterType = 0
	RegisterType_REGISTER_TYPE_ETCD   RegisterType = 1
)

func (RegisterType) Descriptor

func (RegisterType) Enum

func (x RegisterType) Enum() *RegisterType

func (RegisterType) EnumDescriptor deprecated

func (RegisterType) EnumDescriptor() ([]byte, []int)

Deprecated: Use RegisterType.Descriptor instead.

func (RegisterType) Number

func (RegisterType) String

func (x RegisterType) String() string

func (RegisterType) Type

type Registry

type Registry interface {
	ID() string
	String() string

	ProcessService

	lifecycle.LifeCycle
}

Registry The registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, ...}

type Result

type Result struct {
	Id          string            `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Service     *service.Service  `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"`
	EventType   service.EventType `protobuf:"varint,3,opt,name=event_type,json=eventType,proto3,enum=service.EventType" json:"event_type,omitempty"`
	ServiceNode *ServiceNode      `protobuf:"bytes,4,opt,name=service_node,json=serviceNode,proto3" json:"service_node,omitempty"`
	Timestamp   int64             `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// contains filtered or unexported fields
}

func (*Result) Descriptor deprecated

func (*Result) Descriptor() ([]byte, []int)

Deprecated: Use Result.ProtoReflect.Descriptor instead.

func (*Result) GetEventType

func (x *Result) GetEventType() service.EventType

func (*Result) GetId

func (x *Result) GetId() string

func (*Result) GetService

func (x *Result) GetService() *service.Service

func (*Result) GetServiceNode

func (x *Result) GetServiceNode() *ServiceNode

func (*Result) GetTimestamp

func (x *Result) GetTimestamp() int64

func (*Result) ProtoMessage

func (*Result) ProtoMessage()

func (*Result) ProtoReflect

func (x *Result) ProtoReflect() protoreflect.Message

func (*Result) Reset

func (x *Result) Reset()

func (*Result) String

func (x *Result) String() string

type ServiceNode

type ServiceNode struct {
	Service *service.Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
	Node    *node.Node       `protobuf:"bytes,2,opt,name=node,proto3" json:"node,omitempty"`
	// contains filtered or unexported fields
}

func (*ServiceNode) Descriptor deprecated

func (*ServiceNode) Descriptor() ([]byte, []int)

Deprecated: Use ServiceNode.ProtoReflect.Descriptor instead.

func (*ServiceNode) GetNode

func (x *ServiceNode) GetNode() *node.Node

func (*ServiceNode) GetService

func (x *ServiceNode) GetService() *service.Service

func (*ServiceNode) ProtoMessage

func (*ServiceNode) ProtoMessage()

func (*ServiceNode) ProtoReflect

func (x *ServiceNode) ProtoReflect() protoreflect.Message

func (*ServiceNode) RegisteredServiceNode

func (x *ServiceNode) RegisteredServiceNode(registry string) string

func (*ServiceNode) Reset

func (x *ServiceNode) Reset()

func (*ServiceNode) String

func (x *ServiceNode) String() string

type WatchService

type WatchService struct {
	Service  *service.Service `yaml:"service" json:"service"`
	NodeType node.NodeType    `yaml:"node_type" json:"node_type"`

	Metadata *WatchServiceMetadata `yaml:"metadata" json:"metadata"`
}

type WatchServiceMetadata

type WatchServiceMetadata struct {
	ClientConfig *clients.Config `yaml:"client_config" json:"client_config"`
}

func ToWatchServiceMetadata

func ToWatchServiceMetadata(data string) (*WatchServiceMetadata, error)

type Watcher

type Watcher interface {
	// Next is a blocking call
	Next() (*Result, error)
	Stop()
}

Watcher is an interface that returns updates about services within the registry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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