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

@ -79,6 +79,11 @@ func IsDataBroker(s string) bool {
return false
}
// IsRegistry checks if this node should run the registry service
func IsRegistry(s string) bool {
return IsDataBroker(s)
}
// IsAll checks to see if we should be running all services
func IsAll(s string) bool {
return s == ServiceAll

1
go.mod
View file

@ -13,6 +13,7 @@ require (
github.com/cespare/xxhash/v2 v2.1.1
github.com/coreos/go-oidc/v3 v3.0.0
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad
github.com/envoyproxy/protoc-gen-validate v0.1.0
github.com/fsnotify/fsnotify v1.4.9
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-redis/redis/v8 v8.5.0

View file

@ -0,0 +1,7 @@
package pomerium
import "time"
const (
registryTTL = time.Minute
)

View file

@ -23,8 +23,10 @@ import (
"github.com/pomerium/pomerium/internal/databroker"
"github.com/pomerium/pomerium/internal/envoy"
"github.com/pomerium/pomerium/internal/log"
"github.com/pomerium/pomerium/internal/registry"
"github.com/pomerium/pomerium/internal/urlutil"
"github.com/pomerium/pomerium/internal/version"
registry_pb "github.com/pomerium/pomerium/pkg/grpc/registry"
"github.com/pomerium/pomerium/proxy"
)
@ -102,8 +104,16 @@ func Run(ctx context.Context, configFile string) error {
if config.IsDataBroker(src.GetConfig().Options.Services) {
dataBrokerServer, err = setupDataBroker(src, controlPlane)
if err != nil {
return err
return fmt.Errorf("setting up databroker: %w", err)
}
if err = setupRegistryServer(src, controlPlane); err != nil {
return fmt.Errorf("setting up registry: %w", err)
}
}
if err = setupRegistryReporter(src); err != nil {
return fmt.Errorf("setting up registry reporter: %w", err)
}
if err := setupProxy(src, controlPlane); err != nil {
return err
@ -199,6 +209,20 @@ func setupDataBroker(src config.Source, controlPlane *controlplane.Server) (*dat
return svc, nil
}
func setupRegistryServer(src config.Source, controlPlane *controlplane.Server) error {
svc := registry.NewInMemoryServer(context.TODO(), registryTTL)
registry_pb.RegisterRegistryServer(controlPlane.GRPCServer, svc)
log.Info().Msg("enabled service discovery")
return nil
}
func setupRegistryReporter(src config.Source) error {
reporter := new(registry.Reporter)
src.OnConfigChange(reporter.OnConfigChange)
reporter.OnConfigChange(src.GetConfig())
return nil
}
func setupProxy(src config.Source, controlPlane *controlplane.Server) error {
if !config.IsProxy(src.GetConfig().Options.Services) {
return nil

View file

@ -0,0 +1,22 @@
package registry
import (
"errors"
"time"
)
const (
// callAfterTTLFactor will request to report back again after TTL/callAfterTTLFactor time
callAfterTTLFactor = 2
// purgeAfterTTLFactor will purge keys with TTL * purgeAfterTTLFactor time
purgeAfterTTLFactor = 1
// min reporting ttl
minTTL = time.Second
// path metrics are available at
defaultMetricsPath = "/metrics"
)
var (
errNoMetricsAddr = errors.New("no metrics address provided")
errNoMetricsPort = errors.New("no metrics port provided")
)

View file

@ -0,0 +1,201 @@
package registry
import (
"context"
"sync"
"time"
"github.com/pomerium/pomerium/internal/signal"
pb "github.com/pomerium/pomerium/pkg/grpc/registry"
"github.com/golang/protobuf/ptypes"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
)
type inMemoryServer struct {
ttl time.Duration
// onchange is used to broadcast changes to listeners
onchange *signal.Signal
// mu holds lock for regs
mu sync.RWMutex
// regs is {service,endpoint} -> expiration time mapping
regs map[inMemoryKey]*timestamppb.Timestamp
}
type inMemoryKey struct {
kind pb.ServiceKind
endpoint string
}
// NewInMemoryServer constructs a new registry tracking service that operates in RAM
// as such, it is not usable for multi-node deployment where REDIS or other alternative should be used
func NewInMemoryServer(ctx context.Context, ttl time.Duration) pb.RegistryServer {
srv := &inMemoryServer{
ttl: ttl,
regs: make(map[inMemoryKey]*timestamppb.Timestamp),
onchange: signal.New(),
}
go srv.periodicCheck(ctx)
return srv
}
func (s *inMemoryServer) periodicCheck(ctx context.Context) {
after := s.ttl * purgeAfterTTLFactor
for {
select {
case <-ctx.Done():
return
case <-time.After(after):
if s.lockAndRmExpired() {
s.onchange.Broadcast()
}
}
}
}
// Report is periodically sent by each service to confirm it is still serving with the registry
// data is persisted with a certain TTL
func (s *inMemoryServer) Report(ctx context.Context, req *pb.RegisterRequest) (*pb.RegisterResponse, error) {
if err := req.Validate(); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
updated, err := s.lockAndReport(req.Services)
if err != nil {
return nil, err
}
if updated {
s.onchange.Broadcast()
}
return &pb.RegisterResponse{
CallBackAfter: durationpb.New(s.ttl / callAfterTTLFactor),
}, nil
}
func (s *inMemoryServer) lockAndRmExpired() bool {
s.mu.Lock()
defer s.mu.Unlock()
return s.rmExpiredLocked()
}
func (s *inMemoryServer) rmExpiredLocked() bool {
now := time.Now()
removed := false
for k, expires := range s.regs {
if expires.AsTime().Before(now) {
delete(s.regs, k)
removed = true
}
}
return removed
}
// lockAndReport acquires lock, performs an update and returns current state of services
func (s *inMemoryServer) lockAndReport(services []*pb.Service) (bool, error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.reportLocked(services)
}
// reportLocked updates registration and also returns an indication whether service list was updated
func (s *inMemoryServer) reportLocked(services []*pb.Service) (bool, error) {
expires, err := ptypes.TimestampProto(time.Now().Add(s.ttl))
if err != nil {
return false, err
}
inserted := false
for _, svc := range services {
k := inMemoryKey{kind: svc.Kind, endpoint: svc.Endpoint}
if _, present := s.regs[k]; !present {
inserted = true
}
s.regs[k] = expires
}
removed := s.rmExpiredLocked()
return inserted || removed, nil
}
// List returns current snapshot of the services known to the registry
func (s *inMemoryServer) List(ctx context.Context, req *pb.ListRequest) (*pb.ServiceList, error) {
if err := req.Validate(); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
return &pb.ServiceList{Services: s.getServices(kindsMap(req.Kinds))}, nil
}
func kindsMap(kinds []pb.ServiceKind) map[pb.ServiceKind]bool {
out := make(map[pb.ServiceKind]bool, len(kinds))
for _, k := range kinds {
out[k] = true
}
return out
}
// Watch returns a stream of updates as full snapshots
func (s *inMemoryServer) Watch(req *pb.ListRequest, srv pb.Registry_WatchServer) error {
if err := req.Validate(); err != nil {
return status.Error(codes.InvalidArgument, err.Error())
}
kinds := kindsMap(req.Kinds)
ctx := srv.Context()
updates := s.onchange.Bind()
defer s.onchange.Unbind(updates)
if err := srv.Send(&pb.ServiceList{Services: s.getServices(kinds)}); err != nil {
return status.Errorf(codes.Internal, "sending initial snapshot: %v", err)
}
for {
services, err := s.getServiceUpdates(ctx, kinds, updates)
if err != nil {
return status.Errorf(codes.Internal, "obtaining service registrations: %v", err)
}
if err := srv.Send(&pb.ServiceList{Services: services}); err != nil {
return status.Errorf(codes.Internal, "sending registration snapshot: %v", err)
}
}
}
func (s *inMemoryServer) getServiceUpdates(ctx context.Context, kinds map[pb.ServiceKind]bool, updates chan struct{}) ([]*pb.Service, error) {
select {
case <-ctx.Done():
return nil, ctx.Err()
case <-updates:
return s.getServices(kinds), nil
}
}
func (s *inMemoryServer) getServices(kinds map[pb.ServiceKind]bool) []*pb.Service {
s.mu.RLock()
defer s.mu.RUnlock()
return s.getServicesLocked(kinds)
}
func (s *inMemoryServer) getServicesLocked(kinds map[pb.ServiceKind]bool) []*pb.Service {
out := make([]*pb.Service, 0, len(s.regs))
for k := range s.regs {
if len(kinds) == 0 {
// all catch empty filter
} else if _, exists := kinds[k.kind]; !exists {
continue
}
out = append(out, &pb.Service{Kind: k.kind, Endpoint: k.endpoint})
}
return out
}

View file

@ -0,0 +1,130 @@
package registry
import (
"context"
"encoding/base64"
"fmt"
"net"
"net/url"
"os"
"time"
"github.com/pomerium/pomerium/config"
"github.com/pomerium/pomerium/internal/log"
"github.com/pomerium/pomerium/pkg/grpc"
pb "github.com/pomerium/pomerium/pkg/grpc/registry"
"github.com/cenkalti/backoff/v4"
)
// Reporter periodically submits a list of services available on this instance to the service registry
type Reporter struct {
cancel func()
}
// OnConfigChange applies configuration changes to the reporter
func (r *Reporter) OnConfigChange(cfg *config.Config) {
if r.cancel != nil {
r.cancel()
}
services, err := getReportedServices(cfg)
if err != nil {
log.Error().Err(err).Msg("applying config")
return
}
sharedKey, err := base64.StdEncoding.DecodeString(cfg.Options.SharedKey)
if err != nil {
log.Error().Err(err).Msg("decoding shared key")
return
}
registryConn, err := grpc.GetGRPCClientConn("databroker", &grpc.Options{
Addr: cfg.Options.DataBrokerURL,
OverrideCertificateName: cfg.Options.OverrideCertificateName,
CA: cfg.Options.CA,
CAFile: cfg.Options.CAFile,
RequestTimeout: cfg.Options.GRPCClientTimeout,
ClientDNSRoundRobin: cfg.Options.GRPCClientDNSRoundRobin,
WithInsecure: cfg.Options.GRPCInsecure,
ServiceName: cfg.Options.Services,
SignedJWTKey: sharedKey,
})
if err != nil {
log.Error().Err(err).Msg("connecting to registry")
return
}
ctx, cancel := context.WithCancel(context.TODO())
go runReporter(ctx, pb.NewRegistryClient(registryConn), services)
r.cancel = cancel
}
func getReportedServices(cfg *config.Config) ([]*pb.Service, error) {
mu, err := metricsURL(cfg.Options.MetricsAddr)
if err != nil {
return nil, err
}
return []*pb.Service{
{Kind: pb.ServiceKind_PROMETHEUS_METRICS, Endpoint: mu.String()},
}, nil
}
func metricsURL(addr string) (*url.URL, error) {
if addr == "" {
return nil, errNoMetricsAddr
}
host, port, err := net.SplitHostPort(addr)
if err != nil {
return nil, fmt.Errorf("invalid metrics address: %w", err)
}
if port == "" {
return nil, errNoMetricsPort
}
if host == "" {
host, err = os.Hostname()
if err != nil {
return nil, fmt.Errorf("metrics address is missing hostname, error obtaining it from OS: %w", err)
}
}
return &url.URL{
// TODO: TLS selector https://github.com/pomerium/internal/issues/272
Scheme: "http",
Path: defaultMetricsPath,
Host: net.JoinHostPort(host, port),
}, nil
}
func runReporter(
ctx context.Context,
client pb.RegistryClient,
services []*pb.Service,
) {
backoff := backoff.NewExponentialBackOff()
backoff.MaxElapsedTime = 0
req := &pb.RegisterRequest{Services: services}
after := minTTL
for {
select {
case <-time.After(after):
resp, err := client.Report(ctx, req)
if err != nil {
log.Ctx(ctx).Error().Err(err).Msg("grpc.service_registry.Report")
after = backoff.NextBackOff()
continue
}
after = resp.CallBackAfter.AsDuration()
backoff.Reset()
case <-ctx.Done():
log.Info().Msg("service registry reporter stopping")
return
}
}
}

View file

@ -0,0 +1 @@
package registry

View file

@ -0,0 +1,225 @@
package registry_test
import (
"context"
"fmt"
"net"
"sort"
"testing"
"time"
"github.com/pomerium/pomerium/internal/registry"
pb "github.com/pomerium/pomerium/pkg/grpc/registry"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/test/bufconn"
)
const (
ttl = time.Second * 2
)
func TestRegistryListWatch(t *testing.T) {
t.Parallel()
brSvc := &pb.Service{Kind: pb.ServiceKind_DATABROKER, Endpoint: "http://localhost"}
kinds := []pb.ServiceKind{pb.ServiceKind_DATABROKER}
svc := []*pb.Service{brSvc}
ctx, client, cancel, err := newTestRegistry()
require.NoError(t, err)
defer cancel()
wc, err := client.Watch(ctx, &pb.ListRequest{Kinds: kinds})
require.NoError(t, err)
entries, err := wc.Recv()
require.NoError(t, err)
assert.Empty(t, entries.Services)
reportResp, err := client.Report(ctx, &pb.RegisterRequest{Services: svc})
require.NoError(t, err)
assert.LessOrEqual(t, reportResp.CallBackAfter.AsDuration(), ttl)
entries, err = client.List(ctx, &pb.ListRequest{Kinds: kinds})
require.NoError(t, err)
assertEqual(t, svc, entries.Services)
entries, err = wc.Recv()
assert.NoError(t, err)
assertEqual(t, svc, entries.Services)
// wait to expire - an empty list should arrive
entries, err = wc.Recv()
assert.NoError(t, err)
assert.Empty(t, entries.Services)
entries, err = client.List(ctx, &pb.ListRequest{Kinds: kinds})
require.NoError(t, err)
assert.Empty(t, entries.Services)
}
func TestRegistryFilter(t *testing.T) {
t.Parallel()
ctx, client, cancel, err := newTestRegistry()
require.NoError(t, err)
defer cancel()
brSvc := &pb.Service{Kind: pb.ServiceKind_DATABROKER, Endpoint: "http://localhost"}
authSvc := &pb.Service{Kind: pb.ServiceKind_AUTHENTICATE, Endpoint: "http://localhost"}
mtrcsSvc := &pb.Service{Kind: pb.ServiceKind_PROMETHEUS_METRICS, Endpoint: "http://localhost/metrics"}
reportResp, err := client.Report(ctx, &pb.RegisterRequest{Services: []*pb.Service{brSvc, authSvc, mtrcsSvc}})
assert.NoError(t, err, "%v")
assert.LessOrEqual(t, reportResp.CallBackAfter.AsDuration(), ttl)
entries, err := client.List(ctx, &pb.ListRequest{Kinds: []pb.ServiceKind{pb.ServiceKind_DATABROKER}})
require.NoError(t, err)
assertEqual(t, []*pb.Service{brSvc}, entries.Services)
entries, err = client.List(ctx, &pb.ListRequest{Kinds: []pb.ServiceKind{pb.ServiceKind_DATABROKER, pb.ServiceKind_PROMETHEUS_METRICS}})
require.NoError(t, err)
assertEqual(t, []*pb.Service{brSvc, mtrcsSvc}, entries.Services)
entries, err = client.List(ctx, &pb.ListRequest{Kinds: []pb.ServiceKind{}}) // nil filter means all
require.NoError(t, err)
assertEqual(t, []*pb.Service{brSvc, mtrcsSvc, authSvc}, entries.Services)
}
func TestRegistryExpiration(t *testing.T) {
t.Parallel()
svcA := &pb.Service{Kind: pb.ServiceKind_PROMETHEUS_METRICS, Endpoint: "http://host-a/metrics"}
svcB := &pb.Service{Kind: pb.ServiceKind_PROMETHEUS_METRICS, Endpoint: "http://host-b/metrics"}
ctx, client, cancel, err := newTestRegistry()
require.NoError(t, err)
defer cancel()
wc, err := client.Watch(ctx, &pb.ListRequest{Kinds: []pb.ServiceKind{pb.ServiceKind_PROMETHEUS_METRICS}})
require.NoError(t, err)
entries, err := wc.Recv()
require.NoError(t, err)
assert.Empty(t, entries.Services)
_, err = client.Report(ctx, &pb.RegisterRequest{Services: []*pb.Service{svcA, svcB}})
require.NoError(t, err)
ctxB, cancelB := context.WithCancel(ctx)
go func(ctx context.Context) {
after := time.Microsecond
for {
select {
case <-time.After(after):
resp, err := client.Report(ctx, &pb.RegisterRequest{Services: []*pb.Service{svcB}})
if err != nil {
return
}
after = resp.CallBackAfter.AsDuration()
case <-ctx.Done():
return
}
}
}(ctxB)
// first, both services should be reported
entries, err = wc.Recv()
assert.NoError(t, err)
assertEqual(t, []*pb.Service{svcA, svcB}, entries.Services)
// then, svcA should expire as it is not sending updates anymore
entries, err = wc.Recv()
assert.NoError(t, err)
assertEqual(t, []*pb.Service{svcB}, entries.Services)
// now we cancel updates for B, and both registration should expire
cancelB()
entries, err = wc.Recv()
assert.NoError(t, err)
assert.Empty(t, entries.Services)
}
func TestRegistryErrors(t *testing.T) {
t.Parallel()
ctx, client, cancel, err := newTestRegistry()
require.NoError(t, err)
defer cancel()
tc := [][]*pb.Service{
{{Kind: pb.ServiceKind_UNDEFINED_DO_NOT_USE, Endpoint: "http://localhost"}},
{{Kind: pb.ServiceKind_PROMETHEUS_METRICS, Endpoint: ""}},
{{Kind: pb.ServiceKind_PROMETHEUS_METRICS, Endpoint: "/metrics"}},
{},
nil,
}
for _, svc := range tc {
_, err := client.Report(ctx, &pb.RegisterRequest{Services: svc})
assert.Error(t, err, svc)
}
}
func newTestRegistry() (context.Context, pb.RegistryClient, func(), error) {
cancel := new(cancelAll)
l := bufconn.Listen(1024)
cancel.Append(func() { l.Close() })
dialer := func(context.Context, string) (net.Conn, error) {
return l.Dial()
}
ctx, ctxCancel := context.WithCancel(context.Background())
cancel.Append(ctxCancel)
gs := grpc.NewServer()
ttl := time.Second
pb.RegisterRegistryServer(gs, registry.NewInMemoryServer(ctx, ttl))
go gs.Serve(l)
cancel.Append(gs.Stop)
conn, err := grpc.DialContext(ctx, "inmem", grpc.WithContextDialer(dialer), grpc.WithInsecure())
if err != nil {
cancel.Cancel()
return nil, nil, nil, fmt.Errorf("failed to dial bufnet: %w", err)
}
cancel.Append(func() { conn.Close() })
return ctx, pb.NewRegistryClient(conn), cancel.Cancel, nil
}
type cancelAll []func()
func (c *cancelAll) Append(fn func()) { *c = append(*c, fn) }
func (c *cancelAll) Cancel() {
for _, fn := range *c {
fn()
}
}
type serviceList []*pb.Service
func (l serviceList) Len() int { return len(l) }
func (l serviceList) Less(i, j int) bool { return l[i].Kind < l[j].Kind }
func (l serviceList) Swap(i, j int) { t := l[i]; l[i] = l[j]; l[j] = t }
func assertEqual(t *testing.T, want, got []*pb.Service) {
t.Helper()
sort.Sort(serviceList(want))
sort.Sort(serviceList(got))
diff := cmp.Diff(want, got, cmpopts.IgnoreUnexported(pb.Service{}))
if diff != "" {
t.Errorf("(-want +got):\n%s", diff)
}
}

View file

@ -6,6 +6,7 @@ package grpc
//go:generate ../../scripts/protoc -I ./directory/ --go_out=plugins=grpc,paths=source_relative:./directory/. ./directory/directory.proto
//go:generate ../../scripts/protoc -I ./audit/ --go_out=plugins=grpc,paths=source_relative:./audit/. ./audit/audit.proto
//go:generate ../../scripts/protoc -I ./config/ --go_out=Menvoy/config/cluster/v3/cluster.proto=github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3,plugins=grpc,paths=source_relative:./config/. ./config/config.proto
//go:generate ../../scripts/protoc -I ./registry/ --go_out=plugins=grpc,paths=source_relative:./registry/. --validate_out=lang=go:./registry ./registry/registry.proto
const roundRobinServiceConfig = `{
"loadBalancingConfig": [

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);
}