update command proto

This commit is contained in:
Yavolte 2025-06-06 14:51:58 +08:00
parent 7839f7caef
commit 3abcc1ceed
5 changed files with 147 additions and 30 deletions

View File

@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
descriptorpb "google.golang.org/protobuf/types/descriptorpb" descriptorpb "google.golang.org/protobuf/types/descriptorpb"
reflect "reflect" reflect "reflect"
sync "sync"
unsafe "unsafe" unsafe "unsafe"
) )
@ -21,14 +22,66 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
var file_aeus_command_proto_extTypes = []protoimpl.ExtensionInfo{ type CommandOptions struct {
state protoimpl.MessageState `protogen:"open.v1"`
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CommandOptions) Reset() {
*x = CommandOptions{}
mi := &file_command_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CommandOptions) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CommandOptions) ProtoMessage() {}
func (x *CommandOptions) ProtoReflect() protoreflect.Message {
mi := &file_command_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 CommandOptions.ProtoReflect.Descriptor instead.
func (*CommandOptions) Descriptor() ([]byte, []int) {
return file_command_proto_rawDescGZIP(), []int{0}
}
func (x *CommandOptions) GetPath() string {
if x != nil {
return x.Path
}
return ""
}
func (x *CommandOptions) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
var file_command_proto_extTypes = []protoimpl.ExtensionInfo{
{ {
ExtendedType: (*descriptorpb.MethodOptions)(nil), ExtendedType: (*descriptorpb.MethodOptions)(nil),
ExtensionType: (*string)(nil), ExtensionType: (*CommandOptions)(nil),
Field: 50001, Field: 50001,
Name: "aeus.command", Name: "aeus.command",
Tag: "bytes,50001,opt,name=command", Tag: "bytes,50001,opt,name=command",
Filename: "aeus/command.proto", Filename: "command.proto",
}, },
} }
@ -37,49 +90,68 @@ var (
// The 'command' option will be a string. // The 'command' option will be a string.
// Choose a field number in the reserved range (50000-99999) to avoid conflicts. // Choose a field number in the reserved range (50000-99999) to avoid conflicts.
// //
// optional string command = 50001; // optional aeus.CommandOptions command = 50001;
E_Command = &file_aeus_command_proto_extTypes[0] E_Command = &file_command_proto_extTypes[0]
) )
var File_aeus_command_proto protoreflect.FileDescriptor var File_command_proto protoreflect.FileDescriptor
const file_aeus_command_proto_rawDesc = "" + const file_command_proto_rawDesc = "" +
"\n" + "\n" +
"\x12aeus/command.proto\x12\x04aeus\x1a google/protobuf/descriptor.proto:=\n" + "\rcommand.proto\x12\x04aeus\x1a google/protobuf/descriptor.proto\"F\n" +
"\acommand\x12\x1e.google.protobuf.MethodOptions\x18ц\x03 \x01(\tR\acommand\x88\x01\x01B5Z3git.nobla.cn/golang/aeus/pkg/protoc/command;commandb\x06proto3" "\x0eCommandOptions\x12\x12\n" +
"\x04path\x18\x01 \x01(\tR\x04path\x12 \n" +
"\vdescription\x18\x02 \x01(\tR\vdescription:S\n" +
"\acommand\x12\x1e.google.protobuf.MethodOptions\x18ц\x03 \x01(\v2\x14.aeus.CommandOptionsR\acommand\x88\x01\x01B-Z+git.nobla.cn/golang/aeus/pkg/protoc/commandb\x06proto3"
var file_aeus_command_proto_goTypes = []any{ var (
(*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions file_command_proto_rawDescOnce sync.Once
file_command_proto_rawDescData []byte
)
func file_command_proto_rawDescGZIP() []byte {
file_command_proto_rawDescOnce.Do(func() {
file_command_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_command_proto_rawDesc), len(file_command_proto_rawDesc)))
})
return file_command_proto_rawDescData
} }
var file_aeus_command_proto_depIdxs = []int32{
0, // 0: aeus.command:extendee -> google.protobuf.MethodOptions var file_command_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
1, // [1:1] is the sub-list for method output_type var file_command_proto_goTypes = []any{
1, // [1:1] is the sub-list for method input_type (*CommandOptions)(nil), // 0: aeus.CommandOptions
1, // [1:1] is the sub-list for extension type_name (*descriptorpb.MethodOptions)(nil), // 1: google.protobuf.MethodOptions
}
var file_command_proto_depIdxs = []int32{
1, // 0: aeus.command:extendee -> google.protobuf.MethodOptions
0, // 1: aeus.command:type_name -> aeus.CommandOptions
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
1, // [1:2] is the sub-list for extension type_name
0, // [0:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name 0, // [0:0] is the sub-list for field type_name
} }
func init() { file_aeus_command_proto_init() } func init() { file_command_proto_init() }
func file_aeus_command_proto_init() { func file_command_proto_init() {
if File_aeus_command_proto != nil { if File_command_proto != nil {
return return
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_aeus_command_proto_rawDesc), len(file_aeus_command_proto_rawDesc)), RawDescriptor: unsafe.Slice(unsafe.StringData(file_command_proto_rawDesc), len(file_command_proto_rawDesc)),
NumEnums: 0, NumEnums: 0,
NumMessages: 0, NumMessages: 1,
NumExtensions: 1, NumExtensions: 1,
NumServices: 0, NumServices: 0,
}, },
GoTypes: file_aeus_command_proto_goTypes, GoTypes: file_command_proto_goTypes,
DependencyIndexes: file_aeus_command_proto_depIdxs, DependencyIndexes: file_command_proto_depIdxs,
ExtensionInfos: file_aeus_command_proto_extTypes, MessageInfos: file_command_proto_msgTypes,
ExtensionInfos: file_command_proto_extTypes,
}.Build() }.Build()
File_aeus_command_proto = out.File File_command_proto = out.File
file_aeus_command_proto_goTypes = nil file_command_proto_goTypes = nil
file_aeus_command_proto_depIdxs = nil file_command_proto_depIdxs = nil
} }

