mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] [Integration] Services Endpoint (#1761)
This commit is contained in:
parent
a09403d4c2
commit
ed068680f2
9 changed files with 363 additions and 31 deletions
|
@ -17,6 +17,7 @@
|
||||||
- (Feature) (Platform) Storage V1Alpha1 RC
|
- (Feature) (Platform) Storage V1Alpha1 RC
|
||||||
- (Feature) (Networking) ArangoRotue WebSocket Support
|
- (Feature) (Networking) ArangoRotue WebSocket Support
|
||||||
- (Feature) (Scheduler) Helm Driver Param
|
- (Feature) (Scheduler) Helm Driver Param
|
||||||
|
- (Feature) (Integration) Services Endpoint
|
||||||
|
|
||||||
## [1.2.43](https://github.com/arangodb/kube-arangodb/tree/1.2.43) (2024-10-14)
|
## [1.2.43](https://github.com/arangodb/kube-arangodb/tree/1.2.43) (2024-10-14)
|
||||||
- (Feature) ArangoRoute CRD
|
- (Feature) ArangoRoute CRD
|
||||||
|
|
|
@ -91,6 +91,122 @@ func (x *PongV1PingResponse) GetTime() *timestamppb.Timestamp {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PongV1 Services Call Response
|
||||||
|
type PongV1ServicesResponse struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// List of the Services
|
||||||
|
Services []*PongV1Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PongV1ServicesResponse) Reset() {
|
||||||
|
*x = PongV1ServicesResponse{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_integrations_pong_v1_definition_pong_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PongV1ServicesResponse) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*PongV1ServicesResponse) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *PongV1ServicesResponse) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_integrations_pong_v1_definition_pong_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 PongV1ServicesResponse.ProtoReflect.Descriptor instead.
|
||||||
|
func (*PongV1ServicesResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return file_integrations_pong_v1_definition_pong_proto_rawDescGZIP(), []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PongV1ServicesResponse) GetServices() []*PongV1Service {
|
||||||
|
if x != nil {
|
||||||
|
return x.Services
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Service Definition
|
||||||
|
type PongV1Service struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// Service Name
|
||||||
|
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||||
|
// Service Version
|
||||||
|
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
|
||||||
|
// states if service is enabled
|
||||||
|
Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PongV1Service) Reset() {
|
||||||
|
*x = PongV1Service{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_integrations_pong_v1_definition_pong_proto_msgTypes[2]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PongV1Service) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*PongV1Service) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *PongV1Service) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_integrations_pong_v1_definition_pong_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 PongV1Service.ProtoReflect.Descriptor instead.
|
||||||
|
func (*PongV1Service) Descriptor() ([]byte, []int) {
|
||||||
|
return file_integrations_pong_v1_definition_pong_proto_rawDescGZIP(), []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PongV1Service) GetName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PongV1Service) GetVersion() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Version
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PongV1Service) GetEnabled() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Enabled
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var File_integrations_pong_v1_definition_pong_proto protoreflect.FileDescriptor
|
var File_integrations_pong_v1_definition_pong_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_integrations_pong_v1_definition_pong_proto_rawDesc = []byte{
|
var file_integrations_pong_v1_definition_pong_proto_rawDesc = []byte{
|
||||||
|
@ -106,15 +222,29 @@ var file_integrations_pong_v1_definition_pong_proto_rawDesc = []byte{
|
||||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65,
|
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
0x18, 0x01, 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,
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
|
||||||
0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x32, 0x39, 0x0a, 0x06, 0x50, 0x6f, 0x6e, 0x67,
|
0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x49, 0x0a, 0x16, 0x50, 0x6f, 0x6e, 0x67,
|
||||||
0x56, 0x31, 0x12, 0x2f, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x0d, 0x2e, 0x73, 0x68, 0x61,
|
0x56, 0x31, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||||
0x72, 0x65, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x18, 0x2e, 0x70, 0x6f, 0x6e, 0x67,
|
0x73, 0x65, 0x12, 0x2f, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01,
|
||||||
0x2e, 0x50, 0x6f, 0x6e, 0x67, 0x56, 0x31, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x6f, 0x6e, 0x67, 0x2e, 0x50, 0x6f, 0x6e, 0x67,
|
||||||
0x6e, 0x73, 0x65, 0x42, 0x43, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
0x56, 0x31, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69,
|
||||||
0x6d, 0x2f, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x2d,
|
0x63, 0x65, 0x73, 0x22, 0x57, 0x0a, 0x0d, 0x50, 0x6f, 0x6e, 0x67, 0x56, 0x31, 0x53, 0x65, 0x72,
|
||||||
0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61,
|
0x76, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x70, 0x6f, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x65,
|
0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73,
|
||||||
0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69,
|
||||||
|
0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x03, 0x20,
|
||||||
|
0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x32, 0x72, 0x0a, 0x06,
|
||||||
|
0x50, 0x6f, 0x6e, 0x67, 0x56, 0x31, 0x12, 0x2f, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x0d,
|
||||||
|
0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x18, 0x2e,
|
||||||
|
0x70, 0x6f, 0x6e, 0x67, 0x2e, 0x50, 0x6f, 0x6e, 0x67, 0x56, 0x31, 0x50, 0x69, 0x6e, 0x67, 0x52,
|
||||||
|
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x69,
|
||||||
|
0x63, 0x65, 0x73, 0x12, 0x0d, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x45, 0x6d, 0x70,
|
||||||
|
0x74, 0x79, 0x1a, 0x1c, 0x2e, 0x70, 0x6f, 0x6e, 0x67, 0x2e, 0x50, 0x6f, 0x6e, 0x67, 0x56, 0x31,
|
||||||
|
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||||
|
0x42, 0x43, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61,
|
||||||
|
0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x2d, 0x61, 0x72, 0x61,
|
||||||
|
0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f,
|
||||||
|
0x6e, 0x73, 0x2f, 0x70, 0x6f, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e,
|
||||||
|
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -129,21 +259,26 @@ func file_integrations_pong_v1_definition_pong_proto_rawDescGZIP() []byte {
|
||||||
return file_integrations_pong_v1_definition_pong_proto_rawDescData
|
return file_integrations_pong_v1_definition_pong_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_integrations_pong_v1_definition_pong_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
var file_integrations_pong_v1_definition_pong_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||||
var file_integrations_pong_v1_definition_pong_proto_goTypes = []interface{}{
|
var file_integrations_pong_v1_definition_pong_proto_goTypes = []interface{}{
|
||||||
(*PongV1PingResponse)(nil), // 0: pong.PongV1PingResponse
|
(*PongV1PingResponse)(nil), // 0: pong.PongV1PingResponse
|
||||||
(*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp
|
(*PongV1ServicesResponse)(nil), // 1: pong.PongV1ServicesResponse
|
||||||
(*definition.Empty)(nil), // 2: shared.Empty
|
(*PongV1Service)(nil), // 2: pong.PongV1Service
|
||||||
|
(*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp
|
||||||
|
(*definition.Empty)(nil), // 4: shared.Empty
|
||||||
}
|
}
|
||||||
var file_integrations_pong_v1_definition_pong_proto_depIdxs = []int32{
|
var file_integrations_pong_v1_definition_pong_proto_depIdxs = []int32{
|
||||||
1, // 0: pong.PongV1PingResponse.time:type_name -> google.protobuf.Timestamp
|
3, // 0: pong.PongV1PingResponse.time:type_name -> google.protobuf.Timestamp
|
||||||
2, // 1: pong.PongV1.Ping:input_type -> shared.Empty
|
2, // 1: pong.PongV1ServicesResponse.services:type_name -> pong.PongV1Service
|
||||||
0, // 2: pong.PongV1.Ping:output_type -> pong.PongV1PingResponse
|
4, // 2: pong.PongV1.Ping:input_type -> shared.Empty
|
||||||
2, // [2:3] is the sub-list for method output_type
|
4, // 3: pong.PongV1.Services:input_type -> shared.Empty
|
||||||
1, // [1:2] is the sub-list for method input_type
|
0, // 4: pong.PongV1.Ping:output_type -> pong.PongV1PingResponse
|
||||||
1, // [1:1] is the sub-list for extension type_name
|
1, // 5: pong.PongV1.Services:output_type -> pong.PongV1ServicesResponse
|
||||||
1, // [1:1] is the sub-list for extension extendee
|
4, // [4:6] is the sub-list for method output_type
|
||||||
0, // [0:1] is the sub-list for field type_name
|
2, // [2:4] is the sub-list for method input_type
|
||||||
|
2, // [2:2] is the sub-list for extension type_name
|
||||||
|
2, // [2:2] is the sub-list for extension extendee
|
||||||
|
0, // [0:2] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_integrations_pong_v1_definition_pong_proto_init() }
|
func init() { file_integrations_pong_v1_definition_pong_proto_init() }
|
||||||
|
@ -164,6 +299,30 @@ func file_integrations_pong_v1_definition_pong_proto_init() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_integrations_pong_v1_definition_pong_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*PongV1ServicesResponse); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_integrations_pong_v1_definition_pong_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*PongV1Service); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
type x struct{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
|
@ -171,7 +330,7 @@ func file_integrations_pong_v1_definition_pong_proto_init() {
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_integrations_pong_v1_definition_pong_proto_rawDesc,
|
RawDescriptor: file_integrations_pong_v1_definition_pong_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 1,
|
NumMessages: 3,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
|
|
@ -32,6 +32,9 @@ option go_package = "github.com/arangodb/kube-arangodb/integrations/pong/v1/defi
|
||||||
service PongV1 {
|
service PongV1 {
|
||||||
// Sends ping to the server
|
// Sends ping to the server
|
||||||
rpc Ping(shared.Empty) returns (PongV1PingResponse);
|
rpc Ping(shared.Empty) returns (PongV1PingResponse);
|
||||||
|
|
||||||
|
// Asks for the services details
|
||||||
|
rpc Services(shared.Empty) returns (PongV1ServicesResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Responses
|
// Responses
|
||||||
|
@ -41,4 +44,20 @@ service PongV1 {
|
||||||
message PongV1PingResponse {
|
message PongV1PingResponse {
|
||||||
// Current time in UTC
|
// Current time in UTC
|
||||||
google.protobuf.Timestamp time = 1;
|
google.protobuf.Timestamp time = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PongV1 Services Call Response
|
||||||
|
message PongV1ServicesResponse {
|
||||||
|
// List of the Services
|
||||||
|
repeated PongV1Service services = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Service Definition
|
||||||
|
message PongV1Service {
|
||||||
|
// Service Name
|
||||||
|
string name = 1;
|
||||||
|
// Service Version
|
||||||
|
string version = 2;
|
||||||
|
// states if service is enabled
|
||||||
|
bool enabled = 3;
|
||||||
}
|
}
|
|
@ -25,6 +25,8 @@ const _ = grpc.SupportPackageIsVersion7
|
||||||
type PongV1Client interface {
|
type PongV1Client interface {
|
||||||
// Sends ping to the server
|
// Sends ping to the server
|
||||||
Ping(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*PongV1PingResponse, error)
|
Ping(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*PongV1PingResponse, error)
|
||||||
|
// Asks for the services details
|
||||||
|
Services(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*PongV1ServicesResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type pongV1Client struct {
|
type pongV1Client struct {
|
||||||
|
@ -44,12 +46,23 @@ func (c *pongV1Client) Ping(ctx context.Context, in *definition.Empty, opts ...g
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *pongV1Client) Services(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*PongV1ServicesResponse, error) {
|
||||||
|
out := new(PongV1ServicesResponse)
|
||||||
|
err := c.cc.Invoke(ctx, "/pong.PongV1/Services", in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// PongV1Server is the server API for PongV1 service.
|
// PongV1Server is the server API for PongV1 service.
|
||||||
// All implementations must embed UnimplementedPongV1Server
|
// All implementations must embed UnimplementedPongV1Server
|
||||||
// for forward compatibility
|
// for forward compatibility
|
||||||
type PongV1Server interface {
|
type PongV1Server interface {
|
||||||
// Sends ping to the server
|
// Sends ping to the server
|
||||||
Ping(context.Context, *definition.Empty) (*PongV1PingResponse, error)
|
Ping(context.Context, *definition.Empty) (*PongV1PingResponse, error)
|
||||||
|
// Asks for the services details
|
||||||
|
Services(context.Context, *definition.Empty) (*PongV1ServicesResponse, error)
|
||||||
mustEmbedUnimplementedPongV1Server()
|
mustEmbedUnimplementedPongV1Server()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +73,9 @@ type UnimplementedPongV1Server struct {
|
||||||
func (UnimplementedPongV1Server) Ping(context.Context, *definition.Empty) (*PongV1PingResponse, error) {
|
func (UnimplementedPongV1Server) Ping(context.Context, *definition.Empty) (*PongV1PingResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented")
|
||||||
}
|
}
|
||||||
|
func (UnimplementedPongV1Server) Services(context.Context, *definition.Empty) (*PongV1ServicesResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method Services not implemented")
|
||||||
|
}
|
||||||
func (UnimplementedPongV1Server) mustEmbedUnimplementedPongV1Server() {}
|
func (UnimplementedPongV1Server) mustEmbedUnimplementedPongV1Server() {}
|
||||||
|
|
||||||
// UnsafePongV1Server may be embedded to opt out of forward compatibility for this service.
|
// UnsafePongV1Server may be embedded to opt out of forward compatibility for this service.
|
||||||
|
@ -91,6 +107,24 @@ func _PongV1_Ping_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _PongV1_Services_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(definition.Empty)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(PongV1Server).Services(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/pong.PongV1/Services",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(PongV1Server).Services(ctx, req.(*definition.Empty))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
// PongV1_ServiceDesc is the grpc.ServiceDesc for PongV1 service.
|
// PongV1_ServiceDesc is the grpc.ServiceDesc for PongV1 service.
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
@ -102,6 +136,10 @@ var PongV1_ServiceDesc = grpc.ServiceDesc{
|
||||||
MethodName: "Ping",
|
MethodName: "Ping",
|
||||||
Handler: _PongV1_Ping_Handler,
|
Handler: _PongV1_Ping_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "Services",
|
||||||
|
Handler: _PongV1_Services_Handler,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "integrations/pong/v1/definition/pong.proto",
|
Metadata: "integrations/pong/v1/definition/pong.proto",
|
||||||
|
|
|
@ -29,17 +29,54 @@ import (
|
||||||
|
|
||||||
pbPongV1 "github.com/arangodb/kube-arangodb/integrations/pong/v1/definition"
|
pbPongV1 "github.com/arangodb/kube-arangodb/integrations/pong/v1/definition"
|
||||||
pbSharedV1 "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition"
|
pbSharedV1 "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/svc"
|
"github.com/arangodb/kube-arangodb/pkg/util/svc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New() svc.Handler {
|
type Service struct {
|
||||||
return &impl{}
|
Name, Version string
|
||||||
|
Enabled bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) asService() *pbPongV1.PongV1Service {
|
||||||
|
return &pbPongV1.PongV1Service{
|
||||||
|
Name: s.Name,
|
||||||
|
Version: s.Version,
|
||||||
|
Enabled: s.Enabled,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(services ...Service) (svc.Handler, error) {
|
||||||
|
pServices := make(util.List[Service], 0, len(services))
|
||||||
|
|
||||||
|
for _, svc := range services {
|
||||||
|
if pServices.Contains(func(service Service) bool {
|
||||||
|
return service.Name == svc.Name && service.Version == svc.Version
|
||||||
|
}) {
|
||||||
|
return nil, errors.Errorf("Service %s/%s already registered", svc.Name, svc.Version)
|
||||||
|
}
|
||||||
|
|
||||||
|
pServices = pServices.Append(svc)
|
||||||
|
}
|
||||||
|
|
||||||
|
pServices = pServices.Sort(func(a Service, b Service) bool {
|
||||||
|
if a.Name == b.Name {
|
||||||
|
return a.Version < b.Version
|
||||||
|
}
|
||||||
|
|
||||||
|
return a.Name < b.Name
|
||||||
|
})
|
||||||
|
|
||||||
|
return &impl{services: pServices.List()}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ pbPongV1.PongV1Server = &impl{}
|
var _ pbPongV1.PongV1Server = &impl{}
|
||||||
var _ svc.Handler = &impl{}
|
var _ svc.Handler = &impl{}
|
||||||
|
|
||||||
type impl struct {
|
type impl struct {
|
||||||
|
services []Service
|
||||||
|
|
||||||
pbPongV1.UnimplementedPongV1Server
|
pbPongV1.UnimplementedPongV1Server
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +91,19 @@ func (i *impl) Health() svc.HealthState {
|
||||||
func (i *impl) Register(registrar *grpc.Server) {
|
func (i *impl) Register(registrar *grpc.Server) {
|
||||||
pbPongV1.RegisterPongV1Server(registrar, i)
|
pbPongV1.RegisterPongV1Server(registrar, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) Ping(context.Context, *pbSharedV1.Empty) (*pbPongV1.PongV1PingResponse, error) {
|
func (i *impl) Ping(context.Context, *pbSharedV1.Empty) (*pbPongV1.PongV1PingResponse, error) {
|
||||||
return &pbPongV1.PongV1PingResponse{Time: timestamppb.New(time.Now().UTC())}, nil
|
return &pbPongV1.PongV1PingResponse{Time: timestamppb.New(time.Now().UTC())}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *impl) Services(context.Context, *pbSharedV1.Empty) (*pbPongV1.PongV1ServicesResponse, error) {
|
||||||
|
var r = make([]*pbPongV1.PongV1Service, len(i.services))
|
||||||
|
|
||||||
|
for id := range i.services {
|
||||||
|
r[id] = i.services[id].asService()
|
||||||
|
}
|
||||||
|
|
||||||
|
return &pbPongV1.PongV1ServicesResponse{
|
||||||
|
Services: r,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
|
@ -33,10 +33,13 @@ import (
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/tests/tgrpc"
|
"github.com/arangodb/kube-arangodb/pkg/util/tests/tgrpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Client(t *testing.T, ctx context.Context) pbPongV1.PongV1Client {
|
func Client(t *testing.T, ctx context.Context, services ...Service) pbPongV1.PongV1Client {
|
||||||
|
h, err := New(services...)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
local := svc.NewService(svc.Configuration{
|
local := svc.NewService(svc.Configuration{
|
||||||
Address: "127.0.0.1:0",
|
Address: "127.0.0.1:0",
|
||||||
}, New())
|
}, h)
|
||||||
|
|
||||||
start := local.Start(ctx)
|
start := local.Start(ctx)
|
||||||
|
|
||||||
|
@ -61,3 +64,36 @@ func Test_Ping(t *testing.T) {
|
||||||
|
|
||||||
require.True(t, r2.GetTime().AsTime().After(r1.GetTime().AsTime()))
|
require.True(t, r2.GetTime().AsTime().After(r1.GetTime().AsTime()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Services(t *testing.T) {
|
||||||
|
ctx, c := context.WithCancel(context.Background())
|
||||||
|
defer c()
|
||||||
|
|
||||||
|
v2 := Service{
|
||||||
|
Name: "A",
|
||||||
|
Version: "V2",
|
||||||
|
Enabled: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
v3 := Service{
|
||||||
|
Name: "A",
|
||||||
|
Version: "V3",
|
||||||
|
Enabled: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
client := Client(t, ctx,
|
||||||
|
v3,
|
||||||
|
v2,
|
||||||
|
)
|
||||||
|
|
||||||
|
r1, err := client.Services(ctx, &pbSharedV1.Empty{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.Len(t, r1.GetServices(), 2)
|
||||||
|
|
||||||
|
require.NotNil(t, r1.GetServices()[0])
|
||||||
|
require.NotNil(t, r1.GetServices()[1])
|
||||||
|
|
||||||
|
require.EqualValues(t, v2.asService(), r1.GetServices()[0])
|
||||||
|
require.EqualValues(t, v3.asService(), r1.GetServices()[1])
|
||||||
|
}
|
||||||
|
|
|
@ -21,10 +21,13 @@
|
||||||
package clients
|
package clients
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
pbPongV1 "github.com/arangodb/kube-arangodb/integrations/pong/v1/definition"
|
pbPongV1 "github.com/arangodb/kube-arangodb/integrations/pong/v1/definition"
|
||||||
pbSharedV1 "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition"
|
pbSharedV1 "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/shutdown"
|
"github.com/arangodb/kube-arangodb/pkg/util/shutdown"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,6 +64,15 @@ func (s *pongV1) Register(cmd *cobra.Command) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
services, err := client.Services(shutdown.Context(), &pbSharedV1.Empty{})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, svc := range services.GetServices() {
|
||||||
|
println(fmt.Sprintf("%s.%s: %s", svc.GetName(), svc.GetVersion(), util.BoolSwitch(svc.GetEnabled(), "Enabled", "Disabled")))
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -32,6 +32,7 @@ type Factory func() Integration
|
||||||
|
|
||||||
type Integration interface {
|
type Integration interface {
|
||||||
Name() string
|
Name() string
|
||||||
|
|
||||||
Description() string
|
Description() string
|
||||||
|
|
||||||
Register(cmd *cobra.Command, fs FlagEnvHandler) error
|
Register(cmd *cobra.Command, fs FlagEnvHandler) error
|
||||||
|
|
|
@ -196,11 +196,7 @@ func (c *configuration) runWithContext(ctx context.Context, cancel context.Cance
|
||||||
|
|
||||||
var internalHandlers, externalHandlers, healthHandlers []svc.Handler
|
var internalHandlers, externalHandlers, healthHandlers []svc.Handler
|
||||||
|
|
||||||
pong := pbImplPongV1.New()
|
var services []pbImplPongV1.Service
|
||||||
|
|
||||||
internalHandlers = append(internalHandlers, pong)
|
|
||||||
externalHandlers = append(externalHandlers, pong)
|
|
||||||
healthHandlers = append(healthHandlers, pong)
|
|
||||||
|
|
||||||
for _, handler := range c.registered {
|
for _, handler := range c.registered {
|
||||||
if ok, err := cmd.Flags().GetBool(fmt.Sprintf("integration.%s", handler.Name())); err != nil {
|
if ok, err := cmd.Flags().GetBool(fmt.Sprintf("integration.%s", handler.Name())); err != nil {
|
||||||
|
@ -223,6 +219,17 @@ func (c *configuration) runWithContext(ctx context.Context, cancel context.Cance
|
||||||
Bool("external", externalEnabled).
|
Bool("external", externalEnabled).
|
||||||
Info("Service discovered")
|
Info("Service discovered")
|
||||||
|
|
||||||
|
ps := strings.Split(handler.Name(), ".")
|
||||||
|
if len(ps) < 2 {
|
||||||
|
return errors.Errorf("Expected atleast 2 elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
services = append(services, pbImplPongV1.Service{
|
||||||
|
Name: strings.Join(ps[:len(ps)-1], "."),
|
||||||
|
Version: ps[len(ps)-1],
|
||||||
|
Enabled: ok,
|
||||||
|
})
|
||||||
|
|
||||||
if ok && (internalEnabled || externalEnabled) {
|
if ok && (internalEnabled || externalEnabled) {
|
||||||
if svc, err := handler.Handler(ctx, cmd); err != nil {
|
if svc, err := handler.Handler(ctx, cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -239,6 +246,15 @@ func (c *configuration) runWithContext(ctx context.Context, cancel context.Cance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pong, err := pbImplPongV1.New(services...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
internalHandlers = append(internalHandlers, pong)
|
||||||
|
externalHandlers = append(externalHandlers, pong)
|
||||||
|
healthHandlers = append(healthHandlers, pong)
|
||||||
|
|
||||||
if c.health.shutdownEnabled {
|
if c.health.shutdownEnabled {
|
||||||
healthHandlers = append(healthHandlers, pbImplShutdownV1.New(cancel))
|
healthHandlers = append(healthHandlers, pbImplShutdownV1.New(cancel))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue