task proto added

This commit is contained in:
nquidox 2026-03-08 14:06:04 +03:00
parent bdf8d0fa84
commit 9ddeefd34b
3 changed files with 391 additions and 0 deletions

View file

@ -0,0 +1,213 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.8
// protoc v6.33.1
// source: proto/taskTransport.proto
package taskTransportV1
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 Task struct {
state protoimpl.MessageState `protogen:"open.v1"`
MerchUuid string `protobuf:"bytes,1,opt,name=merch_uuid,json=merchUuid,proto3" json:"merch_uuid,omitempty"`
Origins map[string]string `protobuf:"bytes,2,rep,name=origins,proto3" json:"origins,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Task) Reset() {
*x = Task{}
mi := &file_proto_taskTransport_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Task) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Task) ProtoMessage() {}
func (x *Task) ProtoReflect() protoreflect.Message {
mi := &file_proto_taskTransport_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 Task.ProtoReflect.Descriptor instead.
func (*Task) Descriptor() ([]byte, []int) {
return file_proto_taskTransport_proto_rawDescGZIP(), []int{0}
}
func (x *Task) GetMerchUuid() string {
if x != nil {
return x.MerchUuid
}
return ""
}
func (x *Task) GetOrigins() map[string]string {
if x != nil {
return x.Origins
}
return nil
}
type Result struct {
state protoimpl.MessageState `protogen:"open.v1"`
MerchUuid string `protobuf:"bytes,1,opt,name=merch_uuid,json=merchUuid,proto3" json:"merch_uuid,omitempty"`
OriginName string `protobuf:"bytes,2,opt,name=origin_name,json=originName,proto3" json:"origin_name,omitempty"`
Price int32 `protobuf:"varint,3,opt,name=price,proto3" json:"price,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Result) Reset() {
*x = Result{}
mi := &file_proto_taskTransport_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Result) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Result) ProtoMessage() {}
func (x *Result) ProtoReflect() protoreflect.Message {
mi := &file_proto_taskTransport_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 Result.ProtoReflect.Descriptor instead.
func (*Result) Descriptor() ([]byte, []int) {
return file_proto_taskTransport_proto_rawDescGZIP(), []int{1}
}
func (x *Result) GetMerchUuid() string {
if x != nil {
return x.MerchUuid
}
return ""
}
func (x *Result) GetOriginName() string {
if x != nil {
return x.OriginName
}
return ""
}
func (x *Result) GetPrice() int32 {
if x != nil {
return x.Price
}
return 0
}
var File_proto_taskTransport_proto protoreflect.FileDescriptor
const file_proto_taskTransport_proto_rawDesc = "" +
"\n" +
"\x19proto/taskTransport.proto\x12\rtaskTransport\x1a\x1bgoogle/protobuf/empty.proto\"\x9d\x01\n" +
"\x04Task\x12\x1d\n" +
"\n" +
"merch_uuid\x18\x01 \x01(\tR\tmerchUuid\x12:\n" +
"\aorigins\x18\x02 \x03(\v2 .taskTransport.Task.OriginsEntryR\aorigins\x1a:\n" +
"\fOriginsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"^\n" +
"\x06Result\x12\x1d\n" +
"\n" +
"merch_uuid\x18\x01 \x01(\tR\tmerchUuid\x12\x1f\n" +
"\vorigin_name\x18\x02 \x01(\tR\n" +
"originName\x12\x14\n" +
"\x05price\x18\x03 \x01(\x05R\x05price2\x8e\x01\n" +
"\rTaskProcessor\x12=\n" +
"\fRequestTasks\x12\x16.google.protobuf.Empty\x1a\x13.taskTransport.Task0\x01\x12>\n" +
"\vSendResults\x12\x15.taskTransport.Result\x1a\x16.google.protobuf.Empty(\x01B'Z%/pkg/taskTransport/v1;taskTransportV1b\x06proto3"
var (
file_proto_taskTransport_proto_rawDescOnce sync.Once
file_proto_taskTransport_proto_rawDescData []byte
)
func file_proto_taskTransport_proto_rawDescGZIP() []byte {
file_proto_taskTransport_proto_rawDescOnce.Do(func() {
file_proto_taskTransport_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_proto_taskTransport_proto_rawDesc), len(file_proto_taskTransport_proto_rawDesc)))
})
return file_proto_taskTransport_proto_rawDescData
}
var file_proto_taskTransport_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_proto_taskTransport_proto_goTypes = []any{
(*Task)(nil), // 0: taskTransport.Task
(*Result)(nil), // 1: taskTransport.Result
nil, // 2: taskTransport.Task.OriginsEntry
(*emptypb.Empty)(nil), // 3: google.protobuf.Empty
}
var file_proto_taskTransport_proto_depIdxs = []int32{
2, // 0: taskTransport.Task.origins:type_name -> taskTransport.Task.OriginsEntry
3, // 1: taskTransport.TaskProcessor.RequestTasks:input_type -> google.protobuf.Empty
1, // 2: taskTransport.TaskProcessor.SendResults:input_type -> taskTransport.Result
0, // 3: taskTransport.TaskProcessor.RequestTasks:output_type -> taskTransport.Task
3, // 4: taskTransport.TaskProcessor.SendResults:output_type -> google.protobuf.Empty
3, // [3:5] is the sub-list for method output_type
1, // [1:3] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_proto_taskTransport_proto_init() }
func file_proto_taskTransport_proto_init() {
if File_proto_taskTransport_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_taskTransport_proto_rawDesc), len(file_proto_taskTransport_proto_rawDesc)),
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_taskTransport_proto_goTypes,
DependencyIndexes: file_proto_taskTransport_proto_depIdxs,
MessageInfos: file_proto_taskTransport_proto_msgTypes,
}.Build()
File_proto_taskTransport_proto = out.File
file_proto_taskTransport_proto_goTypes = nil
file_proto_taskTransport_proto_depIdxs = nil
}

