Help us shape the future of Go! Take the 2026 Go Developer Survey

gxregistry

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package gxregistry provides a interface for service register/discovery

Package gxregistry provides a interface for service register/discovery

Package gxregistry is a generated protocol buffer package.

It is generated from these files:
	service.proto

It has these top-level messages:
	ServiceAttr
	Node
	Service
	EventResult

Package gxregistry provides a interface for service register/discovery

Index

Constants

View Source
const (
	REGISTRY_CONN_DELAY = 3 // watchDir中使用,防止不断地对zk重连
	DefaultTimeout      = 3e9
	MaxFailTime         = 15e9 // fail retry wait time delay
)

Variables

View Source
var (
	ErrorRegistryNotFound = jerrors.Errorf("registry not found")
	ErrorAlreadyRegister  = jerrors.Errorf("service has already been registered")
	DefaultServiceRoot    = "/gxregistry"
)
View Source
var (
	ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowService   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	ErrWatcherClosed = jerrors.Errorf("Watcher closed")
)
View Source
var ServiceEventType_name = map[int32]string{
	0: "SET_UNKNOWN",
	1: "ServiceAdd",
	2: "ServiceDel",
	3: "ServiceUpdate",
}
View Source
var ServiceEventType_value = map[string]int32{
	"SET_UNKNOWN":   0,
	"ServiceAdd":    1,
	"ServiceDel":    2,
	"ServiceUpdate": 3,
}
View Source
var ServiceRoleType_name = map[int32]string{
	0: "SRT_UNKOWN",
	1: "SRT_Provider",
	2: "SRT_Consumer",
}
View Source
var ServiceRoleType_value = map[string]int32{
	"SRT_UNKOWN":   0,
	"SRT_Provider": 1,
	"SRT_Consumer": 2,
}

Functions

func EncodeService

func EncodeService(s *Service) (string, error)

Types

type EventResult

type EventResult struct {
	Action  ServiceEventType `protobuf:"varint,1,opt,name=Action,proto3,enum=gxregistry.ServiceEventType" json:"Action,omitempty"`
	Service *Service         `protobuf:"bytes,2,opt,name=Service" json:"Service,omitempty"`
}

Result is returned by a call to Next on the watcher. Actions can be create, update, delete

func (*EventResult) Descriptor

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

func (*EventResult) Equal

func (this *EventResult) Equal(that interface{}) bool

func (*EventResult) GoString

func (this *EventResult) GoString() string

func (*EventResult) Marshal

func (m *EventResult) Marshal() (dAtA []byte, err error)

func (*EventResult) MarshalTo

func (m *EventResult) MarshalTo(dAtA []byte) (int, error)

func (*EventResult) ProtoMessage

func (*EventResult) ProtoMessage()

func (*EventResult) Reset

func (m *EventResult) Reset()

func (*EventResult) Size

func (m *EventResult) Size() (n int)

func (*EventResult) String

func (this *EventResult) String() string

func (*EventResult) Unmarshal

func (m *EventResult) Unmarshal(dAtA []byte) error

func (*EventResult) VerboseEqual

func (this *EventResult) VerboseEqual(that interface{}) error

type Node