View File

@ -0,0 +1,20 @@
syntax = "proto3";
package aeus;
import "google/protobuf/descriptor.proto";
option go_package = "git.nobla.cn/golang/aeus/pkg/protoc/command";
message CommandOptions {
string path = 1;
string description = 2;
}
// Extend MethodOptions to add a custom 'command' option to RPC methods.
extend google.protobuf.MethodOptions {
// The 'command' option will be a string.
// Choose a field number in the reserved range (50000-99999) to avoid conflicts.
optional CommandOptions command = 50001;
}

View File

@ -116,14 +116,14 @@ func (ctx *Context) send(res responsePayload) (err error) {
} }
if res.Data == nil { if res.Data == nil {
buf = OK buf = OK
goto __END goto __end
} }
if marshal, ok = res.Data.(encoder); ok { if marshal, ok = res.Data.(encoder); ok {
buf, err = marshal.Marshal() buf, err = marshal.Marshal()
goto __END goto __end
} }
buf, err = serialize(res.Data) buf, err = serialize(res.Data)
__END: __end:
if err != nil { if err != nil {
return return
} }

View File

@ -85,3 +85,27 @@ type (
RemoteAddr string `json:"remote_addr"` RemoteAddr string `json:"remote_addr"`
} }
) )
func WithAddress(addr string) Option {
return func(o *options) {
o.address = addr
}
}
func WithNetwork(network string) Option {
return func(o *options) {
o.network = network
}
}
func WithLogger(logger logger.Logger) Option {
return func(o *options) {
o.logger = logger
}
}
func WithContext(ctx context.Context) Option {
return func(o *options) {
o.context = ctx
}
}

View File

@ -9,6 +9,7 @@ import (
grpcinsecure "google.golang.org/grpc/credentials/insecure" grpcinsecure "google.golang.org/grpc/credentials/insecure"
) )
// dial new gRPC "channel" for the target URI provided.
func Dial(ctx context.Context, target string, cbs ...ClientOption) (conn *grpc.ClientConn, err error) { func Dial(ctx context.Context, target string, cbs ...ClientOption) (conn *grpc.ClientConn, err error) {
grpc.WithResolvers() grpc.WithResolvers()
opts := &clientOptions{} opts := &clientOptions{}