From 833921ea7bac778efb5bd24fbf32756a7f0ce2ec Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Thu, 15 Feb 2024 03:12:03 +0000 Subject: [PATCH] fix: impl porter connection status & instance info --- app/sephirah/cmd/sephirah/wire_gen.go | 2 +- .../service/librariansephirahservice.go | 18 +- app/sephirah/internal/service/tiphereth.go | 3 + .../internal/supervisor/supervisor.go | 15 +- app/sephirah/pkg/service/wire.go | 1 + app/sephirah/pkg/service/wire_gen.go | 4 +- cmd/librarian/wire_gen.go | 2 +- internal/conf/sephirah.pb.go | 274 +++++++++++++----- internal/conf/sephirah.proto | 8 + internal/lib/libcodec/toml_test.go | 6 +- 10 files changed, 244 insertions(+), 89 deletions(-) diff --git a/app/sephirah/cmd/sephirah/wire_gen.go b/app/sephirah/cmd/sephirah/wire_gen.go index bf0349b..38e4094 100644 --- a/app/sephirah/cmd/sephirah/wire_gen.go +++ b/app/sephirah/cmd/sephirah/wire_gen.go @@ -145,7 +145,7 @@ func wireApp(sephirahServer *conf.SephirahServer, sephirahData *conf.SephirahDat return nil, nil, err } v := server.NewAuthMiddleware(libauthAuth) - librarianSephirahServiceServer := service.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, libauthAuth, v) + librarianSephirahServiceServer := service.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, libauthAuth, v, sephirahServer) grpcServer, err := server.NewGRPCServer(sephirahServer, libauthAuth, librarianSephirahServiceServer, settings) if err != nil { cleanup2() diff --git a/app/sephirah/internal/service/librariansephirahservice.go b/app/sephirah/internal/service/librariansephirahservice.go index 05d28f9..4e7e641 100644 --- a/app/sephirah/internal/service/librariansephirahservice.go +++ b/app/sephirah/internal/service/librariansephirahservice.go @@ -13,6 +13,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/biz/bizyesod" "github.com/tuihub/librarian/app/sephirah/internal/model/converter" "github.com/tuihub/librarian/app/sephirah/internal/supervisor" + "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" @@ -33,6 +34,7 @@ type LibrarianSephirahServiceService struct { app *libapp.Settings auth *libauth.Auth authFunc func(context.Context) (context.Context, error) + info *pb.ServerInstanceSummary } func NewLibrarianSephirahServiceService( @@ -47,8 +49,15 @@ func NewLibrarianSephirahServiceService( app *libapp.Settings, auth *libauth.Auth, authFunc func(context.Context) (context.Context, error), + config *conf.SephirahServer, ) pb.LibrarianSephirahServiceServer { t.CreateConfiguredAdmin() + if config == nil { + config = new(conf.SephirahServer) + } + if config.GetInfo() == nil { + config.Info = new(conf.SephirahServer_Info) + } return &LibrarianSephirahServiceService{ UnimplementedLibrarianSephirahServiceServer: pb.UnimplementedLibrarianSephirahServiceServer{}, t: t, @@ -61,6 +70,13 @@ func NewLibrarianSephirahServiceService( app: app, auth: auth, authFunc: authFunc, + info: &pb.ServerInstanceSummary{ + Name: config.GetInfo().GetName(), + Description: config.GetInfo().GetDescription(), + WebsiteUrl: config.GetInfo().GetWebsiteUrl(), + LogoUrl: config.GetInfo().GetLogoUrl(), + BackgroundUrl: config.GetInfo().GetBackgroundUrl(), + }, } } @@ -77,6 +93,6 @@ func (s *LibrarianSephirahServiceService) GetServerInformation(_ context.Context }, CurrentTime: timestamppb.New(time.Now()), FeatureSummary: converter.ToPBServerFeatureSummary(s.s.GetFeatureSummary()), - ServerInstanceSummary: nil, + ServerInstanceSummary: s.info, }, nil } diff --git a/app/sephirah/internal/service/tiphereth.go b/app/sephirah/internal/service/tiphereth.go index 48e41d1..3874855 100644 --- a/app/sephirah/internal/service/tiphereth.go +++ b/app/sephirah/internal/service/tiphereth.go @@ -217,6 +217,9 @@ func (s *LibrarianSephirahServiceService) ListPorters(ctx context.Context, req * if err != nil { return nil, err } + for i := range res { + res[i].ConnectionStatus = s.s.GetInstanceConnectionStatus(ctx, res[i].Address) + } return &pb.ListPortersResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, Porters: converter.ToPBPorterList(res), diff --git a/app/sephirah/internal/supervisor/supervisor.go b/app/sephirah/internal/supervisor/supervisor.go index 9abf952..9e6b30d 100644 --- a/app/sephirah/internal/supervisor/supervisor.go +++ b/app/sephirah/internal/supervisor/supervisor.go @@ -110,13 +110,16 @@ func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit // TODO continue } ins = s.knownInstances[address] + ins.ConnectionStatus = modeltiphereth.PorterConnectionStatusConnected if ins.Status == modeltiphereth.PorterInstanceStatusActive { // enable & check ownership if err2 := s.enablePorterInstance(ctx, ins); err2 != nil { logger.Errorf("%s", err2.Error()) + ins.ConnectionStatus = modeltiphereth.PorterConnectionStatusActivationFailed // bad instance, can't enable continue } + ins.ConnectionStatus = modeltiphereth.PorterConnectionStatusActive } if reflect.DeepEqual(ins.FeatureSummary, feature) { // no change, but alive @@ -134,7 +137,7 @@ func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit // TODO Address: address, FeatureSummary: feature, Status: modeltiphereth.PorterInstanceStatusUnspecified, - ConnectionStatus: modeltiphereth.PorterConnectionStatusUnspecified, + ConnectionStatus: modeltiphereth.PorterConnectionStatusConnected, } } // new instance or feature changed @@ -148,6 +151,16 @@ func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit // TODO return newInstances, nil } +func (s *Supervisor) GetInstanceConnectionStatus( + ctx context.Context, + address string, +) modeltiphereth.PorterConnectionStatus { + if s.aliveInstances[address] == nil { + return modeltiphereth.PorterConnectionStatusDisconnected + } + return s.aliveInstances[address].ConnectionStatus +} + // EnablePorterInstance enable porter instance, can be called multiple times. func (s *Supervisor) enablePorterInstance(ctx context.Context, instance *modeltiphereth.PorterInstance) error { if instance == nil { diff --git a/app/sephirah/pkg/service/wire.go b/app/sephirah/pkg/service/wire.go index 66ecef1..84e76b3 100644 --- a/app/sephirah/pkg/service/wire.go +++ b/app/sephirah/pkg/service/wire.go @@ -26,6 +26,7 @@ import ( ) func NewSephirahService( + *conf.SephirahServer, *conf.SephirahData, *conf.Porter, *conf.Consul, diff --git a/app/sephirah/pkg/service/wire_gen.go b/app/sephirah/pkg/service/wire_gen.go index 4629c29..26e86c9 100644 --- a/app/sephirah/pkg/service/wire_gen.go +++ b/app/sephirah/pkg/service/wire_gen.go @@ -32,7 +32,7 @@ import ( // Injectors from wire.go: -func NewSephirahService(sephirahData *conf.SephirahData, porter *conf.Porter, consul *conf.Consul, auth *libauth.Auth, mq *libmq.MQ, cron *libcron.Cron, store libcache.Store, settings *libapp.Settings, librarianSearcherServiceClient v1.LibrarianSearcherServiceClient, librarianMinerServiceClient v1_2.LibrarianMinerServiceClient) (v1_3.LibrarianSephirahServiceServer, func(), error) { +func NewSephirahService(sephirahServer *conf.SephirahServer, sephirahData *conf.SephirahData, porter *conf.Porter, consul *conf.Consul, auth *libauth.Auth, mq *libmq.MQ, cron *libcron.Cron, store libcache.Store, settings *libapp.Settings, librarianSearcherServiceClient v1.LibrarianSearcherServiceClient, librarianMinerServiceClient v1_2.LibrarianMinerServiceClient) (v1_3.LibrarianSephirahServiceServer, func(), error) { entClient, cleanup, err := data.NewSQLClient(sephirahData, settings) if err != nil { return nil, nil, err @@ -108,7 +108,7 @@ func NewSephirahService(sephirahData *conf.SephirahData, porter *conf.Porter, co return nil, nil, err } v := server.NewAuthMiddleware(auth) - librarianSephirahServiceServer := service.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, auth, v) + librarianSephirahServiceServer := service.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, auth, v, sephirahServer) return librarianSephirahServiceServer, func() { cleanup() }, nil diff --git a/cmd/librarian/wire_gen.go b/cmd/librarian/wire_gen.go index ff7f09a..1636ab7 100644 --- a/cmd/librarian/wire_gen.go +++ b/cmd/librarian/wire_gen.go @@ -65,7 +65,7 @@ func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDisco cleanup() return nil, nil, err } - librarianSephirahServiceServer, cleanup4, err := service3.NewSephirahService(sephirahData, porter, consul, libauthAuth, libmqMQ, cron, store, settings, librarianSearcherServiceClient, librarianMinerServiceClient) + librarianSephirahServiceServer, cleanup4, err := service3.NewSephirahService(sephirahServer, sephirahData, porter, consul, libauthAuth, libmqMQ, cron, store, settings, librarianSearcherServiceClient, librarianMinerServiceClient) if err != nil { cleanup3() cleanup2() diff --git a/internal/conf/sephirah.pb.go b/internal/conf/sephirah.pb.go index d767c36..7dbe58e 100644 --- a/internal/conf/sephirah.pb.go +++ b/internal/conf/sephirah.pb.go @@ -25,8 +25,9 @@ type SephirahServer struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Grpc *GRPC `protobuf:"bytes,1,opt,name=grpc,proto3" json:"grpc,omitempty"` - GrpcWeb *GRPC `protobuf:"bytes,2,opt,name=grpc_web,json=grpcWeb,proto3" json:"grpc_web,omitempty"` + Grpc *GRPC `protobuf:"bytes,1,opt,name=grpc,proto3" json:"grpc,omitempty"` + GrpcWeb *GRPC `protobuf:"bytes,2,opt,name=grpc_web,json=grpcWeb,proto3" json:"grpc_web,omitempty"` + Info *SephirahServer_Info `protobuf:"bytes,3,opt,name=info,proto3" json:"info,omitempty"` } func (x *SephirahServer) Reset() { @@ -75,6 +76,13 @@ func (x *SephirahServer) GetGrpcWeb() *GRPC { return nil } +func (x *SephirahServer) GetInfo() *SephirahServer_Info { + if x != nil { + return x.Info + } + return nil +} + type SephirahData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -272,6 +280,85 @@ func (x *Sephirah) GetConsul() *Consul { return nil } +type SephirahServer_Info struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + WebsiteUrl string `protobuf:"bytes,3,opt,name=website_url,json=websiteUrl,proto3" json:"website_url,omitempty"` + LogoUrl string `protobuf:"bytes,4,opt,name=logo_url,json=logoUrl,proto3" json:"logo_url,omitempty"` + BackgroundUrl string `protobuf:"bytes,5,opt,name=background_url,json=backgroundUrl,proto3" json:"background_url,omitempty"` +} + +func (x *SephirahServer_Info) Reset() { + *x = SephirahServer_Info{} + if protoimpl.UnsafeEnabled { + mi := &file_conf_sephirah_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SephirahServer_Info) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SephirahServer_Info) ProtoMessage() {} + +func (x *SephirahServer_Info) ProtoReflect() protoreflect.Message { + mi := &file_conf_sephirah_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 SephirahServer_Info.ProtoReflect.Descriptor instead. +func (*SephirahServer_Info) Descriptor() ([]byte, []int) { + return file_conf_sephirah_proto_rawDescGZIP(), []int{0, 0} +} + +func (x *SephirahServer_Info) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *SephirahServer_Info) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *SephirahServer_Info) GetWebsiteUrl() string { + if x != nil { + return x.WebsiteUrl + } + return "" +} + +func (x *SephirahServer_Info) GetLogoUrl() string { + if x != nil { + return x.LogoUrl + } + return "" +} + +func (x *SephirahServer_Info) GetBackgroundUrl() string { + if x != nil { + return x.BackgroundUrl + } + return "" +} + type SephirahData_S3 struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -286,7 +373,7 @@ type SephirahData_S3 struct { func (x *SephirahData_S3) Reset() { *x = SephirahData_S3{} if protoimpl.UnsafeEnabled { - mi := &file_conf_sephirah_proto_msgTypes[4] + mi := &file_conf_sephirah_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -299,7 +386,7 @@ func (x *SephirahData_S3) String() string { func (*SephirahData_S3) ProtoMessage() {} func (x *SephirahData_S3) ProtoReflect() protoreflect.Message { - mi := &file_conf_sephirah_proto_msgTypes[4] + mi := &file_conf_sephirah_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -349,53 +436,66 @@ var file_conf_sephirah_proto_rawDesc = []byte{ 0x0a, 0x13, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x73, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x0f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x63, 0x0a, 0x0e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x12, 0x24, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x47, 0x52, 0x50, 0x43, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x12, 0x2b, 0x0a, 0x08, 0x67, 0x72, - 0x70, 0x63, 0x5f, 0x77, 0x65, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, - 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, 0x07, - 0x67, 0x72, 0x70, 0x63, 0x57, 0x65, 0x62, 0x22, 0xe7, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x70, 0x68, - 0x69, 0x72, 0x61, 0x68, 0x44, 0x61, 0x74, 0x61, 0x12, 0x30, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, - 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6b, 0x72, 0x61, - 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, - 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x02, 0x73, 0x33, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x44, 0x61, 0x74, 0x61, - 0x2e, 0x53, 0x33, 0x52, 0x02, 0x73, 0x33, 0x1a, 0x78, 0x0a, 0x02, 0x53, 0x33, 0x12, 0x1b, 0x0a, - 0x09, 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, - 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x63, - 0x72, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, - 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x5f, - 0x73, 0x73, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x75, 0x73, 0x65, 0x53, 0x73, - 0x6c, 0x22, 0x31, 0x0a, 0x06, 0x50, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x74, - 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x22, 0xb3, 0x02, 0x0a, 0x08, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, - 0x68, 0x12, 0x32, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, - 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x12, 0x24, 0x0a, 0x04, 0x61, 0x75, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, - 0x75, 0x74, 0x68, 0x52, 0x04, 0x61, 0x75, 0x74, 0x68, 0x12, 0x1e, 0x0a, 0x02, 0x6d, 0x71, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x4d, 0x51, 0x52, 0x02, 0x6d, 0x71, 0x12, 0x27, 0x0a, 0x05, 0x63, 0x61, 0x63, - 0x68, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, - 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x05, 0x63, 0x61, 0x63, - 0x68, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x50, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x52, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x2a, - 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, - 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, 0x73, - 0x75, 0x6c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x42, 0x1e, 0x5a, 0x1c, 0x4c, 0x69, - 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, - 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x74, 0x6f, 0x22, 0xba, 0x02, 0x0a, 0x0e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x24, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x12, 0x2b, 0x0a, 0x08, 0x67, + 0x72, 0x70, 0x63, 0x5f, 0x77, 0x65, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, + 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, + 0x07, 0x67, 0x72, 0x70, 0x63, 0x57, 0x65, 0x62, 0x12, 0x33, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x1a, 0x9f, 0x01, + 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, + 0x77, 0x65, 0x62, 0x73, 0x69, 0x74, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x77, 0x65, 0x62, 0x73, 0x69, 0x74, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x19, 0x0a, + 0x08, 0x6c, 0x6f, 0x67, 0x6f, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6c, 0x6f, 0x67, 0x6f, 0x55, 0x72, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x62, 0x61, 0x63, 0x6b, + 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0d, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x72, 0x6c, 0x22, + 0xe7, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x44, 0x61, 0x74, 0x61, + 0x12, 0x30, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, + 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x02, 0x73, 0x33, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, + 0x69, 0x72, 0x61, 0x68, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x33, 0x52, 0x02, 0x73, 0x33, 0x1a, + 0x78, 0x0a, 0x02, 0x53, 0x33, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, + 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, + 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, + 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x5f, 0x73, 0x73, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x06, 0x75, 0x73, 0x65, 0x53, 0x73, 0x6c, 0x22, 0x31, 0x0a, 0x06, 0x50, 0x6f, 0x72, + 0x74, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x72, + 0x75, 0x73, 0x74, 0x65, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0xb3, 0x02, 0x0a, + 0x08, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x12, 0x32, 0x0a, 0x06, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6b, 0x72, 0x61, 0x74, + 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2c, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6b, 0x72, + 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, + 0x68, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x24, 0x0a, 0x04, 0x61, + 0x75, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, + 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x04, 0x61, 0x75, 0x74, + 0x68, 0x12, 0x1e, 0x0a, 0x02, 0x6d, 0x71, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, + 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x51, 0x52, 0x02, 0x6d, + 0x71, 0x12, 0x27, 0x0a, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x11, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, + 0x63, 0x68, 0x65, 0x52, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, + 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x52, 0x06, + 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x73, + 0x75, 0x6c, 0x42, 0x1e, 0x5a, 0x1c, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, + 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -410,37 +510,39 @@ func file_conf_sephirah_proto_rawDescGZIP() []byte { return file_conf_sephirah_proto_rawDescData } -var file_conf_sephirah_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_conf_sephirah_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_conf_sephirah_proto_goTypes = []interface{}{ - (*SephirahServer)(nil), // 0: kratos.api.SephirahServer - (*SephirahData)(nil), // 1: kratos.api.SephirahData - (*Porter)(nil), // 2: kratos.api.Porter - (*Sephirah)(nil), // 3: kratos.api.Sephirah - (*SephirahData_S3)(nil), // 4: kratos.api.SephirahData.S3 - (*GRPC)(nil), // 5: kratos.api.GRPC - (*Database)(nil), // 6: kratos.api.Database - (*Auth)(nil), // 7: kratos.api.Auth - (*MQ)(nil), // 8: kratos.api.MQ - (*Cache)(nil), // 9: kratos.api.Cache - (*Consul)(nil), // 10: kratos.api.Consul + (*SephirahServer)(nil), // 0: kratos.api.SephirahServer + (*SephirahData)(nil), // 1: kratos.api.SephirahData + (*Porter)(nil), // 2: kratos.api.Porter + (*Sephirah)(nil), // 3: kratos.api.Sephirah + (*SephirahServer_Info)(nil), // 4: kratos.api.SephirahServer.Info + (*SephirahData_S3)(nil), // 5: kratos.api.SephirahData.S3 + (*GRPC)(nil), // 6: kratos.api.GRPC + (*Database)(nil), // 7: kratos.api.Database + (*Auth)(nil), // 8: kratos.api.Auth + (*MQ)(nil), // 9: kratos.api.MQ + (*Cache)(nil), // 10: kratos.api.Cache + (*Consul)(nil), // 11: kratos.api.Consul } var file_conf_sephirah_proto_depIdxs = []int32{ - 5, // 0: kratos.api.SephirahServer.grpc:type_name -> kratos.api.GRPC - 5, // 1: kratos.api.SephirahServer.grpc_web:type_name -> kratos.api.GRPC - 6, // 2: kratos.api.SephirahData.database:type_name -> kratos.api.Database - 4, // 3: kratos.api.SephirahData.s3:type_name -> kratos.api.SephirahData.S3 - 0, // 4: kratos.api.Sephirah.server:type_name -> kratos.api.SephirahServer - 1, // 5: kratos.api.Sephirah.data:type_name -> kratos.api.SephirahData - 7, // 6: kratos.api.Sephirah.auth:type_name -> kratos.api.Auth - 8, // 7: kratos.api.Sephirah.mq:type_name -> kratos.api.MQ - 9, // 8: kratos.api.Sephirah.cache:type_name -> kratos.api.Cache - 2, // 9: kratos.api.Sephirah.porter:type_name -> kratos.api.Porter - 10, // 10: kratos.api.Sephirah.consul:type_name -> kratos.api.Consul - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 6, // 0: kratos.api.SephirahServer.grpc:type_name -> kratos.api.GRPC + 6, // 1: kratos.api.SephirahServer.grpc_web:type_name -> kratos.api.GRPC + 4, // 2: kratos.api.SephirahServer.info:type_name -> kratos.api.SephirahServer.Info + 7, // 3: kratos.api.SephirahData.database:type_name -> kratos.api.Database + 5, // 4: kratos.api.SephirahData.s3:type_name -> kratos.api.SephirahData.S3 + 0, // 5: kratos.api.Sephirah.server:type_name -> kratos.api.SephirahServer + 1, // 6: kratos.api.Sephirah.data:type_name -> kratos.api.SephirahData + 8, // 7: kratos.api.Sephirah.auth:type_name -> kratos.api.Auth + 9, // 8: kratos.api.Sephirah.mq:type_name -> kratos.api.MQ + 10, // 9: kratos.api.Sephirah.cache:type_name -> kratos.api.Cache + 2, // 10: kratos.api.Sephirah.porter:type_name -> kratos.api.Porter + 11, // 11: kratos.api.Sephirah.consul:type_name -> kratos.api.Consul + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_conf_sephirah_proto_init() } @@ -499,6 +601,18 @@ func file_conf_sephirah_proto_init() { } } file_conf_sephirah_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SephirahServer_Info); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_conf_sephirah_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SephirahData_S3); i { case 0: return &v.state @@ -517,7 +631,7 @@ func file_conf_sephirah_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_conf_sephirah_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/conf/sephirah.proto b/internal/conf/sephirah.proto index cc06a46..5e79075 100644 --- a/internal/conf/sephirah.proto +++ b/internal/conf/sephirah.proto @@ -6,8 +6,16 @@ option go_package = "Librarian/internal/conf;conf"; import "conf/base.proto"; message SephirahServer { + message Info { + string name = 1; + string description = 2; + string website_url = 3; + string logo_url = 4; + string background_url = 5; + } GRPC grpc = 1; GRPC grpc_web = 2; + Info info = 3; } message SephirahData { diff --git a/internal/lib/libcodec/toml_test.go b/internal/lib/libcodec/toml_test.go index 360cf94..7a4185b 100644 --- a/internal/lib/libcodec/toml_test.go +++ b/internal/lib/libcodec/toml_test.go @@ -50,15 +50,15 @@ func TestCodec_Unmarshal(t *testing.T) { //{ // data: "v = 0xDEADBEEF", // value: map[string]interface{}{"v": 3735928559}, - //}, + // }, //{ // data: "v = 0b1101_0101", // value: map[string]interface{}{"v": 213}, - //}, + // }, //{ // data: "v = 0o755", // value: map[string]interface{}{"v": 493}, - //}, + // }, { data: "v = 2022-04-16T12:13:14Z", value: map[string]interface{}{"v": time.Date(2022, time.April, 16, 12, 13, 14, 0, time.UTC)},