in-memory service registry (#1892)

This commit is contained in:
wasaga 2021-02-17 14:28:54 -05:00 committed by GitHub
parent ee28f008b5
commit d04416a5fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 2081 additions and 1 deletions

View file

@ -0,0 +1,845 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.14.0
// source: registry.proto
package registry
import (
context "context"
_ "github.com/envoyproxy/protoc-gen-validate/validate"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
anypb "google.golang.org/protobuf/types/known/anypb"
durationpb "google.golang.org/protobuf/types/known/durationpb"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type ServiceKind int32
const (
ServiceKind_UNDEFINED_DO_NOT_USE ServiceKind = 0
// databroker grpc service
ServiceKind_DATABROKER ServiceKind = 1
// authorize grpc service
ServiceKind_AUTHORIZE ServiceKind = 2
// authentication http(s) service
ServiceKind_AUTHENTICATE ServiceKind = 3
// proxy service
ServiceKind_PROXY ServiceKind = 4
// registry service
ServiceKind_REGISTRY ServiceKind = 5
// console grpc service
ServiceKind_CONSOLE ServiceKind = 6
// prometheus metrics compatible http endpoint
ServiceKind_PROMETHEUS_METRICS ServiceKind = 7
)
// Enum value maps for ServiceKind.
var (
ServiceKind_name = map[int32]string{
0: "UNDEFINED_DO_NOT_USE",
1: "DATABROKER",
2: "AUTHORIZE",
3: "AUTHENTICATE",
4: "PROXY",
5: "REGISTRY",
6: "CONSOLE",
7: "PROMETHEUS_METRICS",
}
ServiceKind_value = map[string]int32{
"UNDEFINED_DO_NOT_USE": 0,
"DATABROKER": 1,
"AUTHORIZE": 2,
"AUTHENTICATE": 3,
"PROXY": 4,
"REGISTRY": 5,
"CONSOLE": 6,
"PROMETHEUS_METRICS": 7,
}
)
func (x ServiceKind) Enum() *ServiceKind {
p := new(ServiceKind)
*p = x
return p
}
func (x ServiceKind) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (ServiceKind) Descriptor() protoreflect.EnumDescriptor {
return file_registry_proto_enumTypes[0].Descriptor()
}
func (ServiceKind) Type() protoreflect.EnumType {
return &file_registry_proto_enumTypes[0]
}
func (x ServiceKind) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use ServiceKind.Descriptor instead.
func (ServiceKind) EnumDescriptor() ([]byte, []int) {
return file_registry_proto_rawDescGZIP(), []int{0}
}
type Service struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// kind is service kind
Kind ServiceKind `protobuf:"varint,1,opt,name=kind,proto3,enum=registry.ServiceKind" json:"kind,omitempty"`
// network endpoints this service may be reachable at
Endpoint string `protobuf:"bytes,3,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
}
func (x *Service) Reset() {
*x = Service{}
if protoimpl.UnsafeEnabled {
mi := &file_registry_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Service) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Service) ProtoMessage() {}
func (x *Service) ProtoReflect() protoreflect.Message {
mi := &file_registry_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Service.ProtoReflect.Descriptor instead.
func (*Service) Descriptor() ([]byte, []int) {
return file_registry_proto_rawDescGZIP(), []int{0}
}
func (x *Service) GetKind() ServiceKind {
if x != nil {
return x.Kind
}
return ServiceKind_UNDEFINED_DO_NOT_USE
}
func (x *Service) GetEndpoint() string {
if x != nil {
return x.Endpoint
}
return ""
}
type RegisterRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// services this deployment runs
Services []*Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"`
// service may optionally provide certain metadata, such as
// - build version
// - startup time
// - bootstrap configuration
// - OS, OS version, OS hostname
// - etc
// this information is not distributed back to the inquiring nodes
// and may also have a different storage and time to live
Metadata map[string]*anypb.Any `protobuf:"bytes,2,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *RegisterRequest) Reset() {
*x = RegisterRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_registry_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RegisterRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegisterRequest) ProtoMessage() {}
func (x *RegisterRequest) ProtoReflect() protoreflect.Message {
mi := &file_registry_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead.
func (*RegisterRequest) Descriptor() ([]byte, []int) {
return file_registry_proto_rawDescGZIP(), []int{1}
}
func (x *RegisterRequest) GetServices() []*Service {
if x != nil {
return x.Services
}
return nil
}
func (x *RegisterRequest) GetMetadata() map[string]*anypb.Any {
if x != nil {
return x.Metadata
}
return nil
}
type RegisterResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// indicates when to report back again
CallBackAfter *durationpb.Duration `protobuf:"bytes,2,opt,name=call_back_after,json=callBackAfter,proto3" json:"call_back_after,omitempty"`
}
func (x *RegisterResponse) Reset() {
*x = RegisterResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_registry_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RegisterResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegisterResponse) ProtoMessage() {}
func (x *RegisterResponse) ProtoReflect() protoreflect.Message {
mi := &file_registry_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead.
func (*RegisterResponse) Descriptor() ([]byte, []int) {
return file_registry_proto_rawDescGZIP(), []int{2}
}
func (x *RegisterResponse) GetCallBackAfter() *durationpb.Duration {
if x != nil {
return x.CallBackAfter
}
return nil
}
type ListRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Kinds []ServiceKind `protobuf:"varint,1,rep,packed,name=kinds,proto3,enum=registry.ServiceKind" json:"kinds,omitempty"`
}
func (x *ListRequest) Reset() {
*x = ListRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_registry_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListRequest) ProtoMessage() {}
func (x *ListRequest) ProtoReflect() protoreflect.Message {
mi := &file_registry_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListRequest.ProtoReflect.Descriptor instead.
func (*ListRequest) Descriptor() ([]byte, []int) {
return file_registry_proto_rawDescGZIP(), []int{3}
}
func (x *ListRequest) GetKinds() []ServiceKind {
if x != nil {
return x.Kinds
}
return nil
}
type ServiceRegistration struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
}
func (x *ServiceRegistration) Reset() {
*x = ServiceRegistration{}
if protoimpl.UnsafeEnabled {
mi := &file_registry_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ServiceRegistration) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ServiceRegistration) ProtoMessage() {}
func (x *ServiceRegistration) ProtoReflect() protoreflect.Message {
mi := &file_registry_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ServiceRegistration.ProtoReflect.Descriptor instead.
func (*ServiceRegistration) Descriptor() ([]byte, []int) {
return file_registry_proto_rawDescGZIP(), []int{4}
}
func (x *ServiceRegistration) GetService() *Service {
if x != nil {
return x.Service
}
return nil
}
func (x *ServiceRegistration) GetExpiresAt() *timestamppb.Timestamp {
if x != nil {
return x.ExpiresAt
}
return nil
}
// RegistrationSnapshot represents the current state of the services
type ServiceList struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Services []*Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"`
}
func (x *ServiceList) Reset() {
*x = ServiceList{}
if protoimpl.UnsafeEnabled {
mi := &file_registry_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ServiceList) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ServiceList) ProtoMessage() {}
func (x *ServiceList) ProtoReflect() protoreflect.Message {
mi := &file_registry_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ServiceList.ProtoReflect.Descriptor instead.
func (*ServiceList) Descriptor() ([]byte, []int) {
return file_registry_proto_rawDescGZIP(), []int{5}
}
func (x *ServiceList) GetServices() []*Service {
if x != nil {
return x.Services
}
return nil
}
var File_registry_proto protoreflect.FileDescriptor
var file_registry_proto_rawDesc = []byte{
0x0a, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65,
0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65,
0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0x64, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x04, 0x6b, 0x69,
0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73,
0x74, 0x72, 0x79, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4b, 0x69, 0x6e, 0x64, 0x42,
0x08, 0xfa, 0x42, 0x05, 0x82, 0x01, 0x02, 0x20, 0x00, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12,
0x24, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x72, 0x03, 0x88, 0x01, 0x01, 0x52, 0x08, 0x65, 0x6e, 0x64,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0xe2, 0x01, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74,
0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x08, 0x73, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x72, 0x65,
0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x08,
0xfa, 0x42, 0x05, 0x92, 0x01, 0x02, 0x08, 0x01, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x73, 0x12, 0x43, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e,
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e,
0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d,
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x51, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2a, 0x0a, 0x05, 0x76, 0x61,
0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x55, 0x0a, 0x10, 0x52, 0x65,
0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41,
0x0a, 0x0f, 0x63, 0x61, 0x6c, 0x6c, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x61, 0x66, 0x74, 0x65,
0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x52, 0x0d, 0x63, 0x61, 0x6c, 0x6c, 0x42, 0x61, 0x63, 0x6b, 0x41, 0x66, 0x74, 0x65,
0x72, 0x22, 0x3a, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x2b, 0x0a, 0x05, 0x6b, 0x69, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32,
0x15, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x05, 0x6b, 0x69, 0x6e, 0x64, 0x73, 0x22, 0x7d, 0x0a,
0x13, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79,
0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x12, 0x39, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x5f, 0x61, 0x74, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
0x70, 0x52, 0x09, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x22, 0x3c, 0x0a, 0x0b,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x08, 0x73,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e,
0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2a, 0x96, 0x01, 0x0a, 0x0b, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e,
0x44, 0x45, 0x46, 0x49, 0x4e, 0x45, 0x44, 0x5f, 0x44, 0x4f, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x55,
0x53, 0x45, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x41, 0x54, 0x41, 0x42, 0x52, 0x4f, 0x4b,
0x45, 0x52, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x5a,
0x45, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x41, 0x55, 0x54, 0x48, 0x45, 0x4e, 0x54, 0x49, 0x43,
0x41, 0x54, 0x45, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x52, 0x4f, 0x58, 0x59, 0x10, 0x04,
0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, 0x59, 0x10, 0x05, 0x12, 0x0b,
0x0a, 0x07, 0x43, 0x4f, 0x4e, 0x53, 0x4f, 0x4c, 0x45, 0x10, 0x06, 0x12, 0x16, 0x0a, 0x12, 0x50,
0x52, 0x4f, 0x4d, 0x45, 0x54, 0x48, 0x45, 0x55, 0x53, 0x5f, 0x4d, 0x45, 0x54, 0x52, 0x49, 0x43,
0x53, 0x10, 0x07, 0x32, 0xba, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79,
0x12, 0x3f, 0x0a, 0x06, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x19, 0x2e, 0x72, 0x65, 0x67,
0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79,
0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x34, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x15, 0x2e, 0x72, 0x65, 0x67, 0x69,
0x73, 0x74, 0x72, 0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x15, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x05, 0x57, 0x61, 0x74, 0x63, 0x68,
0x12, 0x15, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74,
0x72, 0x79, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x30, 0x01,
0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x3b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_registry_proto_rawDescOnce sync.Once
file_registry_proto_rawDescData = file_registry_proto_rawDesc
)
func file_registry_proto_rawDescGZIP() []byte {
file_registry_proto_rawDescOnce.Do(func() {
file_registry_proto_rawDescData = protoimpl.X.CompressGZIP(file_registry_proto_rawDescData)
})
return file_registry_proto_rawDescData
}
var file_registry_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_registry_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_registry_proto_goTypes = []interface{}{
(ServiceKind)(0), // 0: registry.ServiceKind
(*Service)(nil), // 1: registry.Service
(*RegisterRequest)(nil), // 2: registry.RegisterRequest
(*RegisterResponse)(nil), // 3: registry.RegisterResponse
(*ListRequest)(nil), // 4: registry.ListRequest
(*ServiceRegistration)(nil), // 5: registry.ServiceRegistration
(*ServiceList)(nil), // 6: registry.ServiceList
nil, // 7: registry.RegisterRequest.MetadataEntry
(*durationpb.Duration)(nil), // 8: google.protobuf.Duration
(*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp
(*anypb.Any)(nil), // 10: google.protobuf.Any
}
var file_registry_proto_depIdxs = []int32{
0, // 0: registry.Service.kind:type_name -> registry.ServiceKind
1, // 1: registry.RegisterRequest.services:type_name -> registry.Service
7, // 2: registry.RegisterRequest.metadata:type_name -> registry.RegisterRequest.MetadataEntry
8, // 3: registry.RegisterResponse.call_back_after:type_name -> google.protobuf.Duration
0, // 4: registry.ListRequest.kinds:type_name -> registry.ServiceKind
1, // 5: registry.ServiceRegistration.service:type_name -> registry.Service
9, // 6: registry.ServiceRegistration.expires_at:type_name -> google.protobuf.Timestamp
1, // 7: registry.ServiceList.services:type_name -> registry.Service
10, // 8: registry.RegisterRequest.MetadataEntry.value:type_name -> google.protobuf.Any
2, // 9: registry.Registry.Report:input_type -> registry.RegisterRequest
4, // 10: registry.Registry.List:input_type -> registry.ListRequest
4, // 11: registry.Registry.Watch:input_type -> registry.ListRequest
3, // 12: registry.Registry.Report:output_type -> registry.RegisterResponse
6, // 13: registry.Registry.List:output_type -> registry.ServiceList
6, // 14: registry.Registry.Watch:output_type -> registry.ServiceList
12, // [12:15] is the sub-list for method output_type
9, // [9:12] is the sub-list for method input_type
9, // [9:9] is the sub-list for extension type_name
9, // [9:9] is the sub-list for extension extendee
0, // [0:9] is the sub-list for field type_name
}
func init() { file_registry_proto_init() }
func file_registry_proto_init() {
if File_registry_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_registry_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Service); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_registry_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RegisterRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_registry_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RegisterResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_registry_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_registry_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ServiceRegistration); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_registry_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ServiceList); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_registry_proto_rawDesc,
NumEnums: 1,
NumMessages: 7,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_registry_proto_goTypes,
DependencyIndexes: file_registry_proto_depIdxs,
EnumInfos: file_registry_proto_enumTypes,
MessageInfos: file_registry_proto_msgTypes,
}.Build()
File_registry_proto = out.File
file_registry_proto_rawDesc = nil
file_registry_proto_goTypes = nil
file_registry_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// RegistryClient is the client API for Registry service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type RegistryClient interface {
// Report is periodically sent by each service to confirm it is still serving with the registry
// data is persisted with a certain TTL
Report(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error)
// List returns current snapshot of the services known to the registry
List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ServiceList, error)
// Watch returns a stream of updates
// for the simplicity of consumer its delivered as full snapshots
// and is only sent when change is detected
Watch(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (Registry_WatchClient, error)
}
type registryClient struct {
cc grpc.ClientConnInterface
}
func NewRegistryClient(cc grpc.ClientConnInterface) RegistryClient {
return &registryClient{cc}
}
func (c *registryClient) Report(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) {
out := new(RegisterResponse)
err := c.cc.Invoke(ctx, "/registry.Registry/Report", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *registryClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ServiceList, error) {
out := new(ServiceList)
err := c.cc.Invoke(ctx, "/registry.Registry/List", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *registryClient) Watch(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (Registry_WatchClient, error) {
stream, err := c.cc.NewStream(ctx, &_Registry_serviceDesc.Streams[0], "/registry.Registry/Watch", opts...)
if err != nil {
return nil, err
}
x := &registryWatchClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type Registry_WatchClient interface {
Recv() (*ServiceList, error)
grpc.ClientStream
}
type registryWatchClient struct {
grpc.ClientStream
}
func (x *registryWatchClient) Recv() (*ServiceList, error) {
m := new(ServiceList)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// RegistryServer is the server API for Registry service.
type RegistryServer interface {
// Report is periodically sent by each service to confirm it is still serving with the registry
// data is persisted with a certain TTL
Report(context.Context, *RegisterRequest) (*RegisterResponse, error)
// List returns current snapshot of the services known to the registry
List(context.Context, *ListRequest) (*ServiceList, error)
// Watch returns a stream of updates
// for the simplicity of consumer its delivered as full snapshots
// and is only sent when change is detected
Watch(*ListRequest, Registry_WatchServer) error
}
// UnimplementedRegistryServer can be embedded to have forward compatible implementations.
type UnimplementedRegistryServer struct {
}
func (*UnimplementedRegistryServer) Report(context.Context, *RegisterRequest) (*RegisterResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Report not implemented")
}
func (*UnimplementedRegistryServer) List(context.Context, *ListRequest) (*ServiceList, error) {
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
}
func (*UnimplementedRegistryServer) Watch(*ListRequest, Registry_WatchServer) error {
return status.Errorf(codes.Unimplemented, "method Watch not implemented")
}
func RegisterRegistryServer(s *grpc.Server, srv RegistryServer) {
s.RegisterService(&_Registry_serviceDesc, srv)
}
func _Registry_Report_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RegisterRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RegistryServer).Report(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/registry.Registry/Report",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RegistryServer).Report(ctx, req.(*RegisterRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Registry_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RegistryServer).List(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/registry.Registry/List",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RegistryServer).List(ctx, req.(*ListRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Registry_Watch_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(ListRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(RegistryServer).Watch(m, &registryWatchServer{stream})
}
type Registry_WatchServer interface {
Send(*ServiceList) error
grpc.ServerStream
}
type registryWatchServer struct {
grpc.ServerStream
}
func (x *registryWatchServer) Send(m *ServiceList) error {
return x.ServerStream.SendMsg(m)
}
var _Registry_serviceDesc = grpc.ServiceDesc{
ServiceName: "registry.Registry",
HandlerType: (*RegistryServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Report",
Handler: _Registry_Report_Handler,
},
{
MethodName: "List",
Handler: _Registry_List_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "Watch",
Handler: _Registry_Watch_Handler,
ServerStreams: true,
},
},
Metadata: "registry.proto",
}

View file

@ -0,0 +1,536 @@
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: registry.proto
package registry
import (
"bytes"
"errors"
"fmt"
"net"
"net/mail"
"net/url"
"regexp"
"strings"
"time"
"unicode/utf8"
"github.com/golang/protobuf/ptypes"
)
// ensure the imports are used
var (
_ = bytes.MinRead
_ = errors.New("")
_ = fmt.Print
_ = utf8.UTFMax
_ = (*regexp.Regexp)(nil)
_ = (*strings.Reader)(nil)
_ = net.IPv4len
_ = time.Duration(0)
_ = (*url.URL)(nil)
_ = (*mail.Address)(nil)
_ = ptypes.DynamicAny{}
)
// define the regex for a UUID once up-front
var _registry_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
// Validate checks the field values on Service with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned.
func (m *Service) Validate() error {
if m == nil {
return nil
}
if _, ok := _Service_Kind_NotInLookup[m.GetKind()]; ok {
return ServiceValidationError{
field: "Kind",
reason: "value must not be in list [0]",
}
}
if uri, err := url.Parse(m.GetEndpoint()); err != nil {
return ServiceValidationError{
field: "Endpoint",
reason: "value must be a valid URI",
cause: err,
}
} else if !uri.IsAbs() {
return ServiceValidationError{
field: "Endpoint",
reason: "value must be absolute",
}
}
return nil
}
// ServiceValidationError is the validation error returned by Service.Validate
// if the designated constraints aren't met.
type ServiceValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e ServiceValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e ServiceValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e ServiceValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e ServiceValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e ServiceValidationError) ErrorName() string { return "ServiceValidationError" }
// Error satisfies the builtin error interface
func (e ServiceValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sService.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = ServiceValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = ServiceValidationError{}
var _Service_Kind_NotInLookup = map[ServiceKind]struct{}{
0: {},
}
// Validate checks the field values on RegisterRequest with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned.
func (m *RegisterRequest) Validate() error {
if m == nil {
return nil
}
if len(m.GetServices()) < 1 {
return RegisterRequestValidationError{
field: "Services",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetServices() {
_, _ = idx, item
if v, ok := interface{}(item).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RegisterRequestValidationError{
field: fmt.Sprintf("Services[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
for key, val := range m.GetMetadata() {
_ = val
// no validation rules for Metadata[key]
if v, ok := interface{}(val).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RegisterRequestValidationError{
field: fmt.Sprintf("Metadata[%v]", key),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
}
// RegisterRequestValidationError is the validation error returned by
// RegisterRequest.Validate if the designated constraints aren't met.
type RegisterRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e RegisterRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e RegisterRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e RegisterRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e RegisterRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e RegisterRequestValidationError) ErrorName() string { return "RegisterRequestValidationError" }
// Error satisfies the builtin error interface
func (e RegisterRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sRegisterRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = RegisterRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = RegisterRequestValidationError{}
// Validate checks the field values on RegisterResponse with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned.
func (m *RegisterResponse) Validate() error {
if m == nil {
return nil
}
if v, ok := interface{}(m.GetCallBackAfter()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RegisterResponseValidationError{
field: "CallBackAfter",
reason: "embedded message failed validation",
cause: err,
}
}
}
return nil
}
// RegisterResponseValidationError is the validation error returned by
// RegisterResponse.Validate if the designated constraints aren't met.
type RegisterResponseValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e RegisterResponseValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e RegisterResponseValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e RegisterResponseValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e RegisterResponseValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e RegisterResponseValidationError) ErrorName() string { return "RegisterResponseValidationError" }
// Error satisfies the builtin error interface
func (e RegisterResponseValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sRegisterResponse.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = RegisterResponseValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = RegisterResponseValidationError{}
// Validate checks the field values on ListRequest with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned.
func (m *ListRequest) Validate() error {
if m == nil {
return nil
}
return nil
}
// ListRequestValidationError is the validation error returned by
// ListRequest.Validate if the designated constraints aren't met.
type ListRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e ListRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e ListRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e ListRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e ListRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e ListRequestValidationError) ErrorName() string { return "ListRequestValidationError" }
// Error satisfies the builtin error interface
func (e ListRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sListRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = ListRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = ListRequestValidationError{}
// Validate checks the field values on ServiceRegistration with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned.
func (m *ServiceRegistration) Validate() error {
if m == nil {
return nil
}
if v, ok := interface{}(m.GetService()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ServiceRegistrationValidationError{
field: "Service",
reason: "embedded message failed validation",
cause: err,
}
}
}
if v, ok := interface{}(m.GetExpiresAt()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ServiceRegistrationValidationError{
field: "ExpiresAt",
reason: "embedded message failed validation",
cause: err,
}
}
}
return nil
}
// ServiceRegistrationValidationError is the validation error returned by
// ServiceRegistration.Validate if the designated constraints aren't met.
type ServiceRegistrationValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e ServiceRegistrationValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e ServiceRegistrationValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e ServiceRegistrationValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e ServiceRegistrationValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e ServiceRegistrationValidationError) ErrorName() string {
return "ServiceRegistrationValidationError"
}
// Error satisfies the builtin error interface
func (e ServiceRegistrationValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sServiceRegistration.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = ServiceRegistrationValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = ServiceRegistrationValidationError{}
// Validate checks the field values on ServiceList with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned.
func (m *ServiceList) Validate() error {
if m == nil {
return nil
}
for idx, item := range m.GetServices() {
_, _ = idx, item
if v, ok := interface{}(item).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ServiceListValidationError{
field: fmt.Sprintf("Services[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
}
// ServiceListValidationError is the validation error returned by
// ServiceList.Validate if the designated constraints aren't met.
type ServiceListValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e ServiceListValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e ServiceListValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e ServiceListValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e ServiceListValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e ServiceListValidationError) ErrorName() string { return "ServiceListValidationError" }
// Error satisfies the builtin error interface
func (e ServiceListValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sServiceList.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = ServiceListValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = ServiceListValidationError{}

View file

@ -0,0 +1,82 @@
syntax = "proto3";
package registry;
option go_package = ".;registry";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/any.proto";
import "validate/validate.proto";
enum ServiceKind {
UNDEFINED_DO_NOT_USE = 0;
// databroker grpc service
DATABROKER = 1;
// authorize grpc service
AUTHORIZE = 2;
// authentication http(s) service
AUTHENTICATE = 3;
// proxy service
PROXY = 4;
// registry service
REGISTRY = 5;
// console grpc service
CONSOLE = 6;
// prometheus metrics compatible http endpoint
PROMETHEUS_METRICS = 7;
}
message Service {
// kind is service kind
ServiceKind kind = 1 [(validate.rules).enum = {not_in: [0]}];
// network endpoints this service may be reachable at
string endpoint = 3 [(validate.rules).string.uri = true];
}
message RegisterRequest {
// services this deployment runs
repeated Service services = 1 [(validate.rules).repeated.min_items = 1];
// service may optionally provide certain metadata, such as
// - build version
// - startup time
// - bootstrap configuration
// - OS, OS version, OS hostname
// - etc
// this information is not distributed back to the inquiring nodes
// and may also have a different storage and time to live
map <string, google.protobuf.Any> metadata = 2;
}
message RegisterResponse {
// indicates when to report back again
google.protobuf.Duration call_back_after = 2;
}
message ListRequest {
repeated ServiceKind kinds = 1;
}
message ServiceRegistration {
Service service = 1;
google.protobuf.Timestamp expires_at = 2;
}
// RegistrationSnapshot represents the current state of the services
message ServiceList {
repeated Service services = 1;
}
// Registry is invoked by services to inform
service Registry {
// Report is periodically sent by each service to confirm it is still serving with the registry
// data is persisted with a certain TTL
rpc Report(RegisterRequest) returns (RegisterResponse);
// List returns current snapshot of the services known to the registry
rpc List(ListRequest) returns (ServiceList);
// Watch returns a stream of updates
// for the simplicity of consumer its delivered as full snapshots
// and is only sent when change is detected
rpc Watch(ListRequest) returns (stream ServiceList);
}