From aeaa2a7804ffae35eb180d9a7a9a27eb70f9a207 Mon Sep 17 00:00:00 2001 From: albert Date: Tue, 29 Apr 2025 18:29:58 +0200 Subject: [PATCH] first commit --- .gitignore | 1 + .vscode/settings.json | 3 + LICENSE | 0 Makefile | 48 ++++ README.md | 0 cmd/admin.go | 40 ++++ cmd/comunicator.go | 40 ++++ cmd/core.go | 40 ++++ cmd/monitor.go | 40 ++++ cmd/root.go | 51 +++++ go.mod | 10 + go.sum | 10 + .../go-telecom/proto/adaptor/adaptor.pb.go | 197 +++++++++++++++++ .../proto/adaptor/adaptor_grpc.pb.go | 160 ++++++++++++++ .../albert/go-telecom/proto/admin/admin.pb.go | 188 ++++++++++++++++ .../go-telecom/proto/admin/admin_grpc.pb.go | 160 ++++++++++++++ .../go-telecom/proto/common/common.pb.go | 160 ++++++++++++++ .../albert/go-telecom/proto/core/core.pb.go | 189 ++++++++++++++++ .../go-telecom/proto/core/core_grpc.pb.go | 160 ++++++++++++++ .../go-telecom/proto/monitor/monitor.pb.go | 206 ++++++++++++++++++ .../proto/monitor/monitor_grpc.pb.go | 160 ++++++++++++++ main.go | 11 + proto/adaptor.proto | 23 ++ proto/admin.proto | 22 ++ proto/common.proto | 9 + proto/core.proto | 22 ++ proto/monitor.proto | 24 ++ 27 files changed, 1974 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 cmd/admin.go create mode 100644 cmd/comunicator.go create mode 100644 cmd/core.go create mode 100644 cmd/monitor.go create mode 100644 cmd/root.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 internal/gen/git.espin.casa/albert/go-telecom/proto/adaptor/adaptor.pb.go create mode 100644 internal/gen/git.espin.casa/albert/go-telecom/proto/adaptor/adaptor_grpc.pb.go create mode 100644 internal/gen/git.espin.casa/albert/go-telecom/proto/admin/admin.pb.go create mode 100644 internal/gen/git.espin.casa/albert/go-telecom/proto/admin/admin_grpc.pb.go create mode 100644 internal/gen/git.espin.casa/albert/go-telecom/proto/common/common.pb.go create mode 100644 internal/gen/git.espin.casa/albert/go-telecom/proto/core/core.pb.go create mode 100644 internal/gen/git.espin.casa/albert/go-telecom/proto/core/core_grpc.pb.go create mode 100644 internal/gen/git.espin.casa/albert/go-telecom/proto/monitor/monitor.pb.go create mode 100644 internal/gen/git.espin.casa/albert/go-telecom/proto/monitor/monitor_grpc.pb.go create mode 100644 main.go create mode 100644 proto/adaptor.proto create mode 100644 proto/admin.proto create mode 100644 proto/common.proto create mode 100644 proto/core.proto create mode 100644 proto/monitor.proto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c5e82d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..082b194 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "makefile.configureOnOpen": false +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..555ab8d --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +# Directorios +PROTO_DIR := proto +OUT_DIR := internal/gen + +# Ruta base Go para imports en go_package +GO_BASE := git.espin.casa/albert/go-telecom + +# Proto tools +PROTOC := protoc +PROTOC_GEN_GO := $(shell which protoc-gen-go) +PROTOC_GEN_GO_GRPC := $(shell which protoc-gen-go-grpc) + +# Archivos .proto +PROTO_FILES := $(wildcard $(PROTO_DIR)/*.proto) + +.PHONY: all proto build clean run-core run-admin run-monitor + +all: proto build + +## Compile todos los .proto a Go +proto: + @echo "🔧 Creating gRPC code from .proto..." + @mkdir -p $(OUT_DIR) + $(PROTOC) \ + --proto_path=$(PROTO_DIR) \ + --go_out=$(OUT_DIR) \ + --go-grpc_out=$(OUT_DIR) \ + $(PROTO_FILES) + +## Build binario principal (solo CLI cobra, por ejemplo) +build: + @echo "🔨 Compiling main binary..." + go build -o bin/procontel main.go + +## Ejecutar servicios individuales +run-core: + go run main.go core + +run-admin: + go run main.go admin + +run-monitor: + go run main.go monitor + +## Eliminar binarios y generación +clean: + @echo "🧹 Cleaning..." + rm -rf bin/ $(OUT_DIR) diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/cmd/admin.go b/cmd/admin.go new file mode 100644 index 0000000..e72e1d9 --- /dev/null +++ b/cmd/admin.go @@ -0,0 +1,40 @@ +/* +Copyright © 2025 NAME HERE + +*/ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// adminCmd represents the admin command +var adminCmd = &cobra.Command{ + Use: "admin", + Short: "A brief description of your command", + Long: `A longer description that spans multiple lines and likely contains examples +and usage of using your command. For example: + +Cobra is a CLI library for Go that empowers applications. +This application is a tool to generate the needed files +to quickly create a Cobra application.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("admin called") + }, +} + +func init() { + rootCmd.AddCommand(adminCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // adminCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // adminCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/cmd/comunicator.go b/cmd/comunicator.go new file mode 100644 index 0000000..85b0ee9 --- /dev/null +++ b/cmd/comunicator.go @@ -0,0 +1,40 @@ +/* +Copyright © 2025 NAME HERE + +*/ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// comunicatorCmd represents the comunicator command +var comunicatorCmd = &cobra.Command{ + Use: "comunicator", + Short: "A brief description of your command", + Long: `A longer description that spans multiple lines and likely contains examples +and usage of using your command. For example: + +Cobra is a CLI library for Go that empowers applications. +This application is a tool to generate the needed files +to quickly create a Cobra application.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("comunicator called") + }, +} + +func init() { + rootCmd.AddCommand(comunicatorCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // comunicatorCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // comunicatorCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/cmd/core.go b/cmd/core.go new file mode 100644 index 0000000..a6e8455 --- /dev/null +++ b/cmd/core.go @@ -0,0 +1,40 @@ +/* +Copyright © 2025 NAME HERE + +*/ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// coreCmd represents the core command +var coreCmd = &cobra.Command{ + Use: "core", + Short: "A brief description of your command", + Long: `A longer description that spans multiple lines and likely contains examples +and usage of using your command. For example: + +Cobra is a CLI library for Go that empowers applications. +This application is a tool to generate the needed files +to quickly create a Cobra application.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("core called") + }, +} + +func init() { + rootCmd.AddCommand(coreCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // coreCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // coreCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/cmd/monitor.go b/cmd/monitor.go new file mode 100644 index 0000000..899c112 --- /dev/null +++ b/cmd/monitor.go @@ -0,0 +1,40 @@ +/* +Copyright © 2025 NAME HERE + +*/ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// monitorCmd represents the monitor command +var monitorCmd = &cobra.Command{ + Use: "monitor", + Short: "A brief description of your command", + Long: `A longer description that spans multiple lines and likely contains examples +and usage of using your command. For example: + +Cobra is a CLI library for Go that empowers applications. +This application is a tool to generate the needed files +to quickly create a Cobra application.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("monitor called") + }, +} + +func init() { + rootCmd.AddCommand(monitorCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // monitorCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // monitorCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..2d1427c --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,51 @@ +/* +Copyright © 2025 NAME HERE + +*/ +package cmd + +import ( + "os" + + "github.com/spf13/cobra" +) + + + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "go-telecom", + Short: "A brief description of your application", + Long: `A longer description that spans multiple lines and likely contains +examples and usage of using your application. For example: + +Cobra is a CLI library for Go that empowers applications. +This application is a tool to generate the needed files +to quickly create a Cobra application.`, + // Uncomment the following line if your bare application + // has an action associated with it: + // Run: func(cmd *cobra.Command, args []string) { }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + err := rootCmd.Execute() + if err != nil { + os.Exit(1) + } +} + +func init() { + // Here you will define your flags and configuration settings. + // Cobra supports persistent flags, which, if defined here, + // will be global for your application. + + // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.go-telecom.yaml)") + + // Cobra also supports local flags, which will only run + // when this action is called directly. + rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} + + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a24e3ab --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module git.espin.casa/albert/go-telecom + +go 1.24.1 + +require github.com/spf13/cobra v1.9.1 + +require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/pflag v1.0.6 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ffae55e --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= +github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= +github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= +github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/gen/git.espin.casa/albert/go-telecom/proto/adaptor/adaptor.pb.go b/internal/gen/git.espin.casa/albert/go-telecom/proto/adaptor/adaptor.pb.go new file mode 100644 index 0000000..78c3794 --- /dev/null +++ b/internal/gen/git.espin.casa/albert/go-telecom/proto/adaptor/adaptor.pb.go @@ -0,0 +1,197 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: adaptor.proto + +package adaptor + +import ( + common "git.espin.casa/albert/go-telecom/proto/common" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 DataMessage struct { + state protoimpl.MessageState `protogen:"open.v1"` + Origin string `protobuf:"bytes,1,opt,name=origin,proto3" json:"origin,omitempty"` + Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DataMessage) Reset() { + *x = DataMessage{} + mi := &file_adaptor_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DataMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataMessage) ProtoMessage() {} + +func (x *DataMessage) ProtoReflect() protoreflect.Message { + mi := &file_adaptor_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DataMessage.ProtoReflect.Descriptor instead. +func (*DataMessage) Descriptor() ([]byte, []int) { + return file_adaptor_proto_rawDescGZIP(), []int{0} +} + +func (x *DataMessage) GetOrigin() string { + if x != nil { + return x.Origin + } + return "" +} + +func (x *DataMessage) GetPayload() []byte { + if x != nil { + return x.Payload + } + return nil +} + +func (x *DataMessage) GetTimestamp() int64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +type Ack struct { + state protoimpl.MessageState `protogen:"open.v1"` + Received bool `protobuf:"varint,1,opt,name=received,proto3" json:"received,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Ack) Reset() { + *x = Ack{} + mi := &file_adaptor_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Ack) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Ack) ProtoMessage() {} + +func (x *Ack) ProtoReflect() protoreflect.Message { + mi := &file_adaptor_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Ack.ProtoReflect.Descriptor instead. +func (*Ack) Descriptor() ([]byte, []int) { + return file_adaptor_proto_rawDescGZIP(), []int{1} +} + +func (x *Ack) GetReceived() bool { + if x != nil { + return x.Received + } + return false +} + +var File_adaptor_proto protoreflect.FileDescriptor + +const file_adaptor_proto_rawDesc = "" + + "\n" + + "\radaptor.proto\x12\aadapter\x1a\fcommon.proto\"]\n" + + "\vDataMessage\x12\x16\n" + + "\x06origin\x18\x01 \x01(\tR\x06origin\x12\x18\n" + + "\apayload\x18\x02 \x01(\fR\apayload\x12\x1c\n" + + "\ttimestamp\x18\x03 \x01(\x03R\ttimestamp\"!\n" + + "\x03Ack\x12\x1a\n" + + "\breceived\x18\x01 \x01(\bR\breceived2\x88\x01\n" + + "\x0eAdapterService\x12F\n" + + "\vHealthCheck\x12\x1a.common.HealthCheckRequest\x1a\x1b.common.HealthCheckResponse\x12.\n" + + "\bSendData\x12\x14.adapter.DataMessage\x1a\f.adapter.AckB8Z6git.espin.casa/albert/go-telecom/proto/adaptor;adaptorb\x06proto3" + +var ( + file_adaptor_proto_rawDescOnce sync.Once + file_adaptor_proto_rawDescData []byte +) + +func file_adaptor_proto_rawDescGZIP() []byte { + file_adaptor_proto_rawDescOnce.Do(func() { + file_adaptor_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_adaptor_proto_rawDesc), len(file_adaptor_proto_rawDesc))) + }) + return file_adaptor_proto_rawDescData +} + +var file_adaptor_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_adaptor_proto_goTypes = []any{ + (*DataMessage)(nil), // 0: adapter.DataMessage + (*Ack)(nil), // 1: adapter.Ack + (*common.HealthCheckRequest)(nil), // 2: common.HealthCheckRequest + (*common.HealthCheckResponse)(nil), // 3: common.HealthCheckResponse +} +var file_adaptor_proto_depIdxs = []int32{ + 2, // 0: adapter.AdapterService.HealthCheck:input_type -> common.HealthCheckRequest + 0, // 1: adapter.AdapterService.SendData:input_type -> adapter.DataMessage + 3, // 2: adapter.AdapterService.HealthCheck:output_type -> common.HealthCheckResponse + 1, // 3: adapter.AdapterService.SendData:output_type -> adapter.Ack + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_adaptor_proto_init() } +func file_adaptor_proto_init() { + if File_adaptor_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_adaptor_proto_rawDesc), len(file_adaptor_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_adaptor_proto_goTypes, + DependencyIndexes: file_adaptor_proto_depIdxs, + MessageInfos: file_adaptor_proto_msgTypes, + }.Build() + File_adaptor_proto = out.File + file_adaptor_proto_goTypes = nil + file_adaptor_proto_depIdxs = nil +} diff --git a/internal/gen/git.espin.casa/albert/go-telecom/proto/adaptor/adaptor_grpc.pb.go b/internal/gen/git.espin.casa/albert/go-telecom/proto/adaptor/adaptor_grpc.pb.go new file mode 100644 index 0000000..c55c61a --- /dev/null +++ b/internal/gen/git.espin.casa/albert/go-telecom/proto/adaptor/adaptor_grpc.pb.go @@ -0,0 +1,160 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: adaptor.proto + +package adaptor + +import ( + context "context" + common "git.espin.casa/albert/go-telecom/proto/common" + 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.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + AdapterService_HealthCheck_FullMethodName = "/adapter.AdapterService/HealthCheck" + AdapterService_SendData_FullMethodName = "/adapter.AdapterService/SendData" +) + +// AdapterServiceClient is the client API for AdapterService 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 AdapterServiceClient interface { + HealthCheck(ctx context.Context, in *common.HealthCheckRequest, opts ...grpc.CallOption) (*common.HealthCheckResponse, error) + SendData(ctx context.Context, in *DataMessage, opts ...grpc.CallOption) (*Ack, error) +} + +type adapterServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewAdapterServiceClient(cc grpc.ClientConnInterface) AdapterServiceClient { + return &adapterServiceClient{cc} +} + +func (c *adapterServiceClient) HealthCheck(ctx context.Context, in *common.HealthCheckRequest, opts ...grpc.CallOption) (*common.HealthCheckResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(common.HealthCheckResponse) + err := c.cc.Invoke(ctx, AdapterService_HealthCheck_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adapterServiceClient) SendData(ctx context.Context, in *DataMessage, opts ...grpc.CallOption) (*Ack, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Ack) + err := c.cc.Invoke(ctx, AdapterService_SendData_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AdapterServiceServer is the server API for AdapterService service. +// All implementations must embed UnimplementedAdapterServiceServer +// for forward compatibility. +type AdapterServiceServer interface { + HealthCheck(context.Context, *common.HealthCheckRequest) (*common.HealthCheckResponse, error) + SendData(context.Context, *DataMessage) (*Ack, error) + mustEmbedUnimplementedAdapterServiceServer() +} + +// UnimplementedAdapterServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedAdapterServiceServer struct{} + +func (UnimplementedAdapterServiceServer) HealthCheck(context.Context, *common.HealthCheckRequest) (*common.HealthCheckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HealthCheck not implemented") +} +func (UnimplementedAdapterServiceServer) SendData(context.Context, *DataMessage) (*Ack, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendData not implemented") +} +func (UnimplementedAdapterServiceServer) mustEmbedUnimplementedAdapterServiceServer() {} +func (UnimplementedAdapterServiceServer) testEmbeddedByValue() {} + +// UnsafeAdapterServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AdapterServiceServer will +// result in compilation errors. +type UnsafeAdapterServiceServer interface { + mustEmbedUnimplementedAdapterServiceServer() +} + +func RegisterAdapterServiceServer(s grpc.ServiceRegistrar, srv AdapterServiceServer) { + // If the following call pancis, it indicates UnimplementedAdapterServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&AdapterService_ServiceDesc, srv) +} + +func _AdapterService_HealthCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(common.HealthCheckRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdapterServiceServer).HealthCheck(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AdapterService_HealthCheck_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdapterServiceServer).HealthCheck(ctx, req.(*common.HealthCheckRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AdapterService_SendData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DataMessage) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdapterServiceServer).SendData(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AdapterService_SendData_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdapterServiceServer).SendData(ctx, req.(*DataMessage)) + } + return interceptor(ctx, in, info, handler) +} + +// AdapterService_ServiceDesc is the grpc.ServiceDesc for AdapterService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var AdapterService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "adapter.AdapterService", + HandlerType: (*AdapterServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "HealthCheck", + Handler: _AdapterService_HealthCheck_Handler, + }, + { + MethodName: "SendData", + Handler: _AdapterService_SendData_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "adaptor.proto", +} diff --git a/internal/gen/git.espin.casa/albert/go-telecom/proto/admin/admin.pb.go b/internal/gen/git.espin.casa/albert/go-telecom/proto/admin/admin.pb.go new file mode 100644 index 0000000..47bc9db --- /dev/null +++ b/internal/gen/git.espin.casa/albert/go-telecom/proto/admin/admin.pb.go @@ -0,0 +1,188 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: admin.proto + +package admin + +import ( + common "git.espin.casa/albert/go-telecom/proto/common" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 ConfigUpdateRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ConfigUpdateRequest) Reset() { + *x = ConfigUpdateRequest{} + mi := &file_admin_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ConfigUpdateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigUpdateRequest) ProtoMessage() {} + +func (x *ConfigUpdateRequest) ProtoReflect() protoreflect.Message { + mi := &file_admin_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigUpdateRequest.ProtoReflect.Descriptor instead. +func (*ConfigUpdateRequest) Descriptor() ([]byte, []int) { + return file_admin_proto_rawDescGZIP(), []int{0} +} + +func (x *ConfigUpdateRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *ConfigUpdateRequest) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +type ConfigUpdateResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Updated bool `protobuf:"varint,1,opt,name=updated,proto3" json:"updated,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ConfigUpdateResponse) Reset() { + *x = ConfigUpdateResponse{} + mi := &file_admin_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ConfigUpdateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigUpdateResponse) ProtoMessage() {} + +func (x *ConfigUpdateResponse) ProtoReflect() protoreflect.Message { + mi := &file_admin_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigUpdateResponse.ProtoReflect.Descriptor instead. +func (*ConfigUpdateResponse) Descriptor() ([]byte, []int) { + return file_admin_proto_rawDescGZIP(), []int{1} +} + +func (x *ConfigUpdateResponse) GetUpdated() bool { + if x != nil { + return x.Updated + } + return false +} + +var File_admin_proto protoreflect.FileDescriptor + +const file_admin_proto_rawDesc = "" + + "\n" + + "\vadmin.proto\x12\x05admin\x1a\fcommon.proto\"=\n" + + "\x13ConfigUpdateRequest\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value\"0\n" + + "\x14ConfigUpdateResponse\x12\x18\n" + + "\aupdated\x18\x01 \x01(\bR\aupdated2\x9f\x01\n" + + "\fAdminService\x12F\n" + + "\vHealthCheck\x12\x1a.common.HealthCheckRequest\x1a\x1b.common.HealthCheckResponse\x12G\n" + + "\fUpdateConfig\x12\x1a.admin.ConfigUpdateRequest\x1a\x1b.admin.ConfigUpdateResponseB4Z2git.espin.casa/albert/go-telecom/proto/admin;adminb\x06proto3" + +var ( + file_admin_proto_rawDescOnce sync.Once + file_admin_proto_rawDescData []byte +) + +func file_admin_proto_rawDescGZIP() []byte { + file_admin_proto_rawDescOnce.Do(func() { + file_admin_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_admin_proto_rawDesc), len(file_admin_proto_rawDesc))) + }) + return file_admin_proto_rawDescData +} + +var file_admin_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_admin_proto_goTypes = []any{ + (*ConfigUpdateRequest)(nil), // 0: admin.ConfigUpdateRequest + (*ConfigUpdateResponse)(nil), // 1: admin.ConfigUpdateResponse + (*common.HealthCheckRequest)(nil), // 2: common.HealthCheckRequest + (*common.HealthCheckResponse)(nil), // 3: common.HealthCheckResponse +} +var file_admin_proto_depIdxs = []int32{ + 2, // 0: admin.AdminService.HealthCheck:input_type -> common.HealthCheckRequest + 0, // 1: admin.AdminService.UpdateConfig:input_type -> admin.ConfigUpdateRequest + 3, // 2: admin.AdminService.HealthCheck:output_type -> common.HealthCheckResponse + 1, // 3: admin.AdminService.UpdateConfig:output_type -> admin.ConfigUpdateResponse + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_admin_proto_init() } +func file_admin_proto_init() { + if File_admin_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_admin_proto_rawDesc), len(file_admin_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_admin_proto_goTypes, + DependencyIndexes: file_admin_proto_depIdxs, + MessageInfos: file_admin_proto_msgTypes, + }.Build() + File_admin_proto = out.File + file_admin_proto_goTypes = nil + file_admin_proto_depIdxs = nil +} diff --git a/internal/gen/git.espin.casa/albert/go-telecom/proto/admin/admin_grpc.pb.go b/internal/gen/git.espin.casa/albert/go-telecom/proto/admin/admin_grpc.pb.go new file mode 100644 index 0000000..e28f30b --- /dev/null +++ b/internal/gen/git.espin.casa/albert/go-telecom/proto/admin/admin_grpc.pb.go @@ -0,0 +1,160 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: admin.proto + +package admin + +import ( + context "context" + common "git.espin.casa/albert/go-telecom/proto/common" + 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.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + AdminService_HealthCheck_FullMethodName = "/admin.AdminService/HealthCheck" + AdminService_UpdateConfig_FullMethodName = "/admin.AdminService/UpdateConfig" +) + +// AdminServiceClient is the client API for AdminService 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 AdminServiceClient interface { + HealthCheck(ctx context.Context, in *common.HealthCheckRequest, opts ...grpc.CallOption) (*common.HealthCheckResponse, error) + UpdateConfig(ctx context.Context, in *ConfigUpdateRequest, opts ...grpc.CallOption) (*ConfigUpdateResponse, error) +} + +type adminServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewAdminServiceClient(cc grpc.ClientConnInterface) AdminServiceClient { + return &adminServiceClient{cc} +} + +func (c *adminServiceClient) HealthCheck(ctx context.Context, in *common.HealthCheckRequest, opts ...grpc.CallOption) (*common.HealthCheckResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(common.HealthCheckResponse) + err := c.cc.Invoke(ctx, AdminService_HealthCheck_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminServiceClient) UpdateConfig(ctx context.Context, in *ConfigUpdateRequest, opts ...grpc.CallOption) (*ConfigUpdateResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ConfigUpdateResponse) + err := c.cc.Invoke(ctx, AdminService_UpdateConfig_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AdminServiceServer is the server API for AdminService service. +// All implementations must embed UnimplementedAdminServiceServer +// for forward compatibility. +type AdminServiceServer interface { + HealthCheck(context.Context, *common.HealthCheckRequest) (*common.HealthCheckResponse, error) + UpdateConfig(context.Context, *ConfigUpdateRequest) (*ConfigUpdateResponse, error) + mustEmbedUnimplementedAdminServiceServer() +} + +// UnimplementedAdminServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedAdminServiceServer struct{} + +func (UnimplementedAdminServiceServer) HealthCheck(context.Context, *common.HealthCheckRequest) (*common.HealthCheckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HealthCheck not implemented") +} +func (UnimplementedAdminServiceServer) UpdateConfig(context.Context, *ConfigUpdateRequest) (*ConfigUpdateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateConfig not implemented") +} +func (UnimplementedAdminServiceServer) mustEmbedUnimplementedAdminServiceServer() {} +func (UnimplementedAdminServiceServer) testEmbeddedByValue() {} + +// UnsafeAdminServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AdminServiceServer will +// result in compilation errors. +type UnsafeAdminServiceServer interface { + mustEmbedUnimplementedAdminServiceServer() +} + +func RegisterAdminServiceServer(s grpc.ServiceRegistrar, srv AdminServiceServer) { + // If the following call pancis, it indicates UnimplementedAdminServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&AdminService_ServiceDesc, srv) +} + +func _AdminService_HealthCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(common.HealthCheckRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServiceServer).HealthCheck(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AdminService_HealthCheck_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServiceServer).HealthCheck(ctx, req.(*common.HealthCheckRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AdminService_UpdateConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ConfigUpdateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServiceServer).UpdateConfig(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AdminService_UpdateConfig_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServiceServer).UpdateConfig(ctx, req.(*ConfigUpdateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// AdminService_ServiceDesc is the grpc.ServiceDesc for AdminService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var AdminService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "admin.AdminService", + HandlerType: (*AdminServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "HealthCheck", + Handler: _AdminService_HealthCheck_Handler, + }, + { + MethodName: "UpdateConfig", + Handler: _AdminService_UpdateConfig_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "admin.proto", +} diff --git a/internal/gen/git.espin.casa/albert/go-telecom/proto/common/common.pb.go b/internal/gen/git.espin.casa/albert/go-telecom/proto/common/common.pb.go new file mode 100644 index 0000000..c49164e --- /dev/null +++ b/internal/gen/git.espin.casa/albert/go-telecom/proto/common/common.pb.go @@ -0,0 +1,160 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: common.proto + +package common + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 HealthCheckRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *HealthCheckRequest) Reset() { + *x = HealthCheckRequest{} + mi := &file_common_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_common_proto_msgTypes[0] + if 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_common_proto_rawDescGZIP(), []int{0} +} + +type HealthCheckResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *HealthCheckResponse) Reset() { + *x = HealthCheckResponse{} + mi := &file_common_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_common_proto_msgTypes[1] + if 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_common_proto_rawDescGZIP(), []int{1} +} + +func (x *HealthCheckResponse) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +var File_common_proto protoreflect.FileDescriptor + +const file_common_proto_rawDesc = "" + + "\n" + + "\fcommon.proto\x12\x06common\"\x14\n" + + "\x12HealthCheckRequest\"-\n" + + "\x13HealthCheckResponse\x12\x16\n" + + "\x06status\x18\x01 \x01(\tR\x06statusB6Z4git.espin.casa/albert/go-telecom/proto/common;commonb\x06proto3" + +var ( + file_common_proto_rawDescOnce sync.Once + file_common_proto_rawDescData []byte +) + +func file_common_proto_rawDescGZIP() []byte { + file_common_proto_rawDescOnce.Do(func() { + file_common_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_common_proto_rawDesc), len(file_common_proto_rawDesc))) + }) + return file_common_proto_rawDescData +} + +var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_common_proto_goTypes = []any{ + (*HealthCheckRequest)(nil), // 0: common.HealthCheckRequest + (*HealthCheckResponse)(nil), // 1: common.HealthCheckResponse +} +var file_common_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_common_proto_init() } +func file_common_proto_init() { + if File_common_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_common_proto_rawDesc), len(file_common_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_common_proto_goTypes, + DependencyIndexes: file_common_proto_depIdxs, + MessageInfos: file_common_proto_msgTypes, + }.Build() + File_common_proto = out.File + file_common_proto_goTypes = nil + file_common_proto_depIdxs = nil +} diff --git a/internal/gen/git.espin.casa/albert/go-telecom/proto/core/core.pb.go b/internal/gen/git.espin.casa/albert/go-telecom/proto/core/core.pb.go new file mode 100644 index 0000000..5dd31dc --- /dev/null +++ b/internal/gen/git.espin.casa/albert/go-telecom/proto/core/core.pb.go @@ -0,0 +1,189 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: core.proto + +package core + +import ( + common "git.espin.casa/albert/go-telecom/proto/common" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 StartRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + ProcessName string `protobuf:"bytes,1,opt,name=process_name,json=processName,proto3" json:"process_name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StartRequest) Reset() { + *x = StartRequest{} + mi := &file_core_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StartRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartRequest) ProtoMessage() {} + +func (x *StartRequest) ProtoReflect() protoreflect.Message { + mi := &file_core_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartRequest.ProtoReflect.Descriptor instead. +func (*StartRequest) Descriptor() ([]byte, []int) { + return file_core_proto_rawDescGZIP(), []int{0} +} + +func (x *StartRequest) GetProcessName() string { + if x != nil { + return x.ProcessName + } + return "" +} + +type StartResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StartResponse) Reset() { + *x = StartResponse{} + mi := &file_core_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StartResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartResponse) ProtoMessage() {} + +func (x *StartResponse) ProtoReflect() protoreflect.Message { + mi := &file_core_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartResponse.ProtoReflect.Descriptor instead. +func (*StartResponse) Descriptor() ([]byte, []int) { + return file_core_proto_rawDescGZIP(), []int{1} +} + +func (x *StartResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *StartResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +var File_core_proto protoreflect.FileDescriptor + +const file_core_proto_rawDesc = "" + + "\n" + + "\n" + + "core.proto\x12\x04core\x1a\fcommon.proto\"1\n" + + "\fStartRequest\x12!\n" + + "\fprocess_name\x18\x01 \x01(\tR\vprocessName\"C\n" + + "\rStartResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage2\x8e\x01\n" + + "\vCoreService\x12F\n" + + "\vHealthCheck\x12\x1a.common.HealthCheckRequest\x1a\x1b.common.HealthCheckResponse\x127\n" + + "\fStartProcess\x12\x12.core.StartRequest\x1a\x13.core.StartResponseB2Z0git.espin.casa/albert/go-telecom/proto/core;coreb\x06proto3" + +var ( + file_core_proto_rawDescOnce sync.Once + file_core_proto_rawDescData []byte +) + +func file_core_proto_rawDescGZIP() []byte { + file_core_proto_rawDescOnce.Do(func() { + file_core_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_core_proto_rawDesc), len(file_core_proto_rawDesc))) + }) + return file_core_proto_rawDescData +} + +var file_core_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_core_proto_goTypes = []any{ + (*StartRequest)(nil), // 0: core.StartRequest + (*StartResponse)(nil), // 1: core.StartResponse + (*common.HealthCheckRequest)(nil), // 2: common.HealthCheckRequest + (*common.HealthCheckResponse)(nil), // 3: common.HealthCheckResponse +} +var file_core_proto_depIdxs = []int32{ + 2, // 0: core.CoreService.HealthCheck:input_type -> common.HealthCheckRequest + 0, // 1: core.CoreService.StartProcess:input_type -> core.StartRequest + 3, // 2: core.CoreService.HealthCheck:output_type -> common.HealthCheckResponse + 1, // 3: core.CoreService.StartProcess:output_type -> core.StartResponse + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_core_proto_init() } +func file_core_proto_init() { + if File_core_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_core_proto_rawDesc), len(file_core_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_core_proto_goTypes, + DependencyIndexes: file_core_proto_depIdxs, + MessageInfos: file_core_proto_msgTypes, + }.Build() + File_core_proto = out.File + file_core_proto_goTypes = nil + file_core_proto_depIdxs = nil +} diff --git a/internal/gen/git.espin.casa/albert/go-telecom/proto/core/core_grpc.pb.go b/internal/gen/git.espin.casa/albert/go-telecom/proto/core/core_grpc.pb.go new file mode 100644 index 0000000..4bff7b5 --- /dev/null +++ b/internal/gen/git.espin.casa/albert/go-telecom/proto/core/core_grpc.pb.go @@ -0,0 +1,160 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: core.proto + +package core + +import ( + context "context" + common "git.espin.casa/albert/go-telecom/proto/common" + 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.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + CoreService_HealthCheck_FullMethodName = "/core.CoreService/HealthCheck" + CoreService_StartProcess_FullMethodName = "/core.CoreService/StartProcess" +) + +// CoreServiceClient is the client API for CoreService 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 CoreServiceClient interface { + HealthCheck(ctx context.Context, in *common.HealthCheckRequest, opts ...grpc.CallOption) (*common.HealthCheckResponse, error) + StartProcess(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*StartResponse, error) +} + +type coreServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewCoreServiceClient(cc grpc.ClientConnInterface) CoreServiceClient { + return &coreServiceClient{cc} +} + +func (c *coreServiceClient) HealthCheck(ctx context.Context, in *common.HealthCheckRequest, opts ...grpc.CallOption) (*common.HealthCheckResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(common.HealthCheckResponse) + err := c.cc.Invoke(ctx, CoreService_HealthCheck_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *coreServiceClient) StartProcess(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*StartResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(StartResponse) + err := c.cc.Invoke(ctx, CoreService_StartProcess_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// CoreServiceServer is the server API for CoreService service. +// All implementations must embed UnimplementedCoreServiceServer +// for forward compatibility. +type CoreServiceServer interface { + HealthCheck(context.Context, *common.HealthCheckRequest) (*common.HealthCheckResponse, error) + StartProcess(context.Context, *StartRequest) (*StartResponse, error) + mustEmbedUnimplementedCoreServiceServer() +} + +// UnimplementedCoreServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedCoreServiceServer struct{} + +func (UnimplementedCoreServiceServer) HealthCheck(context.Context, *common.HealthCheckRequest) (*common.HealthCheckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HealthCheck not implemented") +} +func (UnimplementedCoreServiceServer) StartProcess(context.Context, *StartRequest) (*StartResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StartProcess not implemented") +} +func (UnimplementedCoreServiceServer) mustEmbedUnimplementedCoreServiceServer() {} +func (UnimplementedCoreServiceServer) testEmbeddedByValue() {} + +// UnsafeCoreServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to CoreServiceServer will +// result in compilation errors. +type UnsafeCoreServiceServer interface { + mustEmbedUnimplementedCoreServiceServer() +} + +func RegisterCoreServiceServer(s grpc.ServiceRegistrar, srv CoreServiceServer) { + // If the following call pancis, it indicates UnimplementedCoreServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&CoreService_ServiceDesc, srv) +} + +func _CoreService_HealthCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(common.HealthCheckRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CoreServiceServer).HealthCheck(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: CoreService_HealthCheck_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CoreServiceServer).HealthCheck(ctx, req.(*common.HealthCheckRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CoreService_StartProcess_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CoreServiceServer).StartProcess(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: CoreService_StartProcess_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CoreServiceServer).StartProcess(ctx, req.(*StartRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// CoreService_ServiceDesc is the grpc.ServiceDesc for CoreService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var CoreService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "core.CoreService", + HandlerType: (*CoreServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "HealthCheck", + Handler: _CoreService_HealthCheck_Handler, + }, + { + MethodName: "StartProcess", + Handler: _CoreService_StartProcess_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "core.proto", +} diff --git a/internal/gen/git.espin.casa/albert/go-telecom/proto/monitor/monitor.pb.go b/internal/gen/git.espin.casa/albert/go-telecom/proto/monitor/monitor.pb.go new file mode 100644 index 0000000..73fcbd0 --- /dev/null +++ b/internal/gen/git.espin.casa/albert/go-telecom/proto/monitor/monitor.pb.go @@ -0,0 +1,206 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: monitor.proto + +package monitor + +import ( + common "git.espin.casa/albert/go-telecom/proto/common" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 LogEntry struct { + state protoimpl.MessageState `protogen:"open.v1"` + Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` + Level string `protobuf:"bytes,2,opt,name=level,proto3" json:"level,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LogEntry) Reset() { + *x = LogEntry{} + mi := &file_monitor_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LogEntry) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogEntry) ProtoMessage() {} + +func (x *LogEntry) ProtoReflect() protoreflect.Message { + mi := &file_monitor_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LogEntry.ProtoReflect.Descriptor instead. +func (*LogEntry) Descriptor() ([]byte, []int) { + return file_monitor_proto_rawDescGZIP(), []int{0} +} + +func (x *LogEntry) GetService() string { + if x != nil { + return x.Service + } + return "" +} + +func (x *LogEntry) GetLevel() string { + if x != nil { + return x.Level + } + return "" +} + +func (x *LogEntry) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *LogEntry) GetTimestamp() int64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +type LogAck struct { + state protoimpl.MessageState `protogen:"open.v1"` + Received bool `protobuf:"varint,1,opt,name=received,proto3" json:"received,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LogAck) Reset() { + *x = LogAck{} + mi := &file_monitor_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LogAck) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogAck) ProtoMessage() {} + +func (x *LogAck) ProtoReflect() protoreflect.Message { + mi := &file_monitor_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LogAck.ProtoReflect.Descriptor instead. +func (*LogAck) Descriptor() ([]byte, []int) { + return file_monitor_proto_rawDescGZIP(), []int{1} +} + +func (x *LogAck) GetReceived() bool { + if x != nil { + return x.Received + } + return false +} + +var File_monitor_proto protoreflect.FileDescriptor + +const file_monitor_proto_rawDesc = "" + + "\n" + + "\rmonitor.proto\x12\amonitor\x1a\fcommon.proto\"r\n" + + "\bLogEntry\x12\x18\n" + + "\aservice\x18\x01 \x01(\tR\aservice\x12\x14\n" + + "\x05level\x18\x02 \x01(\tR\x05level\x12\x18\n" + + "\amessage\x18\x03 \x01(\tR\amessage\x12\x1c\n" + + "\ttimestamp\x18\x04 \x01(\x03R\ttimestamp\"$\n" + + "\x06LogAck\x12\x1a\n" + + "\breceived\x18\x01 \x01(\bR\breceived2\x87\x01\n" + + "\x0eMonitorService\x12F\n" + + "\vHealthCheck\x12\x1a.common.HealthCheckRequest\x1a\x1b.common.HealthCheckResponse\x12-\n" + + "\aSendLog\x12\x11.monitor.LogEntry\x1a\x0f.monitor.LogAckB8Z6git.espin.casa/albert/go-telecom/proto/monitor;monitorb\x06proto3" + +var ( + file_monitor_proto_rawDescOnce sync.Once + file_monitor_proto_rawDescData []byte +) + +func file_monitor_proto_rawDescGZIP() []byte { + file_monitor_proto_rawDescOnce.Do(func() { + file_monitor_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_monitor_proto_rawDesc), len(file_monitor_proto_rawDesc))) + }) + return file_monitor_proto_rawDescData +} + +var file_monitor_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_monitor_proto_goTypes = []any{ + (*LogEntry)(nil), // 0: monitor.LogEntry + (*LogAck)(nil), // 1: monitor.LogAck + (*common.HealthCheckRequest)(nil), // 2: common.HealthCheckRequest + (*common.HealthCheckResponse)(nil), // 3: common.HealthCheckResponse +} +var file_monitor_proto_depIdxs = []int32{ + 2, // 0: monitor.MonitorService.HealthCheck:input_type -> common.HealthCheckRequest + 0, // 1: monitor.MonitorService.SendLog:input_type -> monitor.LogEntry + 3, // 2: monitor.MonitorService.HealthCheck:output_type -> common.HealthCheckResponse + 1, // 3: monitor.MonitorService.SendLog:output_type -> monitor.LogAck + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_monitor_proto_init() } +func file_monitor_proto_init() { + if File_monitor_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_monitor_proto_rawDesc), len(file_monitor_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_monitor_proto_goTypes, + DependencyIndexes: file_monitor_proto_depIdxs, + MessageInfos: file_monitor_proto_msgTypes, + }.Build() + File_monitor_proto = out.File + file_monitor_proto_goTypes = nil + file_monitor_proto_depIdxs = nil +} diff --git a/internal/gen/git.espin.casa/albert/go-telecom/proto/monitor/monitor_grpc.pb.go b/internal/gen/git.espin.casa/albert/go-telecom/proto/monitor/monitor_grpc.pb.go new file mode 100644 index 0000000..e08fec7 --- /dev/null +++ b/internal/gen/git.espin.casa/albert/go-telecom/proto/monitor/monitor_grpc.pb.go @@ -0,0 +1,160 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: monitor.proto + +package monitor + +import ( + context "context" + common "git.espin.casa/albert/go-telecom/proto/common" + 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.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + MonitorService_HealthCheck_FullMethodName = "/monitor.MonitorService/HealthCheck" + MonitorService_SendLog_FullMethodName = "/monitor.MonitorService/SendLog" +) + +// MonitorServiceClient is the client API for MonitorService 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 MonitorServiceClient interface { + HealthCheck(ctx context.Context, in *common.HealthCheckRequest, opts ...grpc.CallOption) (*common.HealthCheckResponse, error) + SendLog(ctx context.Context, in *LogEntry, opts ...grpc.CallOption) (*LogAck, error) +} + +type monitorServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewMonitorServiceClient(cc grpc.ClientConnInterface) MonitorServiceClient { + return &monitorServiceClient{cc} +} + +func (c *monitorServiceClient) HealthCheck(ctx context.Context, in *common.HealthCheckRequest, opts ...grpc.CallOption) (*common.HealthCheckResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(common.HealthCheckResponse) + err := c.cc.Invoke(ctx, MonitorService_HealthCheck_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *monitorServiceClient) SendLog(ctx context.Context, in *LogEntry, opts ...grpc.CallOption) (*LogAck, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(LogAck) + err := c.cc.Invoke(ctx, MonitorService_SendLog_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MonitorServiceServer is the server API for MonitorService service. +// All implementations must embed UnimplementedMonitorServiceServer +// for forward compatibility. +type MonitorServiceServer interface { + HealthCheck(context.Context, *common.HealthCheckRequest) (*common.HealthCheckResponse, error) + SendLog(context.Context, *LogEntry) (*LogAck, error) + mustEmbedUnimplementedMonitorServiceServer() +} + +// UnimplementedMonitorServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMonitorServiceServer struct{} + +func (UnimplementedMonitorServiceServer) HealthCheck(context.Context, *common.HealthCheckRequest) (*common.HealthCheckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HealthCheck not implemented") +} +func (UnimplementedMonitorServiceServer) SendLog(context.Context, *LogEntry) (*LogAck, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendLog not implemented") +} +func (UnimplementedMonitorServiceServer) mustEmbedUnimplementedMonitorServiceServer() {} +func (UnimplementedMonitorServiceServer) testEmbeddedByValue() {} + +// UnsafeMonitorServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MonitorServiceServer will +// result in compilation errors. +type UnsafeMonitorServiceServer interface { + mustEmbedUnimplementedMonitorServiceServer() +} + +func RegisterMonitorServiceServer(s grpc.ServiceRegistrar, srv MonitorServiceServer) { + // If the following call pancis, it indicates UnimplementedMonitorServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&MonitorService_ServiceDesc, srv) +} + +func _MonitorService_HealthCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(common.HealthCheckRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MonitorServiceServer).HealthCheck(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: MonitorService_HealthCheck_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MonitorServiceServer).HealthCheck(ctx, req.(*common.HealthCheckRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _MonitorService_SendLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LogEntry) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MonitorServiceServer).SendLog(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: MonitorService_SendLog_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MonitorServiceServer).SendLog(ctx, req.(*LogEntry)) + } + return interceptor(ctx, in, info, handler) +} + +// MonitorService_ServiceDesc is the grpc.ServiceDesc for MonitorService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var MonitorService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "monitor.MonitorService", + HandlerType: (*MonitorServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "HealthCheck", + Handler: _MonitorService_HealthCheck_Handler, + }, + { + MethodName: "SendLog", + Handler: _MonitorService_SendLog_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "monitor.proto", +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..ce33610 --- /dev/null +++ b/main.go @@ -0,0 +1,11 @@ +/* +Copyright © 2025 NAME HERE + +*/ +package main + +import "git.espin.casa/albert/go-telecom/cmd" + +func main() { + cmd.Execute() +} diff --git a/proto/adaptor.proto b/proto/adaptor.proto new file mode 100644 index 0000000..7904ef7 --- /dev/null +++ b/proto/adaptor.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package adapter; + +import "common.proto"; + +option go_package = "git.espin.casa/albert/go-telecom/proto/adaptor;adaptor"; + + +service AdapterService { + rpc HealthCheck(common.HealthCheckRequest) returns (common.HealthCheckResponse); + rpc SendData(DataMessage) returns (Ack); +} + +message DataMessage { + string origin = 1; + bytes payload = 2; + int64 timestamp = 3; +} + +message Ack { + bool received = 1; +} diff --git a/proto/admin.proto b/proto/admin.proto new file mode 100644 index 0000000..27c6edb --- /dev/null +++ b/proto/admin.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package admin; + +import "common.proto"; + +option go_package = "git.espin.casa/albert/go-telecom/proto/admin;admin"; + + +service AdminService { + rpc HealthCheck(common.HealthCheckRequest) returns (common.HealthCheckResponse); + rpc UpdateConfig(ConfigUpdateRequest) returns (ConfigUpdateResponse); +} + +message ConfigUpdateRequest { + string key = 1; + string value = 2; +} + +message ConfigUpdateResponse { + bool updated = 1; +} diff --git a/proto/common.proto b/proto/common.proto new file mode 100644 index 0000000..a4efba3 --- /dev/null +++ b/proto/common.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package common; +option go_package = "git.espin.casa/albert/go-telecom/proto/common;common"; + +message HealthCheckRequest {} +message HealthCheckResponse { + string status = 1; +} diff --git a/proto/core.proto b/proto/core.proto new file mode 100644 index 0000000..ce9c908 --- /dev/null +++ b/proto/core.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package core; + +import "common.proto"; + +option go_package = "git.espin.casa/albert/go-telecom/proto/core;core"; + +service CoreService { + rpc HealthCheck(common.HealthCheckRequest) returns (common.HealthCheckResponse); + rpc StartProcess(StartRequest) returns (StartResponse); +} + +message StartRequest { + string process_name = 1; +} + +message StartResponse { + bool success = 1; + string message = 2; +} + diff --git a/proto/monitor.proto b/proto/monitor.proto new file mode 100644 index 0000000..04a88b2 --- /dev/null +++ b/proto/monitor.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package monitor; + +import "common.proto"; + +option go_package = "git.espin.casa/albert/go-telecom/proto/monitor;monitor"; + + +service MonitorService { + rpc HealthCheck(common.HealthCheckRequest) returns (common.HealthCheckResponse); + rpc SendLog(LogEntry) returns (LogAck); +} + +message LogEntry { + string service = 1; + string level = 2; + string message = 3; + int64 timestamp = 4; +} + +message LogAck { + bool received = 1; +}