type Node struct {
	ID       string            `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
	Address  string            `protobuf:"bytes,2,opt,name=Address,proto3" json:"Address,omitempty"`
	Port     int32             `protobuf:"varint,3,opt,name=Port,proto3" json:"Port,omitempty"`
	Metadata map[string]string `` /* 150-byte string literal not displayed */
}

func (*Node) Copy

func (m *Node) Copy() *Node

func (*Node) Descriptor

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

func (*Node) Equal

func (this *Node) Equal(that interface{}) bool

func (*Node) GoString

func (this *Node) GoString() string

func (*Node) Marshal

func (m *Node) Marshal() (dAtA []byte, err error)

func (*Node) MarshalTo

func (m *Node) MarshalTo(dAtA []byte) (int, error)

func (*Node) ProtoMessage

func (*Node) ProtoMessage()

func (*Node) Reset

func (m *Node) Reset()

func (*Node) Size

func (m *Node) Size() (n int)

func (*Node) String

func (this *Node) String() string

func (*Node) Unmarshal

func (m *Node) Unmarshal(dAtA []byte) error

func (*Node) VerboseEqual

func (this *Node) VerboseEqual(that interface{}) error

type NodeMeta added in v0.3.1

type NodeMeta func(*Node)

func WithNodeMeta added in v0.3.1

func WithNodeMeta(key, value string) NodeMeta

type Option

type Option func(*Options)

func WithAddrs

func WithAddrs(addrs ...string) Option

Addrs is the registry addresses to use

func WithRoot

func WithRoot(root string) Option

func WithTimeout

func WithTimeout(t time.Duration) Option

type Options

type Options struct {
	Addrs   []string
	Timeout time.Duration
	Root    string
}

type Registry

type Registry interface {
	Register(service Service) error
	Deregister(service Service) error
	GetServices(attr ServiceAttr) ([]Service, error)
	Watch(opts ...WatchOption) (Watcher, error)
	Close() error
	String() string
	Options() Options
}

Registry provides an interface for service register

type Service

type Service struct {
	Attr     *ServiceAttr      `protobuf:"bytes,1,opt,name=Attr" json:"Attr,omitempty"`
	Nodes    []*Node           `protobuf:"bytes,2,rep,name=Nodes" json:"Nodes,omitempty"`
	Metadata map[string]string `` /* 150-byte string literal not displayed */
}

func DecodeService

func DecodeService(ds []byte) (*Service, error)

func (*Service) Copy

func (s *Service) Copy() *Service

func (*Service) Descriptor

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

func (*Service) Equal

func (this *Service) Equal(that interface{}) bool

func (*Service) GoString

func (this *Service) GoString() string

func (*Service) Marshal

func (m *Service) Marshal() (dAtA []byte, err error)

func (*Service) MarshalTo

func (m *Service) MarshalTo(dAtA []byte) (int, error)

func (*Service) NodePath

func (s *Service) NodePath(root string, node Node) string

func (*Service) Path

func (s *Service) Path(root string) string

/dubbo/group%3Dbjtelecom%26protocol%3Dpb%26service%3Dshopping%26type%3Dadd%2Bservice%26version%3D1.0.1/node1

func (*Service) ProtoMessage

func (*Service) ProtoMessage()

func (*Service) Reset

func (m *Service) Reset()

func (*Service) Size

func (m *Service) Size() (n int)

func (*Service) String

func (this *Service) String() string

func (*Service) Unmarshal

func (m *Service) Unmarshal(dAtA []byte) error

func (*Service) VerboseEqual

func (this *Service) VerboseEqual(that interface{}) error

type ServiceAttr

type ServiceAttr struct {
	Group    string          `protobuf:"bytes,1,opt,name=Group,proto3" json:"Group,omitempty"`
	Service  string          `protobuf:"bytes,2,opt,name=Service,proto3" json:"Service,omitempty"`
	Protocol string          `protobuf:"bytes,3,opt,name=Protocol,proto3" json:"Protocol,omitempty"`
	Version  string          `protobuf:"bytes,4,opt,name=Version,proto3" json:"Version,omitempty"`
	Role     ServiceRoleType `protobuf:"varint,5,opt,name=Role,proto3,enum=gxregistry.ServiceRoleType" json:"Role,omitempty"`
}

func (*ServiceAttr) Copy

func (m *ServiceAttr) Copy() *ServiceAttr

func (*ServiceAttr) Descriptor

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

func (*ServiceAttr) Equal

func (this *ServiceAttr) Equal(that interface{}) bool

func (*ServiceAttr) Filter

func (m *ServiceAttr) Filter(service ServiceAttr) bool

fine filtering

func (*ServiceAttr) GoString

func (this *ServiceAttr) GoString() string

func (*ServiceAttr) Marshal

func (m *ServiceAttr) Marshal() (dAtA []byte, err error)

func (*ServiceAttr) MarshalPath

func (a *ServiceAttr) MarshalPath() ([]byte, error)

func (*ServiceAttr) MarshalTo

func (m *ServiceAttr) MarshalTo(dAtA []byte) (int, error)

func (*ServiceAttr) MeshFilter added in v0.3.1

func (m *ServiceAttr) MeshFilter(service ServiceAttr) bool

func (*ServiceAttr) ProtoMessage

func (*ServiceAttr) ProtoMessage()

func (*ServiceAttr) Reset

func (m *ServiceAttr) Reset()

func (*ServiceAttr) Size

func (m *ServiceAttr) Size() (n int)

func (*ServiceAttr) String

func (this *ServiceAttr) String() string

func (*ServiceAttr) Unmarshal

func (m *ServiceAttr) Unmarshal(dAtA []byte) error

func (*ServiceAttr) UnmarshalPath

func (a *ServiceAttr) UnmarshalPath(data []byte) error

func (*ServiceAttr) VerboseEqual

func (this *ServiceAttr) VerboseEqual(that interface{}) error

type ServiceEventType

type ServiceEventType int32

//////////////////////////////////////// service url event type ////////////////////////////////////////

const (
	SET_UNKNOWN   ServiceEventType = 0
	ServiceAdd    ServiceEventType = 1
	ServiceDel    ServiceEventType = 2
	ServiceUpdate ServiceEventType = 3
)

func (ServiceEventType) EnumDescriptor

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

func (ServiceEventType) String

func (x ServiceEventType) String() string

type ServiceMeta added in v0.3.1

type ServiceMeta func(*Service)

func WithServiceMeta added in v0.3.1

func WithServiceMeta(key, value string) ServiceMeta

type ServiceRoleType

type ServiceRoleType int32

//////////////////////////////////////// service role ////////////////////////////////////////

const (
	SRT_UNKOWN   ServiceRoleType = 0
	SRT_Provider ServiceRoleType = 1
	SRT_Consumer ServiceRoleType = 2
)

func String2ServiceRoleType

func String2ServiceRoleType(role string) ServiceRoleType

func (ServiceRoleType) EnumDescriptor

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

func (ServiceRoleType) String

func (x ServiceRoleType) String() string

type WatchOption

type WatchOption func(*WatchOptions)

func WithWatchFilter

func WithWatchFilter(filter ServiceAttr) WatchOption

Watch ServiceAttr Filter

func WithWatchRoot

func WithWatchRoot(root string) WatchOption

Watch root

type WatchOptions

type WatchOptions struct {
	// the root registry path, such as "/dubbo/"
	Root string
	// filter the second path, such as
	// "/test/group%3Dbjtelecom%26protocol%3Dpb%26role%3DSRT_Provider%26service%3Dshopping%26version%3D1.0.1"
	Filter ServiceAttr
}

type Watcher

type Watcher interface {
	Notify() (*EventResult, error)
	Valid() bool // 检查watcher与registry连接是否正常
	Close()
	IsClosed() bool
}

Watcher provides an interface for service discovery

Directories

Path Synopsis
Package gxetcd provides an etcd version 3 gxregistry
Package gxetcd provides an etcd version 3 gxregistry
Package gxzookeeper provides a zookeeper registry
Package gxzookeeper provides a zookeeper registry

Jump to

Keyboard shortcuts

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