From c5ca558e5f29bea659b1ecb5f530cc6e07f4bd1a Mon Sep 17 00:00:00 2001 From: Ufuk Date: Mon, 30 Sep 2024 18:36:01 +0300 Subject: [PATCH] revert: health api --- docs/api-reference/apidocs.swagger.json | 146 ++---- .../openapiv2/apidocs.swagger.json | 144 ++---- internal/servers/healthServer.go | 10 +- internal/servers/server.go | 12 +- pkg/pb/base/v1/health.pb.go | 445 ----------------- pkg/pb/base/v1/health.pb.gw.go | 173 ------- pkg/pb/base/v1/health.pb.validate.go | 446 ------------------ pkg/pb/base/v1/health_grpc.pb.go | 227 --------- proto/base/v1/health.proto | 94 ---- 9 files changed, 88 insertions(+), 1609 deletions(-) delete mode 100644 pkg/pb/base/v1/health.pb.go delete mode 100644 pkg/pb/base/v1/health.pb.gw.go delete mode 100644 pkg/pb/base/v1/health.pb.validate.go delete mode 100644 pkg/pb/base/v1/health_grpc.pb.go delete mode 100644 proto/base/v1/health.proto diff --git a/docs/api-reference/apidocs.swagger.json b/docs/api-reference/apidocs.swagger.json index ff046f657..c373ea060 100644 --- a/docs/api-reference/apidocs.swagger.json +++ b/docs/api-reference/apidocs.swagger.json @@ -15,9 +15,6 @@ } }, "tags": [ - { - "name": "Health" - }, { "name": "Permission" }, @@ -47,54 +44,6 @@ "application/json" ], "paths": { - "/healthz": { - "get": { - "summary": "health api", - "operationId": "health.check", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/HealthCheckResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Status" - } - } - }, - "parameters": [ - { - "name": "service", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": [ - "Health" - ], - "x-codeSamples": [ - { - "label": "", - "lang": "", - "source": "" - }, - { - "label": "", - "lang": "", - "source": "" - }, - { - "label": "", - "lang": "", - "source": "" - } - ] - } - }, "/v1/tenants/create": { "post": { "summary": "create tenant", @@ -733,7 +682,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/Permission.CheckBody" + "$ref": "#/definitions/CheckBody" } } ], @@ -1379,7 +1328,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/Watch.WatchBody" + "$ref": "#/definitions/WatchBody" } } ], @@ -1601,6 +1550,41 @@ }, "description": "BundleWriteResponse is the response for a BundleWriteRequest.\nIt includes a name which could be used as an identifier or acknowledgment." }, + "CheckBody": { + "type": "object", + "properties": { + "metadata": { + "$ref": "#/definitions/PermissionCheckRequestMetadata", + "description": "Metadata associated with this request, required." + }, + "entity": { + "$ref": "#/definitions/Entity", + "example": "repository:1", + "description": "Entity on which the permission needs to be checked, required." + }, + "permission": { + "type": "string", + "description": "The action the user wants to perform on the resource" + }, + "subject": { + "$ref": "#/definitions/Subject", + "description": "Subject for which the permission needs to be checked, required." + }, + "context": { + "$ref": "#/definitions/Context", + "description": "Contextual data that can be dynamically added to permission check requests. See details on [Contextual Data](../../operations/contextual-tuples)" + }, + "arguments": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/Argument" + }, + "description": "Additional arguments associated with this request." + } + }, + "description": "PermissionCheckRequest is the request message for the Check method in the Permission service." + }, "CheckResult": { "type": "string", "enum": [ @@ -2205,14 +2189,6 @@ }, "description": "Function type with result and arg types." }, - "HealthCheckResponse": { - "type": "object", - "properties": { - "status": { - "$ref": "#/definitions/ServingStatus" - } - } - }, "Ident": { "type": "object", "properties": { @@ -2437,41 +2413,6 @@ }, "title": "Partials contains the write, update and delete definitions" }, - "Permission.CheckBody": { - "type": "object", - "properties": { - "metadata": { - "$ref": "#/definitions/PermissionCheckRequestMetadata", - "description": "Metadata associated with this request, required." - }, - "entity": { - "$ref": "#/definitions/Entity", - "example": "repository:1", - "description": "Entity on which the permission needs to be checked, required." - }, - "permission": { - "type": "string", - "description": "The action the user wants to perform on the resource" - }, - "subject": { - "$ref": "#/definitions/Subject", - "description": "Subject for which the permission needs to be checked, required." - }, - "context": { - "$ref": "#/definitions/Context", - "description": "Contextual data that can be dynamically added to permission check requests. See details on [Contextual Data](../../operations/contextual-tuples)" - }, - "arguments": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/Argument" - }, - "description": "Additional arguments associated with this request." - } - }, - "description": "PermissionCheckRequest is the request message for the Check method in the Permission service." - }, "Permission.ExpandBody": { "type": "object", "properties": { @@ -3096,17 +3037,6 @@ }, "description": "A field selection expression. e.g. `request.auth`." }, - "ServingStatus": { - "type": "string", - "enum": [ - "UNKNOWN", - "SERVING", - "NOT_SERVING", - "SERVICE_UNKNOWN" - ], - "default": "UNKNOWN", - "description": " - SERVICE_UNKNOWN: Used only by the Watch method." - }, "SourceInfo": { "type": "object", "properties": { @@ -3398,7 +3328,7 @@ } } }, - "Watch.WatchBody": { + "WatchBody": { "type": "object", "properties": { "snap_token": { diff --git a/docs/api-reference/openapiv2/apidocs.swagger.json b/docs/api-reference/openapiv2/apidocs.swagger.json index d7d07d14e..8ccb762e8 100644 --- a/docs/api-reference/openapiv2/apidocs.swagger.json +++ b/docs/api-reference/openapiv2/apidocs.swagger.json @@ -15,9 +15,6 @@ } }, "tags": [ - { - "name": "Health" - }, { "name": "Permission" }, @@ -47,54 +44,6 @@ "application/json" ], "paths": { - "/healthz": { - "get": { - "summary": "health api", - "operationId": "health.check", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/HealthCheckResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Status" - } - } - }, - "parameters": [ - { - "name": "service", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": [ - "Health" - ], - "x-codeSamples": [ - { - "label": "", - "lang": "", - "source": "" - }, - { - "label": "", - "lang": "", - "source": "" - }, - { - "label": "", - "lang": "", - "source": "" - } - ] - } - }, "/v1/tenants/create": { "post": { "summary": "create tenant", @@ -733,7 +682,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/Permission.CheckBody" + "$ref": "#/definitions/CheckBody" } } ], @@ -1379,7 +1328,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/Watch.WatchBody" + "$ref": "#/definitions/WatchBody" } } ], @@ -1599,6 +1548,41 @@ }, "description": "BundleWriteResponse is the response for a BundleWriteRequest.\nIt includes a name which could be used as an identifier or acknowledgment." }, + "CheckBody": { + "type": "object", + "properties": { + "metadata": { + "$ref": "#/definitions/PermissionCheckRequestMetadata", + "description": "Metadata associated with this request, required." + }, + "entity": { + "$ref": "#/definitions/Entity", + "example": "repository:1", + "description": "Entity on which the permission needs to be checked, required." + }, + "permission": { + "type": "string", + "description": "The action the user wants to perform on the resource" + }, + "subject": { + "$ref": "#/definitions/Subject", + "description": "Subject for which the permission needs to be checked, required." + }, + "context": { + "$ref": "#/definitions/Context", + "description": "Contextual data that can be dynamically added to permission check requests. See details on [Contextual Data](../../operations/contextual-tuples)" + }, + "arguments": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/Argument" + }, + "description": "Additional arguments associated with this request." + } + }, + "description": "PermissionCheckRequest is the request message for the Check method in the Permission service." + }, "CheckResult": { "type": "string", "enum": [ @@ -2195,14 +2179,6 @@ }, "description": "Function type with result and arg types." }, - "HealthCheckResponse": { - "type": "object", - "properties": { - "status": { - "$ref": "#/definitions/ServingStatus" - } - } - }, "Ident": { "type": "object", "properties": { @@ -2423,41 +2399,6 @@ }, "title": "Partials contains the write, update and delete definitions" }, - "Permission.CheckBody": { - "type": "object", - "properties": { - "metadata": { - "$ref": "#/definitions/PermissionCheckRequestMetadata", - "description": "Metadata associated with this request, required." - }, - "entity": { - "$ref": "#/definitions/Entity", - "example": "repository:1", - "description": "Entity on which the permission needs to be checked, required." - }, - "permission": { - "type": "string", - "description": "The action the user wants to perform on the resource" - }, - "subject": { - "$ref": "#/definitions/Subject", - "description": "Subject for which the permission needs to be checked, required." - }, - "context": { - "$ref": "#/definitions/Context", - "description": "Contextual data that can be dynamically added to permission check requests. See details on [Contextual Data](../../operations/contextual-tuples)" - }, - "arguments": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/Argument" - }, - "description": "Additional arguments associated with this request." - } - }, - "description": "PermissionCheckRequest is the request message for the Check method in the Permission service." - }, "Permission.ExpandBody": { "type": "object", "properties": { @@ -3076,15 +3017,6 @@ }, "description": "A field selection expression. e.g. `request.auth`." }, - "ServingStatus": { - "type": "string", - "enum": [ - "SERVING", - "NOT_SERVING", - "SERVICE_UNKNOWN" - ], - "description": " - SERVICE_UNKNOWN: Used only by the Watch method." - }, "SourceInfo": { "type": "object", "properties": { @@ -3376,7 +3308,7 @@ } } }, - "Watch.WatchBody": { + "WatchBody": { "type": "object", "properties": { "snap_token": { diff --git a/internal/servers/healthServer.go b/internal/servers/healthServer.go index ac0e11ea0..5068622e9 100644 --- a/internal/servers/healthServer.go +++ b/internal/servers/healthServer.go @@ -3,14 +3,14 @@ package servers import ( "context" - v1 "github.com/Permify/permify/pkg/pb/base/v1" "google.golang.org/grpc/codes" + health "google.golang.org/grpc/health/grpc_health_v1" "google.golang.org/grpc/status" ) // HealthServer - Structure for Health Server type HealthServer struct { - v1.UnimplementedHealthServer + health.UnimplementedHealthServer } // NewHealthServer - Creates new HealthServer Server @@ -19,12 +19,12 @@ func NewHealthServer() *HealthServer { } // Check - Return health check status response -func (s *HealthServer) Check(_ context.Context, _ *v1.HealthCheckRequest) (*v1.HealthCheckResponse, error) { - return &v1.HealthCheckResponse{Status: v1.HealthCheckResponse_SERVING}, nil +func (s *HealthServer) Check(_ context.Context, _ *health.HealthCheckRequest) (*health.HealthCheckResponse, error) { + return &health.HealthCheckResponse{Status: health.HealthCheckResponse_SERVING}, nil } // Watch - TO:DO -func (s *HealthServer) Watch(_ *v1.HealthCheckRequest, _ v1.Health_WatchServer) error { +func (s *HealthServer) Watch(_ *health.HealthCheckRequest, _ health.Health_WatchServer) error { // Example of how to register both methods but only implement the Check method. return status.Error(codes.Unimplemented, "unimplemented") } diff --git a/internal/servers/server.go b/internal/servers/server.go index 21b124a57..5f84626d0 100644 --- a/internal/servers/server.go +++ b/internal/servers/server.go @@ -35,6 +35,7 @@ import ( "github.com/Permify/permify/internal/middleware" "github.com/Permify/permify/internal/storage" grpcV1 "github.com/Permify/permify/pkg/pb/base/v1" + health "google.golang.org/grpc/health/grpc_health_v1" ) var ( @@ -181,15 +182,17 @@ func (s *Container) Run( grpcV1.RegisterBundleServer(grpcServer, NewBundleServer(s.BR, s.BW)) grpcV1.RegisterTenancyServer(grpcServer, NewTenancyServer(s.TR, s.TW)) grpcV1.RegisterWatchServer(grpcServer, NewWatchServer(s.W, s.DR)) - grpcV1.RegisterHealthServer(grpcServer, NewHealthServer()) + // Register health check and reflection services for gRPC. + health.RegisterHealthServer(grpcServer, NewHealthServer()) reflection.Register(grpcServer) // Create another gRPC server, presumably for invoking permissions. invokeServer := grpc.NewServer(opts...) grpcV1.RegisterPermissionServer(invokeServer, NewPermissionServer(localInvoker)) - grpcV1.RegisterHealthServer(invokeServer, NewHealthServer()) + // Register health check and reflection services for the invokeServer. + health.RegisterHealthServer(invokeServer, NewHealthServer()) reflection.Register(invokeServer) // If profiling is enabled, set up the profiler using the net/http package. @@ -286,7 +289,9 @@ func (s *Container) Run( } }() + healthClient := health.NewHealthClient(conn) muxOpts := []runtime.ServeMuxOption{ + runtime.WithHealthzEndpoint(healthClient), runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.HTTPBodyMarshaler{ Marshaler: &runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ @@ -302,9 +307,6 @@ func (s *Container) Run( mux := runtime.NewServeMux(muxOpts...) - if err = grpcV1.RegisterHealthHandler(ctx, mux, conn); err != nil { - return err - } if err = grpcV1.RegisterPermissionHandler(ctx, mux, conn); err != nil { return err } diff --git a/pkg/pb/base/v1/health.pb.go b/pkg/pb/base/v1/health.pb.go deleted file mode 100644 index c257c2c6d..000000000 --- a/pkg/pb/base/v1/health.pb.go +++ /dev/null @@ -1,445 +0,0 @@ -// Copyright 2015 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc (unknown) -// source: base/v1/health.proto - -package basev1 - -import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" - _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - 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) -) - -type HealthCheckResponse_ServingStatus int32 - -const ( - HealthCheckResponse_UNKNOWN HealthCheckResponse_ServingStatus = 0 - HealthCheckResponse_SERVING HealthCheckResponse_ServingStatus = 1 - HealthCheckResponse_NOT_SERVING HealthCheckResponse_ServingStatus = 2 - HealthCheckResponse_SERVICE_UNKNOWN HealthCheckResponse_ServingStatus = 3 // Used only by the Watch method. -) - -// Enum value maps for HealthCheckResponse_ServingStatus. -var ( - HealthCheckResponse_ServingStatus_name = map[int32]string{ - 0: "UNKNOWN", - 1: "SERVING", - 2: "NOT_SERVING", - 3: "SERVICE_UNKNOWN", - } - HealthCheckResponse_ServingStatus_value = map[string]int32{ - "UNKNOWN": 0, - "SERVING": 1, - "NOT_SERVING": 2, - "SERVICE_UNKNOWN": 3, - } -) - -func (x HealthCheckResponse_ServingStatus) Enum() *HealthCheckResponse_ServingStatus { - p := new(HealthCheckResponse_ServingStatus) - *p = x - return p -} - -func (x HealthCheckResponse_ServingStatus) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (HealthCheckResponse_ServingStatus) Descriptor() protoreflect.EnumDescriptor { - return file_base_v1_health_proto_enumTypes[0].Descriptor() -} - -func (HealthCheckResponse_ServingStatus) Type() protoreflect.EnumType { - return &file_base_v1_health_proto_enumTypes[0] -} - -func (x HealthCheckResponse_ServingStatus) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use HealthCheckResponse_ServingStatus.Descriptor instead. -func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) { - return file_base_v1_health_proto_rawDescGZIP(), []int{1, 0} -} - -type HealthCheckRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` -} - -func (x *HealthCheckRequest) Reset() { - *x = HealthCheckRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_base_v1_health_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HealthCheckRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HealthCheckRequest) ProtoMessage() {} - -func (x *HealthCheckRequest) ProtoReflect() protoreflect.Message { - mi := &file_base_v1_health_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 HealthCheckRequest.ProtoReflect.Descriptor instead. -func (*HealthCheckRequest) Descriptor() ([]byte, []int) { - return file_base_v1_health_proto_rawDescGZIP(), []int{0} -} - -func (x *HealthCheckRequest) GetService() string { - if x != nil { - return x.Service - } - return "" -} - -type HealthCheckResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Status HealthCheckResponse_ServingStatus `protobuf:"varint,1,opt,name=status,proto3,enum=base.v1.HealthCheckResponse_ServingStatus" json:"status,omitempty"` -} - -func (x *HealthCheckResponse) Reset() { - *x = HealthCheckResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_base_v1_health_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HealthCheckResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HealthCheckResponse) ProtoMessage() {} - -func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message { - mi := &file_base_v1_health_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 HealthCheckResponse.ProtoReflect.Descriptor instead. -func (*HealthCheckResponse) Descriptor() ([]byte, []int) { - return file_base_v1_health_proto_rawDescGZIP(), []int{1} -} - -func (x *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus { - if x != nil { - return x.Status - } - return HealthCheckResponse_UNKNOWN -} - -type HealthRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *HealthRequest) Reset() { - *x = HealthRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_base_v1_health_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HealthRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HealthRequest) ProtoMessage() {} - -func (x *HealthRequest) ProtoReflect() protoreflect.Message { - mi := &file_base_v1_health_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 HealthRequest.ProtoReflect.Descriptor instead. -func (*HealthRequest) Descriptor() ([]byte, []int) { - return file_base_v1_health_proto_rawDescGZIP(), []int{2} -} - -type HealthResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` -} - -func (x *HealthResponse) Reset() { - *x = HealthResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_base_v1_health_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HealthResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HealthResponse) ProtoMessage() {} - -func (x *HealthResponse) ProtoReflect() protoreflect.Message { - mi := &file_base_v1_health_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 HealthResponse.ProtoReflect.Descriptor instead. -func (*HealthResponse) Descriptor() ([]byte, []int) { - return file_base_v1_health_proto_rawDescGZIP(), []int{3} -} - -func (x *HealthResponse) GetStatus() string { - if x != nil { - return x.Status - } - return "" -} - -var File_base_v1_health_proto protoreflect.FileDescriptor - -var file_base_v1_health_proto_rawDesc = []byte{ - 0x0a, 0x14, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x1a, - 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, - 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 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, 0x2e, 0x0a, 0x12, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, - 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0xaa, 0x01, 0x0a, 0x13, 0x48, 0x65, 0x61, 0x6c, 0x74, - 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, - 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2a, - 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, - 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x22, 0x4f, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, - 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x45, 0x52, 0x56, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0f, 0x0a, - 0x0b, 0x4e, 0x4f, 0x54, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x13, - 0x0a, 0x0f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, - 0x4e, 0x10, 0x03, 0x22, 0x0f, 0x0a, 0x0d, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x22, 0x28, 0x0a, 0x0e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x32, 0xe5, - 0x02, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x94, 0x02, 0x0a, 0x05, 0x43, 0x68, - 0x65, 0x63, 0x6b, 0x12, 0x1b, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, - 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1c, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, - 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xcf, - 0x01, 0x92, 0x41, 0xbb, 0x01, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x0a, 0x68, - 0x65, 0x61, 0x6c, 0x74, 0x68, 0x20, 0x61, 0x70, 0x69, 0x2a, 0x0c, 0x68, 0x65, 0x61, 0x6c, 0x74, - 0x68, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x6a, 0x96, 0x01, 0x0a, 0x0d, 0x78, 0x2d, 0x63, 0x6f, - 0x64, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x12, 0x84, 0x01, 0x32, 0x81, 0x01, 0x0a, - 0x29, 0x2a, 0x27, 0x0a, 0x0b, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x02, 0x1a, 0x00, - 0x0a, 0x0a, 0x0a, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x12, 0x02, 0x1a, 0x00, 0x0a, 0x0c, 0x0a, 0x06, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x02, 0x1a, 0x00, 0x0a, 0x29, 0x2a, 0x27, 0x0a, 0x0b, - 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x02, 0x1a, 0x00, 0x0a, 0x0a, 0x0a, 0x04, 0x6c, - 0x61, 0x6e, 0x67, 0x12, 0x02, 0x1a, 0x00, 0x0a, 0x0c, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x12, 0x02, 0x1a, 0x00, 0x0a, 0x29, 0x2a, 0x27, 0x0a, 0x0b, 0x0a, 0x05, 0x6c, 0x61, 0x62, - 0x65, 0x6c, 0x12, 0x02, 0x1a, 0x00, 0x0a, 0x0a, 0x0a, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x12, 0x02, - 0x1a, 0x00, 0x0a, 0x0c, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x02, 0x1a, 0x00, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x7a, - 0x12, 0x44, 0x0a, 0x05, 0x57, 0x61, 0x74, 0x63, 0x68, 0x12, 0x1b, 0x2e, 0x62, 0x61, 0x73, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x89, 0x01, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x62, - 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x66, 0x79, 0x2f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x66, - 0x79, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, - 0x3b, 0x62, 0x61, 0x73, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x58, 0x58, 0xaa, 0x02, 0x07, - 0x42, 0x61, 0x73, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x56, - 0x31, 0xe2, 0x02, 0x13, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x42, 0x61, 0x73, 0x65, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_base_v1_health_proto_rawDescOnce sync.Once - file_base_v1_health_proto_rawDescData = file_base_v1_health_proto_rawDesc -) - -func file_base_v1_health_proto_rawDescGZIP() []byte { - file_base_v1_health_proto_rawDescOnce.Do(func() { - file_base_v1_health_proto_rawDescData = protoimpl.X.CompressGZIP(file_base_v1_health_proto_rawDescData) - }) - return file_base_v1_health_proto_rawDescData -} - -var file_base_v1_health_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_base_v1_health_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_base_v1_health_proto_goTypes = []any{ - (HealthCheckResponse_ServingStatus)(0), // 0: base.v1.HealthCheckResponse.ServingStatus - (*HealthCheckRequest)(nil), // 1: base.v1.HealthCheckRequest - (*HealthCheckResponse)(nil), // 2: base.v1.HealthCheckResponse - (*HealthRequest)(nil), // 3: base.v1.HealthRequest - (*HealthResponse)(nil), // 4: base.v1.HealthResponse -} -var file_base_v1_health_proto_depIdxs = []int32{ - 0, // 0: base.v1.HealthCheckResponse.status:type_name -> base.v1.HealthCheckResponse.ServingStatus - 1, // 1: base.v1.Health.Check:input_type -> base.v1.HealthCheckRequest - 1, // 2: base.v1.Health.Watch:input_type -> base.v1.HealthCheckRequest - 2, // 3: base.v1.Health.Check:output_type -> base.v1.HealthCheckResponse - 2, // 4: base.v1.Health.Watch:output_type -> base.v1.HealthCheckResponse - 3, // [3:5] is the sub-list for method output_type - 1, // [1:3] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_base_v1_health_proto_init() } -func file_base_v1_health_proto_init() { - if File_base_v1_health_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_base_v1_health_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*HealthCheckRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_base_v1_health_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*HealthCheckResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_base_v1_health_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*HealthRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_base_v1_health_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*HealthResponse); 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_base_v1_health_proto_rawDesc, - NumEnums: 1, - NumMessages: 4, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_base_v1_health_proto_goTypes, - DependencyIndexes: file_base_v1_health_proto_depIdxs, - EnumInfos: file_base_v1_health_proto_enumTypes, - MessageInfos: file_base_v1_health_proto_msgTypes, - }.Build() - File_base_v1_health_proto = out.File - file_base_v1_health_proto_rawDesc = nil - file_base_v1_health_proto_goTypes = nil - file_base_v1_health_proto_depIdxs = nil -} diff --git a/pkg/pb/base/v1/health.pb.gw.go b/pkg/pb/base/v1/health.pb.gw.go deleted file mode 100644 index 9e88b87fb..000000000 --- a/pkg/pb/base/v1/health.pb.gw.go +++ /dev/null @@ -1,173 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: base/v1/health.proto - -/* -Package basev1 is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package basev1 - -import ( - "context" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = metadata.Join - -var ( - filter_Health_Check_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Health_Check_0(ctx context.Context, marshaler runtime.Marshaler, client HealthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq HealthCheckRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Health_Check_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Check(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Health_Check_0(ctx context.Context, marshaler runtime.Marshaler, server HealthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq HealthCheckRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Health_Check_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Check(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterHealthHandlerServer registers the http handlers for service Health to "mux". -// UnaryRPC :call HealthServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterHealthHandlerFromEndpoint instead. -func RegisterHealthHandlerServer(ctx context.Context, mux *runtime.ServeMux, server HealthServer) error { - - mux.Handle("GET", pattern_Health_Check_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/base.v1.Health/Check", runtime.WithHTTPPathPattern("/healthz")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Health_Check_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_Health_Check_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterHealthHandlerFromEndpoint is same as RegisterHealthHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterHealthHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterHealthHandler(ctx, mux, conn) -} - -// RegisterHealthHandler registers the http handlers for service Health to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterHealthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterHealthHandlerClient(ctx, mux, NewHealthClient(conn)) -} - -// RegisterHealthHandlerClient registers the http handlers for service Health -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "HealthClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "HealthClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "HealthClient" to call the correct interceptors. -func RegisterHealthHandlerClient(ctx context.Context, mux *runtime.ServeMux, client HealthClient) error { - - mux.Handle("GET", pattern_Health_Check_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/base.v1.Health/Check", runtime.WithHTTPPathPattern("/healthz")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Health_Check_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_Health_Check_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Health_Check_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"healthz"}, "")) -) - -var ( - forward_Health_Check_0 = runtime.ForwardResponseMessage -) diff --git a/pkg/pb/base/v1/health.pb.validate.go b/pkg/pb/base/v1/health.pb.validate.go deleted file mode 100644 index 77456fadc..000000000 --- a/pkg/pb/base/v1/health.pb.validate.go +++ /dev/null @@ -1,446 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: base/v1/health.proto - -package basev1 - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// 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) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on HealthCheckRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *HealthCheckRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on HealthCheckRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// HealthCheckRequestMultiError, or nil if none found. -func (m *HealthCheckRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *HealthCheckRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Service - - if len(errors) > 0 { - return HealthCheckRequestMultiError(errors) - } - - return nil -} - -// HealthCheckRequestMultiError is an error wrapping multiple validation errors -// returned by HealthCheckRequest.ValidateAll() if the designated constraints -// aren't met. -type HealthCheckRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m HealthCheckRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m HealthCheckRequestMultiError) AllErrors() []error { return m } - -// HealthCheckRequestValidationError is the validation error returned by -// HealthCheckRequest.Validate if the designated constraints aren't met. -type HealthCheckRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e HealthCheckRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e HealthCheckRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e HealthCheckRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e HealthCheckRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e HealthCheckRequestValidationError) ErrorName() string { - return "HealthCheckRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e HealthCheckRequestValidationError) 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 %sHealthCheckRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = HealthCheckRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = HealthCheckRequestValidationError{} - -// Validate checks the field values on HealthCheckResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *HealthCheckResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on HealthCheckResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// HealthCheckResponseMultiError, or nil if none found. -func (m *HealthCheckResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *HealthCheckResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Status - - if len(errors) > 0 { - return HealthCheckResponseMultiError(errors) - } - - return nil -} - -// HealthCheckResponseMultiError is an error wrapping multiple validation -// errors returned by HealthCheckResponse.ValidateAll() if the designated -// constraints aren't met. -type HealthCheckResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m HealthCheckResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m HealthCheckResponseMultiError) AllErrors() []error { return m } - -// HealthCheckResponseValidationError is the validation error returned by -// HealthCheckResponse.Validate if the designated constraints aren't met. -type HealthCheckResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e HealthCheckResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e HealthCheckResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e HealthCheckResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e HealthCheckResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e HealthCheckResponseValidationError) ErrorName() string { - return "HealthCheckResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e HealthCheckResponseValidationError) 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 %sHealthCheckResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = HealthCheckResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = HealthCheckResponseValidationError{} - -// Validate checks the field values on HealthRequest with the rules defined in -// the proto definition for this message. If any rules are violated, the first -// error encountered is returned, or nil if there are no violations. -func (m *HealthRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on HealthRequest with the rules defined -// in the proto definition for this message. If any rules are violated, the -// result is a list of violation errors wrapped in HealthRequestMultiError, or -// nil if none found. -func (m *HealthRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *HealthRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return HealthRequestMultiError(errors) - } - - return nil -} - -// HealthRequestMultiError is an error wrapping multiple validation errors -// returned by HealthRequest.ValidateAll() if the designated constraints -// aren't met. -type HealthRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m HealthRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m HealthRequestMultiError) AllErrors() []error { return m } - -// HealthRequestValidationError is the validation error returned by -// HealthRequest.Validate if the designated constraints aren't met. -type HealthRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e HealthRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e HealthRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e HealthRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e HealthRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e HealthRequestValidationError) ErrorName() string { return "HealthRequestValidationError" } - -// Error satisfies the builtin error interface -func (e HealthRequestValidationError) 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 %sHealthRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = HealthRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = HealthRequestValidationError{} - -// Validate checks the field values on HealthResponse with the rules defined in -// the proto definition for this message. If any rules are violated, the first -// error encountered is returned, or nil if there are no violations. -func (m *HealthResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on HealthResponse with the rules defined -// in the proto definition for this message. If any rules are violated, the -// result is a list of violation errors wrapped in HealthResponseMultiError, -// or nil if none found. -func (m *HealthResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *HealthResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Status - - if len(errors) > 0 { - return HealthResponseMultiError(errors) - } - - return nil -} - -// HealthResponseMultiError is an error wrapping multiple validation errors -// returned by HealthResponse.ValidateAll() if the designated constraints -// aren't met. -type HealthResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m HealthResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m HealthResponseMultiError) AllErrors() []error { return m } - -// HealthResponseValidationError is the validation error returned by -// HealthResponse.Validate if the designated constraints aren't met. -type HealthResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e HealthResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e HealthResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e HealthResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e HealthResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e HealthResponseValidationError) ErrorName() string { return "HealthResponseValidationError" } - -// Error satisfies the builtin error interface -func (e HealthResponseValidationError) 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 %sHealthResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = HealthResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = HealthResponseValidationError{} diff --git a/pkg/pb/base/v1/health_grpc.pb.go b/pkg/pb/base/v1/health_grpc.pb.go deleted file mode 100644 index f036e25c8..000000000 --- a/pkg/pb/base/v1/health_grpc.pb.go +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2015 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto - -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.4.0 -// - protoc (unknown) -// source: base/v1/health.proto - -package basev1 - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.62.0 or later. -const _ = grpc.SupportPackageIsVersion8 - -const ( - Health_Check_FullMethodName = "/base.v1.Health/Check" - Health_Watch_FullMethodName = "/base.v1.Health/Watch" -) - -// HealthClient is the client API for Health service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type HealthClient interface { - // If the requested service is unknown, the call will fail with status - // NOT_FOUND. - Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) - // Performs a watch for the serving status of the requested service. - // The server will immediately send back a message indicating the current - // serving status. It will then subsequently send a new message whenever - // the service's serving status changes. - // - // If the requested service is unknown when the call is received, the - // server will send a message setting the serving status to - // SERVICE_UNKNOWN but will *not* terminate the call. If at some - // future point, the serving status of the service becomes known, the - // server will send a new message with the service's serving status. - // - // If the call terminates with status UNIMPLEMENTED, then clients - // should assume this method is not supported and should not retry the - // call. If the call terminates with any other status (including OK), - // clients should retry the call with appropriate exponential backoff. - Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error) -} - -type healthClient struct { - cc grpc.ClientConnInterface -} - -func NewHealthClient(cc grpc.ClientConnInterface) HealthClient { - return &healthClient{cc} -} - -func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(HealthCheckResponse) - err := c.cc.Invoke(ctx, Health_Check_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &Health_ServiceDesc.Streams[0], Health_Watch_FullMethodName, cOpts...) - if err != nil { - return nil, err - } - x := &healthWatchClient{ClientStream: 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 Health_WatchClient interface { - Recv() (*HealthCheckResponse, error) - grpc.ClientStream -} - -type healthWatchClient struct { - grpc.ClientStream -} - -func (x *healthWatchClient) Recv() (*HealthCheckResponse, error) { - m := new(HealthCheckResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// HealthServer is the server API for Health service. -// All implementations must embed UnimplementedHealthServer -// for forward compatibility -type HealthServer interface { - // If the requested service is unknown, the call will fail with status - // NOT_FOUND. - Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) - // Performs a watch for the serving status of the requested service. - // The server will immediately send back a message indicating the current - // serving status. It will then subsequently send a new message whenever - // the service's serving status changes. - // - // If the requested service is unknown when the call is received, the - // server will send a message setting the serving status to - // SERVICE_UNKNOWN but will *not* terminate the call. If at some - // future point, the serving status of the service becomes known, the - // server will send a new message with the service's serving status. - // - // If the call terminates with status UNIMPLEMENTED, then clients - // should assume this method is not supported and should not retry the - // call. If the call terminates with any other status (including OK), - // clients should retry the call with appropriate exponential backoff. - Watch(*HealthCheckRequest, Health_WatchServer) error - mustEmbedUnimplementedHealthServer() -} - -// UnimplementedHealthServer must be embedded to have forward compatible implementations. -type UnimplementedHealthServer struct { -} - -func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") -} -func (UnimplementedHealthServer) Watch(*HealthCheckRequest, Health_WatchServer) error { - return status.Errorf(codes.Unimplemented, "method Watch not implemented") -} -func (UnimplementedHealthServer) mustEmbedUnimplementedHealthServer() {} - -// UnsafeHealthServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to HealthServer will -// result in compilation errors. -type UnsafeHealthServer interface { - mustEmbedUnimplementedHealthServer() -} - -func RegisterHealthServer(s grpc.ServiceRegistrar, srv HealthServer) { - s.RegisterService(&Health_ServiceDesc, srv) -} - -func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HealthCheckRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(HealthServer).Check(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Health_Check_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Health_Watch_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(HealthCheckRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(HealthServer).Watch(m, &healthWatchServer{ServerStream: stream}) -} - -type Health_WatchServer interface { - Send(*HealthCheckResponse) error - grpc.ServerStream -} - -type healthWatchServer struct { - grpc.ServerStream -} - -func (x *healthWatchServer) Send(m *HealthCheckResponse) error { - return x.ServerStream.SendMsg(m) -} - -// Health_ServiceDesc is the grpc.ServiceDesc for Health service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Health_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "base.v1.Health", - HandlerType: (*HealthServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Check", - Handler: _Health_Check_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Watch", - Handler: _Health_Watch_Handler, - ServerStreams: true, - }, - }, - Metadata: "base/v1/health.proto", -} diff --git a/proto/base/v1/health.proto b/proto/base/v1/health.proto deleted file mode 100644 index 771a9efaf..000000000 --- a/proto/base/v1/health.proto +++ /dev/null @@ -1,94 +0,0 @@ -syntax = "proto3"; -package base.v1; - -import "google/api/annotations.proto"; -import "protoc-gen-openapiv2/options/annotations.proto"; -import "validate/validate.proto"; - -option go_package = "github.com/Permify/permify/pkg/pb/base/v1"; - - -message HealthCheckRequest { - string service = 1; -} - -message HealthCheckResponse { - enum ServingStatus { - UNKNOWN = 0; - SERVING = 1; - NOT_SERVING = 2; - SERVICE_UNKNOWN = 3; // Used only by the Watch method. - } - ServingStatus status = 1; -} - -service Health { - // If the requested service is unknown, the call will fail with status - // NOT_FOUND. - rpc Check(HealthCheckRequest) returns (HealthCheckResponse){ - option (google.api.http) = {get: "/healthz"}; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - summary: "health api" - tags: ["Health"] - operation_id: "health.check" - description: "" - extensions: { - key: "x-codeSamples" - value: { - list_value: { - values: { - struct_value: { - fields: { - key: "lang" - value: {string_value: ""} - } - fields: { - key: "label" - value: {string_value: ""} - } - fields: { - key: "source" - value: {string_value: ""} - } - } - } - values: { - struct_value: { - fields: { - key: "lang" - value: {string_value: ""} - } - fields: { - key: "label" - value: {string_value: ""} - } - fields: { - key: "source" - value: {string_value: ""} - } - } - } - values: { - struct_value: { - fields: { - key: "lang" - value: {string_value: ""} - } - fields: { - key: "label" - value: {string_value: ""} - } - fields: { - key: "source" - value: {string_value: ""} - } - } - } - } - } - } - }; - } - - rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse); -} \ No newline at end of file