View file

@ -0,0 +1,156 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.33.1
// source: proto/taskTransport.proto
package taskTransportV1
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 (
TaskProcessor_RequestTasks_FullMethodName = "/taskTransport.TaskProcessor/RequestTasks"
TaskProcessor_SendResults_FullMethodName = "/taskTransport.TaskProcessor/SendResults"
)
// TaskProcessorClient is the client API for TaskProcessor 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 TaskProcessorClient interface {
RequestTasks(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Task], error)
SendResults(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[Result, emptypb.Empty], error)
}
type taskProcessorClient struct {
cc grpc.ClientConnInterface
}
func NewTaskProcessorClient(cc grpc.ClientConnInterface) TaskProcessorClient {
return &taskProcessorClient{cc}
}
func (c *taskProcessorClient) RequestTasks(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Task], error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &TaskProcessor_ServiceDesc.Streams[0], TaskProcessor_RequestTasks_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &grpc.GenericClientStream[emptypb.Empty, Task]{ClientStream: stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type TaskProcessor_RequestTasksClient = grpc.ServerStreamingClient[Task]
func (c *taskProcessorClient) SendResults(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[Result, emptypb.Empty], error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &TaskProcessor_ServiceDesc.Streams[1], TaskProcessor_SendResults_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &grpc.GenericClientStream[Result, emptypb.Empty]{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 TaskProcessor_SendResultsClient = grpc.ClientStreamingClient[Result, emptypb.Empty]
// TaskProcessorServer is the server API for TaskProcessor service.
// All implementations must embed UnimplementedTaskProcessorServer
// for forward compatibility.
type TaskProcessorServer interface {
RequestTasks(*emptypb.Empty, grpc.ServerStreamingServer[Task]) error
SendResults(grpc.ClientStreamingServer[Result, emptypb.Empty]) error
mustEmbedUnimplementedTaskProcessorServer()
}
// UnimplementedTaskProcessorServer 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 UnimplementedTaskProcessorServer struct{}
func (UnimplementedTaskProcessorServer) RequestTasks(*emptypb.Empty, grpc.ServerStreamingServer[Task]) error {
return status.Errorf(codes.Unimplemented, "method RequestTasks not implemented")
}
func (UnimplementedTaskProcessorServer) SendResults(grpc.ClientStreamingServer[Result, emptypb.Empty]) error {
return status.Errorf(codes.Unimplemented, "method SendResults not implemented")
}
func (UnimplementedTaskProcessorServer) mustEmbedUnimplementedTaskProcessorServer() {}
func (UnimplementedTaskProcessorServer) testEmbeddedByValue() {}
// UnsafeTaskProcessorServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to TaskProcessorServer will
// result in compilation errors.
type UnsafeTaskProcessorServer interface {
mustEmbedUnimplementedTaskProcessorServer()
}
func RegisterTaskProcessorServer(s grpc.ServiceRegistrar, srv TaskProcessorServer) {
// If the following call pancis, it indicates UnimplementedTaskProcessorServer 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(&TaskProcessor_ServiceDesc, srv)
}
func _TaskProcessor_RequestTasks_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(emptypb.Empty)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(TaskProcessorServer).RequestTasks(m, &grpc.GenericServerStream[emptypb.Empty, Task]{ServerStream: stream})
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type TaskProcessor_RequestTasksServer = grpc.ServerStreamingServer[Task]
func _TaskProcessor_SendResults_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(TaskProcessorServer).SendResults(&grpc.GenericServerStream[Result, emptypb.Empty]{ServerStream: stream})
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type TaskProcessor_SendResultsServer = grpc.ClientStreamingServer[Result, emptypb.Empty]
// TaskProcessor_ServiceDesc is the grpc.ServiceDesc for TaskProcessor service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var TaskProcessor_ServiceDesc = grpc.ServiceDesc{
ServiceName: "taskTransport.TaskProcessor",
HandlerType: (*TaskProcessorServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "RequestTasks",
Handler: _TaskProcessor_RequestTasks_Handler,
ServerStreams: true,
},
{
StreamName: "SendResults",
Handler: _TaskProcessor_SendResults_Handler,
ClientStreams: true,
},
},
Metadata: "proto/taskTransport.proto",
}

22
proto/taskTransport.proto Normal file
View file

@ -0,0 +1,22 @@
syntax = "proto3";
import "google/protobuf/empty.proto";
package taskTransport;
option go_package = "/pkg/taskTransport/v1;taskTransportV1";
message Task{
string merch_uuid = 1;
map<string, string> origins = 2;
}
message Result{
string merch_uuid = 1;
string origin_name = 2;
int32 price = 3;
}
service TaskProcessor {
rpc RequestTasks(google.protobuf.Empty) returns (stream Task);
rpc SendResults(stream Result) returns (google.protobuf.Empty);
}