diff --git a/proto/do.sh b/proto/do.sh new file mode 100755 index 0000000..383b7f8 --- /dev/null +++ b/proto/do.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -exuo pipefail + +protogen() { + in=./hellreign.proto + protoc --go_out="." --go_opt=module="gitea.d3m0k1d.ru/d3m0k1d/HellreigN/proto" \ + --go-grpc_out="." --go-grpc_opt=module="gitea.d3m0k1d.ru/d3m0k1d/HellreigN/proto" "$in" +} + +"$@" diff --git a/proto/go.mod b/proto/go.mod new file mode 100644 index 0000000..a7d5780 --- /dev/null +++ b/proto/go.mod @@ -0,0 +1,15 @@ +module gitea.d3m0k1d.ru/d3m0k1d/HellreigN/proto + +go 1.24.3 + +require ( + google.golang.org/grpc v1.80.0 + google.golang.org/protobuf v1.36.11 +) + +require ( + golang.org/x/net v0.49.0 // indirect + golang.org/x/sys v0.40.0 // indirect + golang.org/x/text v0.33.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516 // indirect +) diff --git a/proto/go.sum b/proto/go.sum new file mode 100644 index 0000000..98ff7bd --- /dev/null +++ b/proto/go.sum @@ -0,0 +1,38 @@ +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48= +go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8= +go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0= +go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs= +go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18= +go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE= +go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8= +go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew= +go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI= +go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA= +golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= +golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= +gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= +gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516 h1:sNrWoksmOyF5bvJUcnmbeAmQi8baNhqg5IWaI3llQqU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ= +google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM= +google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4= +google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= +google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= diff --git a/proto/hellreign.pb.go b/proto/hellreign.pb.go new file mode 100644 index 0000000..36f82a5 --- /dev/null +++ b/proto/hellreign.pb.go @@ -0,0 +1,309 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc v3.21.9 +// source: hellreign.proto + +package proto + +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 CollectorRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CollectorRequest) Reset() { + *x = CollectorRequest{} + mi := &file_hellreign_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CollectorRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectorRequest) ProtoMessage() {} + +func (x *CollectorRequest) ProtoReflect() protoreflect.Message { + mi := &file_hellreign_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 CollectorRequest.ProtoReflect.Descriptor instead. +func (*CollectorRequest) Descriptor() ([]byte, []int) { + return file_hellreign_proto_rawDescGZIP(), []int{0} +} + +func (x *CollectorRequest) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type CollectorResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CollectorResponse) Reset() { + *x = CollectorResponse{} + mi := &file_hellreign_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CollectorResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectorResponse) ProtoMessage() {} + +func (x *CollectorResponse) ProtoReflect() protoreflect.Message { + mi := &file_hellreign_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 CollectorResponse.ProtoReflect.Descriptor instead. +func (*CollectorResponse) Descriptor() ([]byte, []int) { + return file_hellreign_proto_rawDescGZIP(), []int{1} +} + +type Command struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Command []string `protobuf:"bytes,2,rep,name=command,proto3" json:"command,omitempty"` + Stdin *string `protobuf:"bytes,3,opt,name=stdin,proto3,oneof" json:"stdin,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Command) Reset() { + *x = Command{} + mi := &file_hellreign_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Command) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Command) ProtoMessage() {} + +func (x *Command) ProtoReflect() protoreflect.Message { + mi := &file_hellreign_proto_msgTypes[2] + 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 Command.ProtoReflect.Descriptor instead. +func (*Command) Descriptor() ([]byte, []int) { + return file_hellreign_proto_rawDescGZIP(), []int{2} +} + +func (x *Command) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Command) GetCommand() []string { + if x != nil { + return x.Command + } + return nil +} + +func (x *Command) GetStdin() string { + if x != nil && x.Stdin != nil { + return *x.Stdin + } + return "" +} + +type FinishedCommand struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` + Stdout string `protobuf:"bytes,3,opt,name=stdout,proto3" json:"stdout,omitempty"` + Stderr string `protobuf:"bytes,4,opt,name=stderr,proto3" json:"stderr,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *FinishedCommand) Reset() { + *x = FinishedCommand{} + mi := &file_hellreign_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *FinishedCommand) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FinishedCommand) ProtoMessage() {} + +func (x *FinishedCommand) ProtoReflect() protoreflect.Message { + mi := &file_hellreign_proto_msgTypes[3] + 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 FinishedCommand.ProtoReflect.Descriptor instead. +func (*FinishedCommand) Descriptor() ([]byte, []int) { + return file_hellreign_proto_rawDescGZIP(), []int{3} +} + +func (x *FinishedCommand) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *FinishedCommand) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *FinishedCommand) GetStdout() string { + if x != nil { + return x.Stdout + } + return "" +} + +func (x *FinishedCommand) GetStderr() string { + if x != nil { + return x.Stderr + } + return "" +} + +var File_hellreign_proto protoreflect.FileDescriptor + +const file_hellreign_proto_rawDesc = "" + + "\n" + + "\x0fhellreign.proto\x12\x04chat\",\n" + + "\x10CollectorRequest\x12\x18\n" + + "\amessage\x18\x01 \x01(\tR\amessage\"\x13\n" + + "\x11CollectorResponse\"X\n" + + "\aCommand\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acommand\x18\x02 \x03(\tR\acommand\x12\x19\n" + + "\x05stdin\x18\x03 \x01(\tH\x00R\x05stdin\x88\x01\x01B\b\n" + + "\x06_stdin\"i\n" + + "\x0fFinishedCommand\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + + "\x06status\x18\x02 \x01(\x05R\x06status\x12\x16\n" + + "\x06stdout\x18\x03 \x01(\tR\x06stdout\x12\x16\n" + + "\x06stderr\x18\x04 \x01(\tR\x06stderr2H\n" + + "\tCollector\x12;\n" + + "\x06Stream\x12\x16.chat.CollectorRequest\x1a\x17.chat.CollectorResponse(\x012?\n" + + "\tCommander\x122\n" + + "\x06Stream\x12\r.chat.Command\x1a\x15.chat.FinishedCommand(\x010\x01B*Z(gitea.d3m0k1d.ru/d3m0k1d/HellreigN/protob\x06proto3" + +var ( + file_hellreign_proto_rawDescOnce sync.Once + file_hellreign_proto_rawDescData []byte +) + +func file_hellreign_proto_rawDescGZIP() []byte { + file_hellreign_proto_rawDescOnce.Do(func() { + file_hellreign_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hellreign_proto_rawDesc), len(file_hellreign_proto_rawDesc))) + }) + return file_hellreign_proto_rawDescData +} + +var file_hellreign_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_hellreign_proto_goTypes = []any{ + (*CollectorRequest)(nil), // 0: chat.CollectorRequest + (*CollectorResponse)(nil), // 1: chat.CollectorResponse + (*Command)(nil), // 2: chat.Command + (*FinishedCommand)(nil), // 3: chat.FinishedCommand +} +var file_hellreign_proto_depIdxs = []int32{ + 0, // 0: chat.Collector.Stream:input_type -> chat.CollectorRequest + 2, // 1: chat.Commander.Stream:input_type -> chat.Command + 1, // 2: chat.Collector.Stream:output_type -> chat.CollectorResponse + 3, // 3: chat.Commander.Stream:output_type -> chat.FinishedCommand + 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_hellreign_proto_init() } +func file_hellreign_proto_init() { + if File_hellreign_proto != nil { + return + } + file_hellreign_proto_msgTypes[2].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_hellreign_proto_rawDesc), len(file_hellreign_proto_rawDesc)), + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 2, + }, + GoTypes: file_hellreign_proto_goTypes, + DependencyIndexes: file_hellreign_proto_depIdxs, + MessageInfos: file_hellreign_proto_msgTypes, + }.Build() + File_hellreign_proto = out.File + file_hellreign_proto_goTypes = nil + file_hellreign_proto_depIdxs = nil +} diff --git a/proto/hellreign.proto b/proto/hellreign.proto new file mode 100644 index 0000000..861515f --- /dev/null +++ b/proto/hellreign.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package chat; + +option go_package="gitea.d3m0k1d.ru/d3m0k1d/HellreigN/proto"; + +service Collector { + rpc Stream(stream CollectorRequest) returns (CollectorResponse); +} + +message CollectorRequest { + string message = 1; +} + +message CollectorResponse { +} + +service Commander { + rpc Stream(stream Command) returns (stream FinishedCommand); +} + +message Command { + int64 id = 1; + repeated string command = 2; + optional string stdin = 3; +} + +message FinishedCommand { + int64 id = 1; + int32 status = 2; + string stdout = 3; + string stderr = 4; +} diff --git a/proto/hellreign_grpc.pb.go b/proto/hellreign_grpc.pb.go new file mode 100644 index 0000000..387dbc7 --- /dev/null +++ b/proto/hellreign_grpc.pb.go @@ -0,0 +1,210 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.6.1 +// - protoc v3.21.9 +// source: hellreign.proto + +package proto + +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.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Collector_Stream_FullMethodName = "/chat.Collector/Stream" +) + +// CollectorClient is the client API for Collector 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 CollectorClient interface { + Stream(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[CollectorRequest, CollectorResponse], error) +} + +type collectorClient struct { + cc grpc.ClientConnInterface +} + +func NewCollectorClient(cc grpc.ClientConnInterface) CollectorClient { + return &collectorClient{cc} +} + +func (c *collectorClient) Stream(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[CollectorRequest, CollectorResponse], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &Collector_ServiceDesc.Streams[0], Collector_Stream_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[CollectorRequest, CollectorResponse]{ClientStream: stream} + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type Collector_StreamClient = grpc.ClientStreamingClient[CollectorRequest, CollectorResponse] + +// CollectorServer is the server API for Collector service. +// All implementations must embed UnimplementedCollectorServer +// for forward compatibility. +type CollectorServer interface { + Stream(grpc.ClientStreamingServer[CollectorRequest, CollectorResponse]) error + mustEmbedUnimplementedCollectorServer() +} + +// UnimplementedCollectorServer 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 UnimplementedCollectorServer struct{} + +func (UnimplementedCollectorServer) Stream(grpc.ClientStreamingServer[CollectorRequest, CollectorResponse]) error { + return status.Error(codes.Unimplemented, "method Stream not implemented") +} +func (UnimplementedCollectorServer) mustEmbedUnimplementedCollectorServer() {} +func (UnimplementedCollectorServer) testEmbeddedByValue() {} + +// UnsafeCollectorServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to CollectorServer will +// result in compilation errors. +type UnsafeCollectorServer interface { + mustEmbedUnimplementedCollectorServer() +} + +func RegisterCollectorServer(s grpc.ServiceRegistrar, srv CollectorServer) { + // If the following call panics, it indicates UnimplementedCollectorServer 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(&Collector_ServiceDesc, srv) +} + +func _Collector_Stream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(CollectorServer).Stream(&grpc.GenericServerStream[CollectorRequest, CollectorResponse]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type Collector_StreamServer = grpc.ClientStreamingServer[CollectorRequest, CollectorResponse] + +// Collector_ServiceDesc is the grpc.ServiceDesc for Collector service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Collector_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "chat.Collector", + HandlerType: (*CollectorServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Stream", + Handler: _Collector_Stream_Handler, + ClientStreams: true, + }, + }, + Metadata: "hellreign.proto", +} + +const ( + Commander_Stream_FullMethodName = "/chat.Commander/Stream" +) + +// CommanderClient is the client API for Commander 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 CommanderClient interface { + Stream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[Command, FinishedCommand], error) +} + +type commanderClient struct { + cc grpc.ClientConnInterface +} + +func NewCommanderClient(cc grpc.ClientConnInterface) CommanderClient { + return &commanderClient{cc} +} + +func (c *commanderClient) Stream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[Command, FinishedCommand], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &Commander_ServiceDesc.Streams[0], Commander_Stream_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[Command, FinishedCommand]{ClientStream: stream} + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type Commander_StreamClient = grpc.BidiStreamingClient[Command, FinishedCommand] + +// CommanderServer is the server API for Commander service. +// All implementations must embed UnimplementedCommanderServer +// for forward compatibility. +type CommanderServer interface { + Stream(grpc.BidiStreamingServer[Command, FinishedCommand]) error + mustEmbedUnimplementedCommanderServer() +} + +// UnimplementedCommanderServer 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 UnimplementedCommanderServer struct{} + +func (UnimplementedCommanderServer) Stream(grpc.BidiStreamingServer[Command, FinishedCommand]) error { + return status.Error(codes.Unimplemented, "method Stream not implemented") +} +func (UnimplementedCommanderServer) mustEmbedUnimplementedCommanderServer() {} +func (UnimplementedCommanderServer) testEmbeddedByValue() {} + +// UnsafeCommanderServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to CommanderServer will +// result in compilation errors. +type UnsafeCommanderServer interface { + mustEmbedUnimplementedCommanderServer() +} + +func RegisterCommanderServer(s grpc.ServiceRegistrar, srv CommanderServer) { + // If the following call panics, it indicates UnimplementedCommanderServer 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(&Commander_ServiceDesc, srv) +} + +func _Commander_Stream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(CommanderServer).Stream(&grpc.GenericServerStream[Command, FinishedCommand]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type Commander_StreamServer = grpc.BidiStreamingServer[Command, FinishedCommand] + +// Commander_ServiceDesc is the grpc.ServiceDesc for Commander service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Commander_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "chat.Commander", + HandlerType: (*CommanderServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Stream", + Handler: _Commander_Stream_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "hellreign.proto", +}