mirror of
https://github.com/lorsanstand/HomeOps-Hub.git
synced 2026-06-19 17:45:17 +03:00
feat: base grpc system and base use
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v7.34.1
|
||||
// source: homeops/hub.proto
|
||||
|
||||
package homeops
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
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 PongResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Pong string `protobuf:"bytes,1,opt,name=pong,proto3" json:"pong,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *PongResponse) Reset() {
|
||||
*x = PongResponse{}
|
||||
mi := &file_homeops_hub_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *PongResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PongResponse) ProtoMessage() {}
|
||||
|
||||
func (x *PongResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_homeops_hub_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 PongResponse.ProtoReflect.Descriptor instead.
|
||||
func (*PongResponse) Descriptor() ([]byte, []int) {
|
||||
return file_homeops_hub_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *PongResponse) GetPong() string {
|
||||
if x != nil {
|
||||
return x.Pong
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_homeops_hub_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_homeops_hub_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x11homeops/hub.proto\x1a\x1bgoogle/protobuf/empty.proto\"\"\n" +
|
||||
"\fPongResponse\x12\x12\n" +
|
||||
"\x04pong\x18\x01 \x01(\tR\x04pong26\n" +
|
||||
"\x03Hub\x12/\n" +
|
||||
"\x04Ping\x12\x16.google.protobuf.Empty\x1a\r.PongResponse\"\x00B<Z:github.com/lorsanstand/HomeOps-Hub/api/gen/homeops;homeopsb\x06proto3"
|
||||
|
||||
var (
|
||||
file_homeops_hub_proto_rawDescOnce sync.Once
|
||||
file_homeops_hub_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_homeops_hub_proto_rawDescGZIP() []byte {
|
||||
file_homeops_hub_proto_rawDescOnce.Do(func() {
|
||||
file_homeops_hub_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_homeops_hub_proto_rawDesc), len(file_homeops_hub_proto_rawDesc)))
|
||||
})
|
||||
return file_homeops_hub_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_homeops_hub_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_homeops_hub_proto_goTypes = []any{
|
||||
(*PongResponse)(nil), // 0: PongResponse
|
||||
(*emptypb.Empty)(nil), // 1: google.protobuf.Empty
|
||||
}
|
||||
var file_homeops_hub_proto_depIdxs = []int32{
|
||||
1, // 0: Hub.Ping:input_type -> google.protobuf.Empty
|
||||
0, // 1: Hub.Ping:output_type -> PongResponse
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] 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_homeops_hub_proto_init() }
|
||||
func file_homeops_hub_proto_init() {
|
||||
if File_homeops_hub_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_homeops_hub_proto_rawDesc), len(file_homeops_hub_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_homeops_hub_proto_goTypes,
|
||||
DependencyIndexes: file_homeops_hub_proto_depIdxs,
|
||||
MessageInfos: file_homeops_hub_proto_msgTypes,
|
||||
}.Build()
|
||||
File_homeops_hub_proto = out.File
|
||||
file_homeops_hub_proto_goTypes = nil
|
||||
file_homeops_hub_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc v7.34.1
|
||||
// source: homeops/hub.proto
|
||||
|
||||
package homeops
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
// 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 (
|
||||
Hub_Ping_FullMethodName = "/Hub/Ping"
|
||||
)
|
||||
|
||||
// HubClient is the client API for Hub 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 HubClient interface {
|
||||
Ping(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*PongResponse, error)
|
||||
}
|
||||
|
||||
type hubClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewHubClient(cc grpc.ClientConnInterface) HubClient {
|
||||
return &hubClient{cc}
|
||||
}
|
||||
|
||||
func (c *hubClient) Ping(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*PongResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(PongResponse)
|
||||
err := c.cc.Invoke(ctx, Hub_Ping_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// HubServer is the server API for Hub service.
|
||||
// All implementations must embed UnimplementedHubServer
|
||||
// for forward compatibility.
|
||||
type HubServer interface {
|
||||
Ping(context.Context, *emptypb.Empty) (*PongResponse, error)
|
||||
mustEmbedUnimplementedHubServer()
|
||||
}
|
||||
|
||||
// UnimplementedHubServer 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 UnimplementedHubServer struct{}
|
||||
|
||||
func (UnimplementedHubServer) Ping(context.Context, *emptypb.Empty) (*PongResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Ping not implemented")
|
||||
}
|
||||
func (UnimplementedHubServer) mustEmbedUnimplementedHubServer() {}
|
||||
func (UnimplementedHubServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeHubServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to HubServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeHubServer interface {
|
||||
mustEmbedUnimplementedHubServer()
|
||||
}
|
||||
|
||||
func RegisterHubServer(s grpc.ServiceRegistrar, srv HubServer) {
|
||||
// If the following call panics, it indicates UnimplementedHubServer 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(&Hub_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Hub_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(emptypb.Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HubServer).Ping(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Hub_Ping_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HubServer).Ping(ctx, req.(*emptypb.Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Hub_ServiceDesc is the grpc.ServiceDesc for Hub service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Hub_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "Hub",
|
||||
HandlerType: (*HubServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Ping",
|
||||
Handler: _Hub_Ping_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "homeops/hub.proto",
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
|
||||
option go_package = "github.com/lorsanstand/HomeOps-Hub/api/gen/homeops;homeops";
|
||||
|
||||
service Hub {
|
||||
rpc Ping (google.protobuf.Empty) returns (PongResponse) {}
|
||||
}
|
||||
|
||||
message PongResponse {
|
||||
string pong = 1;
|
||||
}
|
||||
Reference in New Issue
Block a user