diff --git a/_examples/03_custom_resolver/federation/federation.pb.go b/_examples/03_custom_resolver/federation/federation.pb.go index 399ed4f7..a12e1353 100644 --- a/_examples/03_custom_resolver/federation/federation.pb.go +++ b/_examples/03_custom_resolver/federation/federation.pb.go @@ -204,10 +204,11 @@ type PostV2Dev struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` - Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` - User *User `protobuf:"bytes,4,opt,name=user,proto3" json:"user,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` + Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` + User *User `protobuf:"bytes,4,opt,name=user,proto3" json:"user,omitempty"` + NullCheck bool `protobuf:"varint,5,opt,name=null_check,json=nullCheck,proto3" json:"null_check,omitempty"` } func (x *PostV2Dev) Reset() { @@ -270,6 +271,13 @@ func (x *PostV2Dev) GetUser() *User { return nil } +func (x *PostV2Dev) GetNullCheck() bool { + if x != nil { + return x.NullCheck + } + return false +} + type User struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -419,6 +427,44 @@ func (x *ForNameless) GetBar() string { return "" } +type TypedNil struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TypedNil) Reset() { + *x = TypedNil{} + if protoimpl.UnsafeEnabled { + mi := &file_federation_federation_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TypedNil) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TypedNil) ProtoMessage() {} + +func (x *TypedNil) ProtoReflect() protoreflect.Message { + mi := &file_federation_federation_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TypedNil.ProtoReflect.Descriptor instead. +func (*TypedNil) Descriptor() ([]byte, []int) { + return file_federation_federation_proto_rawDescGZIP(), []int{6} +} + var File_federation_federation_proto protoreflect.FileDescriptor var file_federation_federation_proto_rawDesc = []byte{ @@ -463,7 +509,7 @@ var file_federation_federation_proto_rawDesc = []byte{ 0x65, 0x66, 0x3a, 0x30, 0x9a, 0x4a, 0x2d, 0x0a, 0x1f, 0x0a, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x6a, 0x17, 0x0a, 0x09, 0x50, 0x6f, 0x73, 0x74, 0x56, 0x32, 0x64, 0x65, 0x76, 0x12, 0x0a, 0x0a, 0x02, 0x69, 0x64, 0x12, 0x04, 0x24, 0x2e, 0x69, 0x64, 0x0a, 0x0a, 0x0a, 0x01, 0x72, 0x6a, 0x05, 0x0a, - 0x03, 0x52, 0x65, 0x66, 0x22, 0xa1, 0x02, 0x0a, 0x09, 0x50, 0x6f, 0x73, 0x74, 0x56, 0x32, 0x64, + 0x03, 0x52, 0x65, 0x66, 0x22, 0xf3, 0x03, 0x0a, 0x09, 0x50, 0x6f, 0x73, 0x74, 0x56, 0x32, 0x64, 0x65, 0x76, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, @@ -471,7 +517,10 @@ var file_federation_federation_proto_rawDesc = []byte{ 0x6e, 0x74, 0x12, 0x31, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x64, 0x65, 0x76, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x42, 0x05, 0x9a, 0x4a, 0x02, 0x08, 0x01, 0x52, - 0x04, 0x75, 0x73, 0x65, 0x72, 0x3a, 0xa0, 0x01, 0x9a, 0x4a, 0x9c, 0x01, 0x0a, 0x2d, 0x0a, 0x03, + 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x2e, 0x0a, 0x0a, 0x6e, 0x75, 0x6c, 0x6c, 0x5f, 0x63, 0x68, + 0x65, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x42, 0x0f, 0x9a, 0x4a, 0x0c, 0x12, 0x0a, + 0x6e, 0x75, 0x6c, 0x6c, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x09, 0x6e, 0x75, 0x6c, 0x6c, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x3a, 0xc2, 0x02, 0x9a, 0x4a, 0xbe, 0x02, 0x0a, 0x2d, 0x0a, 0x03, 0x72, 0x65, 0x73, 0x72, 0x26, 0x0a, 0x18, 0x70, 0x6f, 0x73, 0x74, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x12, 0x0a, 0x0a, 0x02, 0x69, 0x64, 0x12, 0x04, 0x24, 0x2e, 0x69, 0x64, 0x0a, 0x12, 0x0a, 0x04, 0x70, @@ -481,48 +530,59 @@ var file_federation_federation_proto_rawDesc = []byte{ 0x64, 0x6a, 0x16, 0x0a, 0x06, 0x55, 0x6e, 0x75, 0x73, 0x65, 0x64, 0x12, 0x0c, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x12, 0x05, 0x27, 0x66, 0x6f, 0x6f, 0x27, 0x0a, 0x1d, 0x6a, 0x1b, 0x0a, 0x0b, 0x46, 0x6f, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x6c, 0x65, 0x73, 0x73, 0x12, 0x0c, 0x0a, 0x03, 0x62, 0x61, - 0x72, 0x12, 0x05, 0x27, 0x62, 0x61, 0x72, 0x27, 0x22, 0x7b, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x19, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, - 0x9a, 0x4a, 0x02, 0x08, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x3a, 0x48, 0x9a, 0x4a, 0x45, - 0x0a, 0x32, 0x0a, 0x03, 0x72, 0x65, 0x73, 0x72, 0x2b, 0x0a, 0x18, 0x75, 0x73, 0x65, 0x72, 0x2e, - 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x47, 0x65, 0x74, 0x55, - 0x73, 0x65, 0x72, 0x12, 0x0f, 0x0a, 0x02, 0x69, 0x64, 0x12, 0x09, 0x24, 0x2e, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x69, 0x64, 0x0a, 0x0d, 0x0a, 0x01, 0x75, 0x5a, 0x08, 0x72, 0x65, 0x73, 0x2e, 0x75, - 0x73, 0x65, 0x72, 0x10, 0x01, 0x22, 0x21, 0x0a, 0x06, 0x55, 0x6e, 0x75, 0x73, 0x65, 0x64, 0x12, - 0x10, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x66, 0x6f, - 0x6f, 0x3a, 0x05, 0x9a, 0x4a, 0x02, 0x10, 0x01, 0x22, 0x26, 0x0a, 0x0b, 0x46, 0x6f, 0x72, 0x4e, - 0x61, 0x6d, 0x65, 0x6c, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x61, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x62, 0x61, 0x72, 0x3a, 0x05, 0x9a, 0x4a, 0x02, 0x10, 0x01, - 0x2a, 0x25, 0x0a, 0x0d, 0x50, 0x6f, 0x73, 0x74, 0x56, 0x32, 0x64, 0x65, 0x76, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x14, 0x0a, 0x10, 0x50, 0x4f, 0x53, 0x54, 0x5f, 0x56, 0x32, 0x5f, 0x44, 0x45, 0x56, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x00, 0x32, 0xc9, 0x01, 0x0a, 0x16, 0x46, 0x65, 0x64, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x32, 0x64, 0x65, 0x76, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x56, 0x32, 0x64, - 0x65, 0x76, 0x12, 0x25, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x76, 0x32, 0x64, 0x65, 0x76, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x56, 0x32, 0x64, - 0x65, 0x76, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x66, 0x65, 0x64, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x64, 0x65, 0x76, 0x2e, 0x47, 0x65, 0x74, - 0x50, 0x6f, 0x73, 0x74, 0x56, 0x32, 0x64, 0x65, 0x76, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x1a, 0x4e, 0x9a, 0x4a, 0x4b, 0x0a, 0x49, 0x0a, 0x0e, 0x0a, 0x01, 0x61, 0x12, - 0x02, 0x08, 0x01, 0x1a, 0x05, 0x12, 0x03, 0x78, 0x78, 0x78, 0x0a, 0x10, 0x0a, 0x01, 0x62, 0x12, - 0x04, 0x12, 0x02, 0x08, 0x03, 0x1a, 0x05, 0x0a, 0x03, 0x79, 0x79, 0x79, 0x0a, 0x18, 0x0a, 0x01, - 0x63, 0x12, 0x0a, 0x1a, 0x08, 0x0a, 0x02, 0x08, 0x01, 0x12, 0x02, 0x08, 0x06, 0x1a, 0x07, 0x0a, - 0x03, 0x7a, 0x7a, 0x7a, 0x18, 0x01, 0x0a, 0x0b, 0x0a, 0x01, 0x64, 0x12, 0x02, 0x08, 0x05, 0x1a, - 0x02, 0x20, 0x01, 0x42, 0xcc, 0x01, 0x9a, 0x4a, 0x22, 0x12, 0x0f, 0x70, 0x6f, 0x73, 0x74, 0x2f, - 0x70, 0x6f, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x75, 0x73, 0x65, 0x72, - 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x0a, 0x14, 0x63, 0x6f, 0x6d, + 0x72, 0x12, 0x05, 0x27, 0x62, 0x61, 0x72, 0x27, 0x0a, 0x17, 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, + 0x64, 0x5f, 0x6e, 0x69, 0x6c, 0x6a, 0x0a, 0x0a, 0x08, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4e, 0x69, + 0x6c, 0x0a, 0x25, 0x0a, 0x0a, 0x6e, 0x75, 0x6c, 0x6c, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x12, + 0x11, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, 0x6e, 0x69, 0x6c, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, + 0x6c, 0x6c, 0x5a, 0x04, 0x74, 0x72, 0x75, 0x65, 0x0a, 0x60, 0x12, 0x11, 0x74, 0x79, 0x70, 0x65, + 0x64, 0x5f, 0x6e, 0x69, 0x6c, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x5a, 0x4b, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x6c, + 0x6f, 0x67, 0x2e, 0x69, 0x6e, 0x66, 0x6f, 0x28, 0x27, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, + 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, 0x6e, 0x69, 0x6c, 0x27, 0x2c, 0x20, 0x7b, 0x27, 0x72, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x27, 0x3a, 0x20, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, 0x6e, 0x69, 0x6c, + 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x7d, 0x29, 0x22, 0x7b, 0x0a, 0x04, 0x55, 0x73, + 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x19, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x05, 0x9a, 0x4a, 0x02, 0x08, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x3a, 0x48, 0x9a, + 0x4a, 0x45, 0x0a, 0x32, 0x0a, 0x03, 0x72, 0x65, 0x73, 0x72, 0x2b, 0x0a, 0x18, 0x75, 0x73, 0x65, + 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x47, 0x65, + 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0f, 0x0a, 0x02, 0x69, 0x64, 0x12, 0x09, 0x24, 0x2e, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x0a, 0x0d, 0x0a, 0x01, 0x75, 0x5a, 0x08, 0x72, 0x65, 0x73, + 0x2e, 0x75, 0x73, 0x65, 0x72, 0x10, 0x01, 0x22, 0x21, 0x0a, 0x06, 0x55, 0x6e, 0x75, 0x73, 0x65, + 0x64, 0x12, 0x10, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x66, 0x6f, 0x6f, 0x3a, 0x05, 0x9a, 0x4a, 0x02, 0x10, 0x01, 0x22, 0x26, 0x0a, 0x0b, 0x46, 0x6f, + 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x6c, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x61, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x62, 0x61, 0x72, 0x3a, 0x05, 0x9a, 0x4a, 0x02, + 0x10, 0x01, 0x22, 0x11, 0x0a, 0x08, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4e, 0x69, 0x6c, 0x3a, 0x05, + 0x9a, 0x4a, 0x02, 0x10, 0x01, 0x2a, 0x25, 0x0a, 0x0d, 0x50, 0x6f, 0x73, 0x74, 0x56, 0x32, 0x64, + 0x65, 0x76, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x50, 0x4f, 0x53, 0x54, 0x5f, 0x56, + 0x32, 0x5f, 0x44, 0x45, 0x56, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x00, 0x32, 0xc9, 0x01, 0x0a, + 0x16, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x32, 0x64, 0x65, 0x76, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x50, 0x6f, + 0x73, 0x74, 0x56, 0x32, 0x64, 0x65, 0x76, 0x12, 0x25, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x64, 0x65, 0x76, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, + 0x73, 0x74, 0x56, 0x32, 0x64, 0x65, 0x76, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x64, 0x65, - 0x76, 0x42, 0x0f, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1d, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x66, 0x65, - 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x46, 0x56, 0x58, 0xaa, 0x02, 0x10, 0x46, 0x65, 0x64, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x32, 0x64, 0x65, 0x76, 0xca, 0x02, 0x10, 0x46, - 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x32, 0x64, 0x65, 0x76, 0xe2, - 0x02, 0x1c, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x32, 0x64, - 0x65, 0x76, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x11, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x3a, 0x56, 0x32, 0x64, - 0x65, 0x76, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x76, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x56, 0x32, 0x64, 0x65, 0x76, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x1a, 0x4e, 0x9a, 0x4a, 0x4b, 0x0a, 0x49, 0x0a, + 0x0e, 0x0a, 0x01, 0x61, 0x12, 0x02, 0x08, 0x01, 0x1a, 0x05, 0x12, 0x03, 0x78, 0x78, 0x78, 0x0a, + 0x10, 0x0a, 0x01, 0x62, 0x12, 0x04, 0x12, 0x02, 0x08, 0x03, 0x1a, 0x05, 0x0a, 0x03, 0x79, 0x79, + 0x79, 0x0a, 0x18, 0x0a, 0x01, 0x63, 0x12, 0x0a, 0x1a, 0x08, 0x0a, 0x02, 0x08, 0x01, 0x12, 0x02, + 0x08, 0x06, 0x1a, 0x07, 0x0a, 0x03, 0x7a, 0x7a, 0x7a, 0x18, 0x01, 0x0a, 0x0b, 0x0a, 0x01, 0x64, + 0x12, 0x02, 0x08, 0x05, 0x1a, 0x02, 0x20, 0x01, 0x42, 0xcc, 0x01, 0x9a, 0x4a, 0x22, 0x12, 0x0f, + 0x70, 0x6f, 0x73, 0x74, 0x2f, 0x70, 0x6f, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x0f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x76, 0x32, 0x64, 0x65, 0x76, 0x42, 0x0f, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1d, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x2f, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x66, 0x65, + 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x46, 0x56, 0x58, 0xaa, 0x02, + 0x10, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x32, 0x64, 0x65, + 0x76, 0xca, 0x02, 0x10, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, + 0x32, 0x64, 0x65, 0x76, 0xe2, 0x02, 0x1c, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5c, 0x56, 0x32, 0x64, 0x65, 0x76, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x3a, 0x3a, 0x56, 0x32, 0x64, 0x65, 0x76, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -538,7 +598,7 @@ func file_federation_federation_proto_rawDescGZIP() []byte { } var file_federation_federation_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_federation_federation_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_federation_federation_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_federation_federation_proto_goTypes = []interface{}{ (PostV2DevType)(0), // 0: federation.v2dev.PostV2devType (*GetPostV2DevRequest)(nil), // 1: federation.v2dev.GetPostV2devRequest @@ -547,14 +607,15 @@ var file_federation_federation_proto_goTypes = []interface{}{ (*User)(nil), // 4: federation.v2dev.User (*Unused)(nil), // 5: federation.v2dev.Unused (*ForNameless)(nil), // 6: federation.v2dev.ForNameless - (*durationpb.Duration)(nil), // 7: google.protobuf.Duration - (*Ref)(nil), // 8: federation.v2dev.Ref + (*TypedNil)(nil), // 7: federation.v2dev.TypedNil + (*durationpb.Duration)(nil), // 8: google.protobuf.Duration + (*Ref)(nil), // 9: federation.v2dev.Ref } var file_federation_federation_proto_depIdxs = []int32{ 3, // 0: federation.v2dev.GetPostV2devResponse.post:type_name -> federation.v2dev.PostV2dev 0, // 1: federation.v2dev.GetPostV2devResponse.type:type_name -> federation.v2dev.PostV2devType - 7, // 2: federation.v2dev.GetPostV2devResponse.env_c_value:type_name -> google.protobuf.Duration - 8, // 3: federation.v2dev.GetPostV2devResponse.ref:type_name -> federation.v2dev.Ref + 8, // 2: federation.v2dev.GetPostV2devResponse.env_c_value:type_name -> google.protobuf.Duration + 9, // 3: federation.v2dev.GetPostV2devResponse.ref:type_name -> federation.v2dev.Ref 4, // 4: federation.v2dev.PostV2dev.user:type_name -> federation.v2dev.User 1, // 5: federation.v2dev.FederationV2devService.GetPostV2dev:input_type -> federation.v2dev.GetPostV2devRequest 2, // 6: federation.v2dev.FederationV2devService.GetPostV2dev:output_type -> federation.v2dev.GetPostV2devResponse @@ -644,6 +705,18 @@ func file_federation_federation_proto_init() { return nil } } + file_federation_federation_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TypedNil); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -651,7 +724,7 @@ func file_federation_federation_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_federation_federation_proto_rawDesc, NumEnums: 1, - NumMessages: 6, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/_examples/03_custom_resolver/federation/federation_grpc_federation.pb.go b/_examples/03_custom_resolver/federation/federation_grpc_federation.pb.go index 065746b7..4c7dbde4 100644 --- a/_examples/03_custom_resolver/federation/federation_grpc_federation.pb.go +++ b/_examples/03_custom_resolver/federation/federation_grpc_federation.pb.go @@ -40,12 +40,15 @@ type FederationV2DevService_Federation_V2Dev_GetPostV2DevResponseArgument struct // Federation_V2Dev_PostV2DevArgument is argument for "federation.v2dev.PostV2dev" message. type FederationV2DevService_Federation_V2Dev_PostV2DevArgument struct { - Id string - Post *post.Post - Res *post.GetPostResponse - Unused *Unused - User *User - XDef4 *ForNameless + Id string + NullCheck bool + Post *post.Post + Res *post.GetPostResponse + TypedNil *TypedNil + Unused *Unused + User *User + XDef4 *ForNameless + XDef7 bool } // Federation_V2Dev_PostV2Dev_UserArgument is custom resolver's argument for "user" field of "federation.v2dev.PostV2dev" message. @@ -57,6 +60,10 @@ type FederationV2DevService_Federation_V2Dev_PostV2Dev_UserArgument struct { type FederationV2DevService_Federation_V2Dev_RefArgument struct { } +// Federation_V2Dev_TypedNilArgument is argument for "federation.v2dev.TypedNil" message. +type FederationV2DevService_Federation_V2Dev_TypedNilArgument struct { +} + // Federation_V2Dev_UnusedArgument is argument for "federation.v2dev.Unused" message. type FederationV2DevService_Federation_V2Dev_UnusedArgument struct { Foo string @@ -121,6 +128,8 @@ type FederationV2DevServiceResolver interface { Resolve_Federation_V2Dev_ForNameless(context.Context, *FederationV2DevService_Federation_V2Dev_ForNamelessArgument) (*ForNameless, error) // Resolve_Federation_V2Dev_PostV2Dev_User implements resolver for "federation.v2dev.PostV2dev.user". Resolve_Federation_V2Dev_PostV2Dev_User(context.Context, *FederationV2DevService_Federation_V2Dev_PostV2Dev_UserArgument) (*User, error) + // Resolve_Federation_V2Dev_TypedNil implements resolver for "federation.v2dev.TypedNil". + Resolve_Federation_V2Dev_TypedNil(context.Context, *FederationV2DevService_Federation_V2Dev_TypedNilArgument) (*TypedNil, error) // Resolve_Federation_V2Dev_Unused implements resolver for "federation.v2dev.Unused". Resolve_Federation_V2Dev_Unused(context.Context, *FederationV2DevService_Federation_V2Dev_UnusedArgument) (*Unused, error) // Resolve_Federation_V2Dev_User implements resolver for "federation.v2dev.User". @@ -179,6 +188,13 @@ func (FederationV2DevServiceUnimplementedResolver) Resolve_Federation_V2Dev_Post return } +// Resolve_Federation_V2Dev_TypedNil resolve "federation.v2dev.TypedNil". +// This method always returns Unimplemented error. +func (FederationV2DevServiceUnimplementedResolver) Resolve_Federation_V2Dev_TypedNil(context.Context, *FederationV2DevService_Federation_V2Dev_TypedNilArgument) (ret *TypedNil, e error) { + e = grpcfed.GRPCErrorf(grpcfed.UnimplementedCode, "method Resolve_Federation_V2Dev_TypedNil not implemented") + return +} + // Resolve_Federation_V2Dev_Unused resolve "federation.v2dev.Unused". // This method always returns Unimplemented error. func (FederationV2DevServiceUnimplementedResolver) Resolve_Federation_V2Dev_Unused(context.Context, *FederationV2DevService_Federation_V2Dev_UnusedArgument) (ret *Unused, e error) { @@ -259,7 +275,8 @@ func NewFederationV2DevService(cfg FederationV2DevServiceConfig) (*FederationV2D "grpc.federation.private.PostV2devArgument": { "id": grpcfed.NewCELFieldType(grpcfed.CELStringType, "Id"), }, - "grpc.federation.private.RefArgument": {}, + "grpc.federation.private.RefArgument": {}, + "grpc.federation.private.TypedNilArgument": {}, "grpc.federation.private.UnusedArgument": { "foo": grpcfed.NewCELFieldType(grpcfed.CELStringType, "Foo"), }, @@ -558,22 +575,29 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_PostV2Dev(ctx context. type localValueType struct { *grpcfed.LocalValue vars struct { - _def4 *ForNameless - post *post.Post - res *post.GetPostResponse - unused *Unused - user *User + _def4 *ForNameless + _def7 bool + null_check bool + post *post.Post + res *post.GetPostResponse + typed_nil *TypedNil + unused *Unused + user *User } } value := &localValueType{LocalValue: grpcfed.NewLocalValue(ctx, s.celEnvOpts, "grpc.federation.private.PostV2devArgument", req)} value.AddEnv(s.env) // A tree view of message dependencies is shown below. /* - _def4 ─┐ - unused ─┤ - res ─┐ │ - post ─┐ │ - user ─┤ + _def4 ─┐ + typed_nil ─┐ │ + _def7 ─┤ + typed_nil ─┐ │ + null_check ─┤ + unused ─┤ + res ─┐ │ + post ─┐ │ + user ─┤ */ eg, ctx1 := grpcfed.ErrorGroupWithContext(ctx) @@ -623,6 +647,120 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_PostV2Dev(ctx context. return nil, nil }) + grpcfed.GoWithRecover(eg, func() (any, error) { + + // This section's codes are generated by the following proto definition. + /* + def { + name: "typed_nil" + message { + name: "TypedNil" + } + } + */ + if err := grpcfed.EvalDef(ctx1, value, grpcfed.Def[*TypedNil, *localValueType]{ + Name: `typed_nil`, + Type: grpcfed.CELObjectType("federation.v2dev.TypedNil"), + Setter: func(value *localValueType, v *TypedNil) error { + value.vars.typed_nil = v + return nil + }, + Message: func(ctx context.Context, value *localValueType) (any, error) { + args := &FederationV2DevService_Federation_V2Dev_TypedNilArgument{} + ret, err := s.resolve_Federation_V2Dev_TypedNil(ctx, args) + if err != nil { + return nil, err + } + return ret, nil + }, + }); err != nil { + grpcfed.RecordErrorToSpan(ctx1, err) + return nil, err + } + + // This section's codes are generated by the following proto definition. + /* + def { + name: "_def7" + if: "typed_nil == null" + by: "grpc.federation.log.info('output typed_nil', {'result': typed_nil == null})" + } + */ + if err := grpcfed.EvalDef(ctx1, value, grpcfed.Def[bool, *localValueType]{ + If: `typed_nil == null`, + IfCacheIndex: 9, + Name: `_def7`, + Type: grpcfed.CELBoolType, + Setter: func(value *localValueType, v bool) error { + value.vars._def7 = v + return nil + }, + By: `grpc.federation.log.info('output typed_nil', {'result': typed_nil == null})`, + ByCacheIndex: 10, + }); err != nil { + grpcfed.RecordErrorToSpan(ctx1, err) + return nil, err + } + return nil, nil + }) + + grpcfed.GoWithRecover(eg, func() (any, error) { + + // This section's codes are generated by the following proto definition. + /* + def { + name: "typed_nil" + message { + name: "TypedNil" + } + } + */ + if err := grpcfed.EvalDef(ctx1, value, grpcfed.Def[*TypedNil, *localValueType]{ + Name: `typed_nil`, + Type: grpcfed.CELObjectType("federation.v2dev.TypedNil"), + Setter: func(value *localValueType, v *TypedNil) error { + value.vars.typed_nil = v + return nil + }, + Message: func(ctx context.Context, value *localValueType) (any, error) { + args := &FederationV2DevService_Federation_V2Dev_TypedNilArgument{} + ret, err := s.resolve_Federation_V2Dev_TypedNil(ctx, args) + if err != nil { + return nil, err + } + return ret, nil + }, + }); err != nil { + grpcfed.RecordErrorToSpan(ctx1, err) + return nil, err + } + + // This section's codes are generated by the following proto definition. + /* + def { + name: "null_check" + if: "typed_nil == null" + by: "true" + } + */ + if err := grpcfed.EvalDef(ctx1, value, grpcfed.Def[bool, *localValueType]{ + If: `typed_nil == null`, + IfCacheIndex: 11, + Name: `null_check`, + Type: grpcfed.CELBoolType, + Setter: func(value *localValueType, v bool) error { + value.vars.null_check = v + return nil + }, + By: `true`, + ByCacheIndex: 12, + }); err != nil { + grpcfed.RecordErrorToSpan(ctx1, err) + return nil, err + } + return nil, nil + }) + grpcfed.GoWithRecover(eg, func() (any, error) { // This section's codes are generated by the following proto definition. @@ -648,7 +786,7 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_PostV2Dev(ctx context. if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `'foo'`, - CacheIndex: 9, + CacheIndex: 13, Setter: func(v string) error { args.Foo = v return nil @@ -694,7 +832,7 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_PostV2Dev(ctx context. if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `$.id`, - CacheIndex: 10, + CacheIndex: 14, Setter: func(v string) error { args.Id = v return nil @@ -732,7 +870,7 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_PostV2Dev(ctx context. return nil }, By: `res.post`, - ByCacheIndex: 11, + ByCacheIndex: 15, }); err != nil { grpcfed.RecordErrorToSpan(ctx1, err) return nil, err @@ -761,7 +899,7 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_PostV2Dev(ctx context. if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[*post.Post]{ Value: value, Expr: `post`, - CacheIndex: 12, + CacheIndex: 16, Setter: func(v *post.Post) error { args.Id = v.GetId() args.Title = v.GetTitle() @@ -790,11 +928,14 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_PostV2Dev(ctx context. } // assign named parameters to message arguments to pass to the custom resolver. + req.NullCheck = value.vars.null_check req.Post = value.vars.post req.Res = value.vars.res + req.TypedNil = value.vars.typed_nil req.Unused = value.vars.unused req.User = value.vars.user req.XDef4 = value.vars._def4 + req.XDef7 = value.vars._def7 // create a message value to be returned. ret := &PostV2Dev{} @@ -815,6 +956,19 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_PostV2Dev(ctx context. return nil, err } } + // (grpc.federation.field).by = "null_check" + if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[bool]{ + Value: value, + Expr: `null_check`, + CacheIndex: 17, + Setter: func(v bool) error { + ret.NullCheck = v + return nil + }, + }); err != nil { + grpcfed.RecordErrorToSpan(ctx, err) + return nil, err + } grpcfed.Logger(ctx).DebugContext(ctx, "resolved federation.v2dev.PostV2dev", slog.Any("federation.v2dev.PostV2dev", s.logvalue_Federation_V2Dev_PostV2Dev(ret))) return ret, nil @@ -843,7 +997,7 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_Ref(ctx context.Contex if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `grpc.federation.env.a`, - CacheIndex: 13, + CacheIndex: 18, Setter: func(v string) error { ret.A = v return nil @@ -857,6 +1011,27 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_Ref(ctx context.Contex return ret, nil } +// resolve_Federation_V2Dev_TypedNil resolve "federation.v2dev.TypedNil" message. +func (s *FederationV2DevService) resolve_Federation_V2Dev_TypedNil(ctx context.Context, req *FederationV2DevService_Federation_V2Dev_TypedNilArgument) (*TypedNil, error) { + ctx, span := s.tracer.Start(ctx, "federation.v2dev.TypedNil") + defer span.End() + ctx = grpcfed.WithLogger(ctx, grpcfed.Logger(ctx), grpcfed.LogAttrs(ctx)...) + + grpcfed.Logger(ctx).DebugContext(ctx, "resolve federation.v2dev.TypedNil", slog.Any("message_args", s.logvalue_Federation_V2Dev_TypedNilArgument(req))) + + // create a message value to be returned. + // `custom_resolver = true` in "grpc.federation.message" option. + ctx = grpcfed.WithLogger(ctx, grpcfed.Logger(ctx)) // create a new reference to logger. + ret, err := s.resolver.Resolve_Federation_V2Dev_TypedNil(ctx, req) + if err != nil { + grpcfed.RecordErrorToSpan(ctx, err) + return nil, err + } + + grpcfed.Logger(ctx).DebugContext(ctx, "resolved federation.v2dev.TypedNil", slog.Any("federation.v2dev.TypedNil", s.logvalue_Federation_V2Dev_TypedNil(ret))) + return ret, nil +} + // resolve_Federation_V2Dev_Unused resolve "federation.v2dev.Unused" message. func (s *FederationV2DevService) resolve_Federation_V2Dev_Unused(ctx context.Context, req *FederationV2DevService_Federation_V2Dev_UnusedArgument) (*Unused, error) { ctx, span := s.tracer.Start(ctx, "federation.v2dev.Unused") @@ -918,7 +1093,7 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_User(ctx context.Conte if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `$.user_id`, - CacheIndex: 14, + CacheIndex: 19, Setter: func(v string) error { args.Id = v return nil @@ -955,7 +1130,7 @@ func (s *FederationV2DevService) resolve_Federation_V2Dev_User(ctx context.Conte return nil }, By: `res.user`, - ByCacheIndex: 15, + ByCacheIndex: 20, }); err != nil { grpcfed.RecordErrorToSpan(ctx, err) return nil, err @@ -1063,6 +1238,7 @@ func (s *FederationV2DevService) logvalue_Federation_V2Dev_PostV2Dev(v *PostV2De slog.String("title", v.GetTitle()), slog.String("content", v.GetContent()), slog.Any("user", s.logvalue_Federation_V2Dev_User(v.GetUser())), + slog.Bool("null_check", v.GetNullCheck()), ) } @@ -1099,6 +1275,20 @@ func (s *FederationV2DevService) logvalue_Federation_V2Dev_RefArgument(v *Federa return slog.GroupValue() } +func (s *FederationV2DevService) logvalue_Federation_V2Dev_TypedNil(v *TypedNil) slog.Value { + if v == nil { + return slog.GroupValue() + } + return slog.GroupValue() +} + +func (s *FederationV2DevService) logvalue_Federation_V2Dev_TypedNilArgument(v *FederationV2DevService_Federation_V2Dev_TypedNilArgument) slog.Value { + if v == nil { + return slog.GroupValue() + } + return slog.GroupValue() +} + func (s *FederationV2DevService) logvalue_Federation_V2Dev_Unused(v *Unused) slog.Value { if v == nil { return slog.GroupValue() diff --git a/_examples/03_custom_resolver/main_test.go b/_examples/03_custom_resolver/main_test.go index da1c25c0..1bcf4c8e 100644 --- a/_examples/03_custom_resolver/main_test.go +++ b/_examples/03_custom_resolver/main_test.go @@ -86,10 +86,14 @@ func (r *Resolver) Resolve_Federation_V2Dev_ForNameless(_ context.Context, _ *fe return &federation.ForNameless{}, nil } -func (r *Resolver) Resolve_Federation_V2Dev_User_Name(ctx context.Context, arg *federation.FederationV2DevService_Federation_V2Dev_User_NameArgument) (string, error) { +func (r *Resolver) Resolve_Federation_V2Dev_User_Name(_ context.Context, arg *federation.FederationV2DevService_Federation_V2Dev_User_NameArgument) (string, error) { return arg.Federation_V2Dev_User.Name, nil } +func (r *Resolver) Resolve_Federation_V2Dev_TypedNil(_ context.Context, _ *federation.FederationV2DevService_Federation_V2Dev_TypedNilArgument) (*federation.TypedNil, error) { + return nil, nil +} + type PostServer struct { *post.UnimplementedPostServiceServer } @@ -246,6 +250,7 @@ func TestFederation(t *testing.T) { Id: "anonymous_id", Name: "anonymous", }, + NullCheck: true, }, EnvA: "xxx", EnvB: 2, diff --git a/_examples/03_custom_resolver/proto/federation/federation.proto b/_examples/03_custom_resolver/proto/federation/federation.proto index 8cd982e0..0b979185 100644 --- a/_examples/03_custom_resolver/proto/federation/federation.proto +++ b/_examples/03_custom_resolver/proto/federation/federation.proto @@ -101,18 +101,36 @@ message PostV2dev { args { name: "foo", by: "'foo'" } } }, - { + { + // without name message { name: "ForNameless" args { name: "bar", by: "'bar'" } } - } // without name + }, + { + // assign typed-nil by custom resolver + name: "typed_nil" + message { + name: "TypedNil" + } + }, + { + name: "null_check" + if: "typed_nil == null" // replace `grpc.federation.cast.null_value(typed_nil) == null` by EvalCEL function + by: "true" + }, + { + if: "typed_nil == null" + by: "grpc.federation.log.info('output typed_nil', {'result': typed_nil == null})" + } ] }; string id = 1; string title = 2; string content = 3; User user = 4 [(grpc.federation.field).custom_resolver = true]; + bool null_check = 5 [(grpc.federation.field).by = "null_check"]; } message User { @@ -140,3 +158,7 @@ message ForNameless { option (grpc.federation.message).custom_resolver = true; string bar = 1; } + +message TypedNil { + option (grpc.federation.message).custom_resolver = true; +} \ No newline at end of file diff --git a/_examples/10_oneof/federation/federation.pb.go b/_examples/10_oneof/federation/federation.pb.go index b560dd87..db6e4f61 100644 --- a/_examples/10_oneof/federation/federation.pb.go +++ b/_examples/10_oneof/federation/federation.pb.go @@ -114,6 +114,91 @@ func (x *GetResponse) GetMsg() string { return "" } +type GetNoValueRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GetNoValueRequest) Reset() { + *x = GetNoValueRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_federation_federation_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetNoValueRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNoValueRequest) ProtoMessage() {} + +func (x *GetNoValueRequest) ProtoReflect() protoreflect.Message { + mi := &file_federation_federation_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNoValueRequest.ProtoReflect.Descriptor instead. +func (*GetNoValueRequest) Descriptor() ([]byte, []int) { + return file_federation_federation_proto_rawDescGZIP(), []int{2} +} + +type GetNoValueResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NoValue *M `protobuf:"bytes,1,opt,name=no_value,json=noValue,proto3" json:"no_value,omitempty"` +} + +func (x *GetNoValueResponse) Reset() { + *x = GetNoValueResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_federation_federation_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetNoValueResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNoValueResponse) ProtoMessage() {} + +func (x *GetNoValueResponse) ProtoReflect() protoreflect.Message { + mi := &file_federation_federation_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNoValueResponse.ProtoReflect.Descriptor instead. +func (*GetNoValueResponse) Descriptor() ([]byte, []int) { + return file_federation_federation_proto_rawDescGZIP(), []int{3} +} + +func (x *GetNoValueResponse) GetNoValue() *M { + if x != nil { + return x.NoValue + } + return nil +} + type UserSelection struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -130,7 +215,7 @@ type UserSelection struct { func (x *UserSelection) Reset() { *x = UserSelection{} if protoimpl.UnsafeEnabled { - mi := &file_federation_federation_proto_msgTypes[2] + mi := &file_federation_federation_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -143,7 +228,7 @@ func (x *UserSelection) String() string { func (*UserSelection) ProtoMessage() {} func (x *UserSelection) ProtoReflect() protoreflect.Message { - mi := &file_federation_federation_proto_msgTypes[2] + mi := &file_federation_federation_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -156,7 +241,7 @@ func (x *UserSelection) ProtoReflect() protoreflect.Message { // Deprecated: Use UserSelection.ProtoReflect.Descriptor instead. func (*UserSelection) Descriptor() ([]byte, []int) { - return file_federation_federation_proto_rawDescGZIP(), []int{2} + return file_federation_federation_proto_rawDescGZIP(), []int{4} } func (m *UserSelection) GetUser() isUserSelection_User { @@ -225,7 +310,7 @@ type MessageSelection struct { func (x *MessageSelection) Reset() { *x = MessageSelection{} if protoimpl.UnsafeEnabled { - mi := &file_federation_federation_proto_msgTypes[3] + mi := &file_federation_federation_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -238,7 +323,7 @@ func (x *MessageSelection) String() string { func (*MessageSelection) ProtoMessage() {} func (x *MessageSelection) ProtoReflect() protoreflect.Message { - mi := &file_federation_federation_proto_msgTypes[3] + mi := &file_federation_federation_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -251,7 +336,7 @@ func (x *MessageSelection) ProtoReflect() protoreflect.Message { // Deprecated: Use MessageSelection.ProtoReflect.Descriptor instead. func (*MessageSelection) Descriptor() ([]byte, []int) { - return file_federation_federation_proto_rawDescGZIP(), []int{3} + return file_federation_federation_proto_rawDescGZIP(), []int{5} } func (m *MessageSelection) GetMessage() isMessageSelection_Message { @@ -304,6 +389,87 @@ func (*MessageSelection_MsgB) isMessageSelection_Message() {} func (*MessageSelection_MsgC) isMessageSelection_Message() {} +type NoValueSelection struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to NoValue: + // + // *NoValueSelection_MA + // *NoValueSelection_MB + NoValue isNoValueSelection_NoValue `protobuf_oneof:"no_value"` +} + +func (x *NoValueSelection) Reset() { + *x = NoValueSelection{} + if protoimpl.UnsafeEnabled { + mi := &file_federation_federation_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NoValueSelection) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NoValueSelection) ProtoMessage() {} + +func (x *NoValueSelection) ProtoReflect() protoreflect.Message { + mi := &file_federation_federation_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NoValueSelection.ProtoReflect.Descriptor instead. +func (*NoValueSelection) Descriptor() ([]byte, []int) { + return file_federation_federation_proto_rawDescGZIP(), []int{6} +} + +func (m *NoValueSelection) GetNoValue() isNoValueSelection_NoValue { + if m != nil { + return m.NoValue + } + return nil +} + +func (x *NoValueSelection) GetMA() *M { + if x, ok := x.GetNoValue().(*NoValueSelection_MA); ok { + return x.MA + } + return nil +} + +func (x *NoValueSelection) GetMB() *M { + if x, ok := x.GetNoValue().(*NoValueSelection_MB); ok { + return x.MB + } + return nil +} + +type isNoValueSelection_NoValue interface { + isNoValueSelection_NoValue() +} + +type NoValueSelection_MA struct { + MA *M `protobuf:"bytes,1,opt,name=m_a,json=mA,proto3,oneof"` +} + +type NoValueSelection_MB struct { + MB *M `protobuf:"bytes,2,opt,name=m_b,json=mB,proto3,oneof"` +} + +func (*NoValueSelection_MA) isNoValueSelection_NoValue() {} + +func (*NoValueSelection_MB) isNoValueSelection_NoValue() {} + type M struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -315,7 +481,7 @@ type M struct { func (x *M) Reset() { *x = M{} if protoimpl.UnsafeEnabled { - mi := &file_federation_federation_proto_msgTypes[4] + mi := &file_federation_federation_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -328,7 +494,7 @@ func (x *M) String() string { func (*M) ProtoMessage() {} func (x *M) ProtoReflect() protoreflect.Message { - mi := &file_federation_federation_proto_msgTypes[4] + mi := &file_federation_federation_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -341,7 +507,7 @@ func (x *M) ProtoReflect() protoreflect.Message { // Deprecated: Use M.ProtoReflect.Descriptor instead. func (*M) Descriptor() ([]byte, []int) { - return file_federation_federation_proto_rawDescGZIP(), []int{4} + return file_federation_federation_proto_rawDescGZIP(), []int{7} } func (x *M) GetValue() string { @@ -362,7 +528,7 @@ type User struct { func (x *User) Reset() { *x = User{} if protoimpl.UnsafeEnabled { - mi := &file_federation_federation_proto_msgTypes[5] + mi := &file_federation_federation_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -375,7 +541,7 @@ func (x *User) String() string { func (*User) ProtoMessage() {} func (x *User) ProtoReflect() protoreflect.Message { - mi := &file_federation_federation_proto_msgTypes[5] + mi := &file_federation_federation_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -388,7 +554,7 @@ func (x *User) ProtoReflect() protoreflect.Message { // Deprecated: Use User.ProtoReflect.Descriptor instead. func (*User) Descriptor() ([]byte, []int) { - return file_federation_federation_proto_rawDescGZIP(), []int{5} + return file_federation_federation_proto_rawDescGZIP(), []int{8} } func (x *User) GetId() string { @@ -418,70 +584,96 @@ var file_federation_federation_proto_rawDesc = []byte{ 0x65, 0x72, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x05, 0x27, 0x66, 0x6f, 0x6f, 0x27, 0x0a, 0x1d, 0x0a, 0x07, 0x6d, 0x73, 0x67, 0x5f, 0x73, 0x65, 0x6c, 0x6a, 0x12, 0x0a, 0x10, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x80, 0x03, 0x0a, 0x0d, 0x55, - 0x73, 0x65, 0x72, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x77, 0x0a, 0x06, - 0x75, 0x73, 0x65, 0x72, 0x5f, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, + 0x65, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x13, 0x0a, 0x11, 0x47, 0x65, + 0x74, 0x4e, 0x6f, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, + 0x87, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x08, 0x6e, 0x6f, 0x5f, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, + 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x42, 0x1a, 0x9a, 0x4a, 0x17, + 0x12, 0x15, 0x6e, 0x6f, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x6c, 0x2e, 0x6e, + 0x6f, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x6e, 0x6f, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x27, 0x9a, 0x4a, 0x24, 0x0a, 0x22, 0x0a, 0x0c, 0x6e, 0x6f, 0x5f, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x5f, 0x73, 0x65, 0x6c, 0x6a, 0x12, 0x0a, 0x10, 0x4e, 0x6f, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x80, 0x03, 0x0a, 0x0d, 0x55, 0x73, + 0x65, 0x72, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x77, 0x0a, 0x06, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x72, + 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x55, 0x73, 0x65, + 0x72, 0x42, 0x48, 0x9a, 0x4a, 0x45, 0x22, 0x43, 0x1a, 0x36, 0x0a, 0x02, 0x75, 0x61, 0x6a, 0x30, + 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, + 0x64, 0x12, 0x03, 0x27, 0x61, 0x27, 0x12, 0x08, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x12, 0x01, 0x30, + 0x12, 0x0e, 0x0a, 0x03, 0x62, 0x61, 0x72, 0x12, 0x07, 0x27, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x27, + 0x22, 0x02, 0x75, 0x61, 0x0a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x48, 0x00, 0x52, 0x05, 0x75, + 0x73, 0x65, 0x72, 0x41, 0x12, 0x76, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x62, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x42, 0x47, 0x9a, 0x4a, 0x44, 0x22, + 0x42, 0x1a, 0x36, 0x0a, 0x02, 0x75, 0x62, 0x6a, 0x30, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, + 0x0e, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x03, 0x27, 0x62, 0x27, 0x12, + 0x08, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x12, 0x01, 0x30, 0x12, 0x0e, 0x0a, 0x03, 0x62, 0x61, 0x72, + 0x12, 0x07, 0x27, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x27, 0x22, 0x02, 0x75, 0x62, 0x0a, 0x04, 0x74, + 0x72, 0x75, 0x65, 0x48, 0x00, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x42, 0x12, 0x76, 0x0a, 0x06, + 0x75, 0x73, 0x65, 0x72, 0x5f, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x55, 0x73, - 0x65, 0x72, 0x42, 0x48, 0x9a, 0x4a, 0x45, 0x22, 0x43, 0x1a, 0x36, 0x0a, 0x02, 0x75, 0x61, 0x6a, - 0x30, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x69, 0x64, 0x12, 0x03, 0x27, 0x61, 0x27, 0x12, 0x08, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x12, 0x01, - 0x30, 0x12, 0x0e, 0x0a, 0x03, 0x62, 0x61, 0x72, 0x12, 0x07, 0x27, 0x68, 0x65, 0x6c, 0x6c, 0x6f, - 0x27, 0x22, 0x02, 0x75, 0x61, 0x0a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x48, 0x00, 0x52, 0x05, - 0x75, 0x73, 0x65, 0x72, 0x41, 0x12, 0x76, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x62, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x42, 0x47, 0x9a, 0x4a, 0x44, - 0x22, 0x42, 0x1a, 0x36, 0x0a, 0x02, 0x75, 0x62, 0x6a, 0x30, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, - 0x12, 0x0e, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x03, 0x27, 0x62, 0x27, - 0x12, 0x08, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x12, 0x01, 0x30, 0x12, 0x0e, 0x0a, 0x03, 0x62, 0x61, - 0x72, 0x12, 0x07, 0x27, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x27, 0x22, 0x02, 0x75, 0x62, 0x0a, 0x04, - 0x74, 0x72, 0x75, 0x65, 0x48, 0x00, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x42, 0x12, 0x76, 0x0a, - 0x06, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, - 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x42, 0x47, 0x9a, 0x4a, 0x44, 0x22, 0x42, 0x1a, 0x3a, 0x0a, 0x02, 0x75, 0x63, - 0x6a, 0x34, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x12, 0x07, 0x24, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x08, 0x0a, 0x03, - 0x66, 0x6f, 0x6f, 0x12, 0x01, 0x30, 0x12, 0x0e, 0x0a, 0x03, 0x62, 0x61, 0x72, 0x12, 0x07, 0x27, - 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x27, 0x22, 0x02, 0x75, 0x63, 0x10, 0x01, 0x48, 0x00, 0x52, 0x05, - 0x75, 0x73, 0x65, 0x72, 0x43, 0x42, 0x06, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x9b, 0x01, - 0x0a, 0x10, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x05, 0x6d, 0x73, 0x67, 0x5f, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x13, 0x9a, 0x4a, 0x10, 0x22, 0x0e, 0x22, 0x05, 0x27, 0x61, 0x61, 0x61, 0x27, 0x0a, - 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x48, 0x00, 0x52, 0x04, 0x6d, 0x73, 0x67, 0x41, 0x12, 0x29, - 0x0a, 0x05, 0x6d, 0x73, 0x67, 0x5f, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x12, 0x9a, - 0x4a, 0x0f, 0x22, 0x0d, 0x22, 0x05, 0x27, 0x62, 0x62, 0x62, 0x27, 0x0a, 0x04, 0x74, 0x72, 0x75, - 0x65, 0x48, 0x00, 0x52, 0x04, 0x6d, 0x73, 0x67, 0x42, 0x12, 0x25, 0x0a, 0x05, 0x6d, 0x73, 0x67, - 0x5f, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0x9a, 0x4a, 0x0b, 0x22, 0x09, 0x22, - 0x05, 0x27, 0x63, 0x63, 0x63, 0x27, 0x10, 0x01, 0x48, 0x00, 0x52, 0x04, 0x6d, 0x73, 0x67, 0x43, - 0x42, 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x25, 0x0a, 0x01, 0x4d, - 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x0a, 0x9a, 0x4a, 0x07, 0x12, 0x05, 0x27, 0x66, 0x6f, 0x6f, 0x27, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0x9a, 0x4a, 0x0b, 0x12, 0x09, 0x24, 0x2e, - 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x52, 0x02, 0x69, 0x64, 0x3a, 0x67, 0x9a, 0x4a, 0x64, - 0x0a, 0x62, 0x72, 0x60, 0x0a, 0x18, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0f, - 0x0a, 0x02, 0x69, 0x64, 0x12, 0x09, 0x24, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, - 0x18, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x12, 0x05, 0x24, 0x2e, 0x66, 0x6f, 0x6f, 0x1a, 0x0a, 0x24, - 0x2e, 0x66, 0x6f, 0x6f, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x12, 0x19, 0x0a, 0x03, 0x62, 0x61, 0x72, - 0x12, 0x05, 0x24, 0x2e, 0x62, 0x61, 0x72, 0x1a, 0x0b, 0x24, 0x2e, 0x62, 0x61, 0x72, 0x20, 0x21, - 0x3d, 0x20, 0x27, 0x27, 0x32, 0x5a, 0x0a, 0x11, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x40, 0x0a, 0x03, 0x47, 0x65, 0x74, - 0x12, 0x1a, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6f, - 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x47, 0x65, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x1a, 0x03, 0x9a, 0x4a, 0x00, - 0x42, 0xb1, 0x01, 0x9a, 0x4a, 0x11, 0x12, 0x0f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, - 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x6f, 0x72, 0x67, - 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0f, 0x46, 0x65, 0x64, - 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1d, - 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x3b, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, - 0x4f, 0x46, 0x58, 0xaa, 0x02, 0x0e, 0x4f, 0x72, 0x67, 0x2e, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x0e, 0x4f, 0x72, 0x67, 0x5c, 0x46, 0x65, 0x64, 0x65, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x1a, 0x4f, 0x72, 0x67, 0x5c, 0x46, 0x65, 0x64, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x0f, 0x4f, 0x72, 0x67, 0x3a, 0x3a, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x42, 0x47, 0x9a, 0x4a, 0x44, 0x22, 0x42, 0x1a, 0x3a, 0x0a, 0x02, 0x75, 0x63, 0x6a, + 0x34, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x69, 0x64, 0x12, 0x07, 0x24, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x08, 0x0a, 0x03, 0x66, + 0x6f, 0x6f, 0x12, 0x01, 0x30, 0x12, 0x0e, 0x0a, 0x03, 0x62, 0x61, 0x72, 0x12, 0x07, 0x27, 0x68, + 0x65, 0x6c, 0x6c, 0x6f, 0x27, 0x22, 0x02, 0x75, 0x63, 0x10, 0x01, 0x48, 0x00, 0x52, 0x05, 0x75, + 0x73, 0x65, 0x72, 0x43, 0x42, 0x06, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x9b, 0x01, 0x0a, + 0x10, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x2a, 0x0a, 0x05, 0x6d, 0x73, 0x67, 0x5f, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x13, 0x9a, 0x4a, 0x10, 0x22, 0x0e, 0x22, 0x05, 0x27, 0x61, 0x61, 0x61, 0x27, 0x0a, 0x05, + 0x66, 0x61, 0x6c, 0x73, 0x65, 0x48, 0x00, 0x52, 0x04, 0x6d, 0x73, 0x67, 0x41, 0x12, 0x29, 0x0a, + 0x05, 0x6d, 0x73, 0x67, 0x5f, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x12, 0x9a, 0x4a, + 0x0f, 0x22, 0x0d, 0x22, 0x05, 0x27, 0x62, 0x62, 0x62, 0x27, 0x0a, 0x04, 0x74, 0x72, 0x75, 0x65, + 0x48, 0x00, 0x52, 0x04, 0x6d, 0x73, 0x67, 0x42, 0x12, 0x25, 0x0a, 0x05, 0x6d, 0x73, 0x67, 0x5f, + 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0x9a, 0x4a, 0x0b, 0x22, 0x09, 0x22, 0x05, + 0x27, 0x63, 0x63, 0x63, 0x27, 0x10, 0x01, 0x48, 0x00, 0x52, 0x04, 0x6d, 0x73, 0x67, 0x43, 0x42, + 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xa4, 0x01, 0x0a, 0x10, 0x4e, + 0x6f, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x41, 0x0a, 0x03, 0x6d, 0x5f, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6f, + 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x42, + 0x1b, 0x9a, 0x4a, 0x18, 0x22, 0x16, 0x22, 0x0d, 0x4d, 0x7b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x20, 0x27, 0x61, 0x27, 0x7d, 0x0a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x48, 0x00, 0x52, 0x02, + 0x6d, 0x41, 0x12, 0x41, 0x0a, 0x03, 0x6d, 0x5f, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x11, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x4d, 0x42, 0x1b, 0x9a, 0x4a, 0x18, 0x22, 0x16, 0x22, 0x0d, 0x4d, 0x7b, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x20, 0x27, 0x62, 0x27, 0x7d, 0x0a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x48, + 0x00, 0x52, 0x02, 0x6d, 0x42, 0x42, 0x0a, 0x0a, 0x08, 0x6e, 0x6f, 0x5f, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x22, 0x25, 0x0a, 0x01, 0x4d, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0x9a, 0x4a, 0x07, 0x12, 0x05, 0x27, 0x66, 0x6f, 0x6f, + 0x27, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x04, 0x55, 0x73, 0x65, + 0x72, 0x12, 0x1e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0x9a, + 0x4a, 0x0b, 0x12, 0x09, 0x24, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x52, 0x02, 0x69, + 0x64, 0x3a, 0x67, 0x9a, 0x4a, 0x64, 0x0a, 0x62, 0x72, 0x60, 0x0a, 0x18, 0x75, 0x73, 0x65, 0x72, + 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x47, 0x65, 0x74, + 0x55, 0x73, 0x65, 0x72, 0x12, 0x0f, 0x0a, 0x02, 0x69, 0x64, 0x12, 0x09, 0x24, 0x2e, 0x75, 0x73, + 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x12, 0x05, 0x24, 0x2e, + 0x66, 0x6f, 0x6f, 0x1a, 0x0a, 0x24, 0x2e, 0x66, 0x6f, 0x6f, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x12, + 0x19, 0x0a, 0x03, 0x62, 0x61, 0x72, 0x12, 0x05, 0x24, 0x2e, 0x62, 0x61, 0x72, 0x1a, 0x0b, 0x24, + 0x2e, 0x62, 0x61, 0x72, 0x20, 0x21, 0x3d, 0x20, 0x27, 0x27, 0x32, 0xb1, 0x01, 0x0a, 0x11, 0x46, + 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x40, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x1a, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x65, + 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x55, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x21, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x1a, 0x03, 0x9a, 0x4a, 0x00, 0x42, 0xb1, + 0x01, 0x9a, 0x4a, 0x11, 0x12, 0x0f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x66, + 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0f, 0x46, 0x65, 0x64, 0x65, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1d, 0x65, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x3b, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x4f, 0x46, + 0x58, 0xaa, 0x02, 0x0e, 0x4f, 0x72, 0x67, 0x2e, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0xca, 0x02, 0x0e, 0x4f, 0x72, 0x67, 0x5c, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x1a, 0x4f, 0x72, 0x67, 0x5c, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x0f, 0x4f, 0x72, 0x67, 0x3a, 0x3a, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -496,27 +688,35 @@ func file_federation_federation_proto_rawDescGZIP() []byte { return file_federation_federation_proto_rawDescData } -var file_federation_federation_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_federation_federation_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_federation_federation_proto_goTypes = []interface{}{ - (*GetRequest)(nil), // 0: org.federation.GetRequest - (*GetResponse)(nil), // 1: org.federation.GetResponse - (*UserSelection)(nil), // 2: org.federation.UserSelection - (*MessageSelection)(nil), // 3: org.federation.MessageSelection - (*M)(nil), // 4: org.federation.M - (*User)(nil), // 5: org.federation.User + (*GetRequest)(nil), // 0: org.federation.GetRequest + (*GetResponse)(nil), // 1: org.federation.GetResponse + (*GetNoValueRequest)(nil), // 2: org.federation.GetNoValueRequest + (*GetNoValueResponse)(nil), // 3: org.federation.GetNoValueResponse + (*UserSelection)(nil), // 4: org.federation.UserSelection + (*MessageSelection)(nil), // 5: org.federation.MessageSelection + (*NoValueSelection)(nil), // 6: org.federation.NoValueSelection + (*M)(nil), // 7: org.federation.M + (*User)(nil), // 8: org.federation.User } var file_federation_federation_proto_depIdxs = []int32{ - 5, // 0: org.federation.GetResponse.user:type_name -> org.federation.User - 5, // 1: org.federation.UserSelection.user_a:type_name -> org.federation.User - 5, // 2: org.federation.UserSelection.user_b:type_name -> org.federation.User - 5, // 3: org.federation.UserSelection.user_c:type_name -> org.federation.User - 0, // 4: org.federation.FederationService.Get:input_type -> org.federation.GetRequest - 1, // 5: org.federation.FederationService.Get:output_type -> org.federation.GetResponse - 5, // [5:6] is the sub-list for method output_type - 4, // [4:5] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 8, // 0: org.federation.GetResponse.user:type_name -> org.federation.User + 7, // 1: org.federation.GetNoValueResponse.no_value:type_name -> org.federation.M + 8, // 2: org.federation.UserSelection.user_a:type_name -> org.federation.User + 8, // 3: org.federation.UserSelection.user_b:type_name -> org.federation.User + 8, // 4: org.federation.UserSelection.user_c:type_name -> org.federation.User + 7, // 5: org.federation.NoValueSelection.m_a:type_name -> org.federation.M + 7, // 6: org.federation.NoValueSelection.m_b:type_name -> org.federation.M + 0, // 7: org.federation.FederationService.Get:input_type -> org.federation.GetRequest + 2, // 8: org.federation.FederationService.GetNoValue:input_type -> org.federation.GetNoValueRequest + 1, // 9: org.federation.FederationService.Get:output_type -> org.federation.GetResponse + 3, // 10: org.federation.FederationService.GetNoValue:output_type -> org.federation.GetNoValueResponse + 9, // [9:11] is the sub-list for method output_type + 7, // [7:9] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_federation_federation_proto_init() } @@ -550,7 +750,7 @@ func file_federation_federation_proto_init() { } } file_federation_federation_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UserSelection); i { + switch v := v.(*GetNoValueRequest); i { case 0: return &v.state case 1: @@ -562,7 +762,7 @@ func file_federation_federation_proto_init() { } } file_federation_federation_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MessageSelection); i { + switch v := v.(*GetNoValueResponse); i { case 0: return &v.state case 1: @@ -574,7 +774,7 @@ func file_federation_federation_proto_init() { } } file_federation_federation_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*M); i { + switch v := v.(*UserSelection); i { case 0: return &v.state case 1: @@ -586,6 +786,42 @@ func file_federation_federation_proto_init() { } } file_federation_federation_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MessageSelection); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_federation_federation_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NoValueSelection); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_federation_federation_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*M); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_federation_federation_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*User); i { case 0: return &v.state @@ -598,23 +834,27 @@ func file_federation_federation_proto_init() { } } } - file_federation_federation_proto_msgTypes[2].OneofWrappers = []interface{}{ + file_federation_federation_proto_msgTypes[4].OneofWrappers = []interface{}{ (*UserSelection_UserA)(nil), (*UserSelection_UserB)(nil), (*UserSelection_UserC)(nil), } - file_federation_federation_proto_msgTypes[3].OneofWrappers = []interface{}{ + file_federation_federation_proto_msgTypes[5].OneofWrappers = []interface{}{ (*MessageSelection_MsgA)(nil), (*MessageSelection_MsgB)(nil), (*MessageSelection_MsgC)(nil), } + file_federation_federation_proto_msgTypes[6].OneofWrappers = []interface{}{ + (*NoValueSelection_MA)(nil), + (*NoValueSelection_MB)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_federation_federation_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 9, NumExtensions: 0, NumServices: 1, }, diff --git a/_examples/10_oneof/federation/federation_grpc.pb.go b/_examples/10_oneof/federation/federation_grpc.pb.go index 01b0a9e9..e24f84d5 100644 --- a/_examples/10_oneof/federation/federation_grpc.pb.go +++ b/_examples/10_oneof/federation/federation_grpc.pb.go @@ -19,7 +19,8 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - FederationService_Get_FullMethodName = "/org.federation.FederationService/Get" + FederationService_Get_FullMethodName = "/org.federation.FederationService/Get" + FederationService_GetNoValue_FullMethodName = "/org.federation.FederationService/GetNoValue" ) // FederationServiceClient is the client API for FederationService service. @@ -27,6 +28,7 @@ const ( // 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 FederationServiceClient interface { Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) + GetNoValue(ctx context.Context, in *GetNoValueRequest, opts ...grpc.CallOption) (*GetNoValueResponse, error) } type federationServiceClient struct { @@ -46,11 +48,21 @@ func (c *federationServiceClient) Get(ctx context.Context, in *GetRequest, opts return out, nil } +func (c *federationServiceClient) GetNoValue(ctx context.Context, in *GetNoValueRequest, opts ...grpc.CallOption) (*GetNoValueResponse, error) { + out := new(GetNoValueResponse) + err := c.cc.Invoke(ctx, FederationService_GetNoValue_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // FederationServiceServer is the server API for FederationService service. // All implementations must embed UnimplementedFederationServiceServer // for forward compatibility type FederationServiceServer interface { Get(context.Context, *GetRequest) (*GetResponse, error) + GetNoValue(context.Context, *GetNoValueRequest) (*GetNoValueResponse, error) mustEmbedUnimplementedFederationServiceServer() } @@ -61,6 +73,9 @@ type UnimplementedFederationServiceServer struct { func (UnimplementedFederationServiceServer) Get(context.Context, *GetRequest) (*GetResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") } +func (UnimplementedFederationServiceServer) GetNoValue(context.Context, *GetNoValueRequest) (*GetNoValueResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetNoValue not implemented") +} func (UnimplementedFederationServiceServer) mustEmbedUnimplementedFederationServiceServer() {} // UnsafeFederationServiceServer may be embedded to opt out of forward compatibility for this service. @@ -92,6 +107,24 @@ func _FederationService_Get_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _FederationService_GetNoValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetNoValueRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FederationServiceServer).GetNoValue(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FederationService_GetNoValue_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FederationServiceServer).GetNoValue(ctx, req.(*GetNoValueRequest)) + } + return interceptor(ctx, in, info, handler) +} + // FederationService_ServiceDesc is the grpc.ServiceDesc for FederationService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -103,6 +136,10 @@ var FederationService_ServiceDesc = grpc.ServiceDesc{ MethodName: "Get", Handler: _FederationService_Get_Handler, }, + { + MethodName: "GetNoValue", + Handler: _FederationService_GetNoValue_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "federation/federation.proto", diff --git a/_examples/10_oneof/federation/federation_grpc_federation.pb.go b/_examples/10_oneof/federation/federation_grpc_federation.pb.go index de9f3206..4b48e0b2 100644 --- a/_examples/10_oneof/federation/federation_grpc_federation.pb.go +++ b/_examples/10_oneof/federation/federation_grpc_federation.pb.go @@ -24,6 +24,11 @@ var ( _ = reflect.Invalid // to avoid "imported and not used error" ) +// Org_Federation_GetNoValueResponseArgument is argument for "org.federation.GetNoValueResponse" message. +type FederationService_Org_Federation_GetNoValueResponseArgument struct { + NoValueSel *NoValueSelection +} + // Org_Federation_GetResponseArgument is argument for "org.federation.GetResponse" message. type FederationService_Org_Federation_GetResponseArgument struct { MsgSel *MessageSelection @@ -34,6 +39,10 @@ type FederationService_Org_Federation_GetResponseArgument struct { type FederationService_Org_Federation_MessageSelectionArgument struct { } +// Org_Federation_NoValueSelectionArgument is argument for "org.federation.NoValueSelection" message. +type FederationService_Org_Federation_NoValueSelectionArgument struct { +} + // Org_Federation_UserArgument is argument for "org.federation.User" message. type FederationService_Org_Federation_UserArgument struct { Bar string @@ -135,8 +144,10 @@ func NewFederationService(cfg FederationServiceConfig) (*FederationService, erro errorHandler = func(ctx context.Context, methodName string, err error) error { return err } } celTypeHelperFieldMap := grpcfed.CELTypeHelperFieldMap{ - "grpc.federation.private.GetResponseArgument": {}, - "grpc.federation.private.MessageSelectionArgument": {}, + "grpc.federation.private.GetNoValueResponseArgument": {}, + "grpc.federation.private.GetResponseArgument": {}, + "grpc.federation.private.MessageSelectionArgument": {}, + "grpc.federation.private.NoValueSelectionArgument": {}, "grpc.federation.private.UserArgument": { "user_id": grpcfed.NewCELFieldType(grpcfed.CELStringType, "UserId"), "foo": grpcfed.NewCELFieldType(grpcfed.CELIntType, "Foo"), @@ -153,6 +164,14 @@ func NewFederationService(cfg FederationServiceConfig) (*FederationService, erro reflect.Zero(reflect.TypeOf("")), ), }, + "org.federation.NoValueSelection": { + "no_value": grpcfed.NewOneofSelectorFieldType( + grpcfed.NewCELObjectType("org.federation.M"), "NoValue", + []reflect.Type{reflect.TypeOf((*NoValueSelection_MA)(nil)), reflect.TypeOf((*NoValueSelection_MB)(nil))}, + []string{"GetMA", "GetMB"}, + reflect.Zero(reflect.TypeOf((*M)(nil))), + ), + }, "org.federation.UserSelection": { "user": grpcfed.NewOneofSelectorFieldType( grpcfed.NewCELObjectType("org.federation.User"), "User", @@ -200,6 +219,96 @@ func (s *FederationService) Get(ctx context.Context, req *GetRequest) (res *GetR return res, nil } +// GetNoValue implements "org.federation.FederationService/GetNoValue" method. +func (s *FederationService) GetNoValue(ctx context.Context, req *GetNoValueRequest) (res *GetNoValueResponse, e error) { + ctx, span := s.tracer.Start(ctx, "org.federation.FederationService/GetNoValue") + defer span.End() + ctx = grpcfed.WithLogger(ctx, s.logger) + ctx = grpcfed.WithCELCacheMap(ctx, s.celCacheMap) + defer func() { + if r := recover(); r != nil { + e = grpcfed.RecoverError(r, grpcfed.StackTrace()) + grpcfed.OutputErrorLog(ctx, e) + } + }() + res, err := s.resolve_Org_Federation_GetNoValueResponse(ctx, &FederationService_Org_Federation_GetNoValueResponseArgument{}) + if err != nil { + grpcfed.RecordErrorToSpan(ctx, err) + grpcfed.OutputErrorLog(ctx, err) + return nil, err + } + return res, nil +} + +// resolve_Org_Federation_GetNoValueResponse resolve "org.federation.GetNoValueResponse" message. +func (s *FederationService) resolve_Org_Federation_GetNoValueResponse(ctx context.Context, req *FederationService_Org_Federation_GetNoValueResponseArgument) (*GetNoValueResponse, error) { + ctx, span := s.tracer.Start(ctx, "org.federation.GetNoValueResponse") + defer span.End() + ctx = grpcfed.WithLogger(ctx, grpcfed.Logger(ctx), grpcfed.LogAttrs(ctx)...) + + grpcfed.Logger(ctx).DebugContext(ctx, "resolve org.federation.GetNoValueResponse", slog.Any("message_args", s.logvalue_Org_Federation_GetNoValueResponseArgument(req))) + type localValueType struct { + *grpcfed.LocalValue + vars struct { + no_value_sel *NoValueSelection + } + } + value := &localValueType{LocalValue: grpcfed.NewLocalValue(ctx, s.celEnvOpts, "grpc.federation.private.GetNoValueResponseArgument", req)} + + // This section's codes are generated by the following proto definition. + /* + def { + name: "no_value_sel" + message { + name: "NoValueSelection" + } + } + */ + if err := grpcfed.EvalDef(ctx, value, grpcfed.Def[*NoValueSelection, *localValueType]{ + Name: `no_value_sel`, + Type: grpcfed.CELObjectType("org.federation.NoValueSelection"), + Setter: func(value *localValueType, v *NoValueSelection) error { + value.vars.no_value_sel = v + return nil + }, + Message: func(ctx context.Context, value *localValueType) (any, error) { + args := &FederationService_Org_Federation_NoValueSelectionArgument{} + ret, err := s.resolve_Org_Federation_NoValueSelection(ctx, args) + if err != nil { + return nil, err + } + return ret, nil + }, + }); err != nil { + grpcfed.RecordErrorToSpan(ctx, err) + return nil, err + } + + // assign named parameters to message arguments to pass to the custom resolver. + req.NoValueSel = value.vars.no_value_sel + + // create a message value to be returned. + ret := &GetNoValueResponse{} + + // field binding section. + // (grpc.federation.field).by = "no_value_sel.no_value" + if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[*M]{ + Value: value, + Expr: `no_value_sel.no_value`, + CacheIndex: 1, + Setter: func(v *M) error { + ret.NoValue = v + return nil + }, + }); err != nil { + grpcfed.RecordErrorToSpan(ctx, err) + return nil, err + } + + grpcfed.Logger(ctx).DebugContext(ctx, "resolved org.federation.GetNoValueResponse", slog.Any("org.federation.GetNoValueResponse", s.logvalue_Org_Federation_GetNoValueResponse(ret))) + return ret, nil +} + // resolve_Org_Federation_GetResponse resolve "org.federation.GetResponse" message. func (s *FederationService) resolve_Org_Federation_GetResponse(ctx context.Context, req *FederationService_Org_Federation_GetResponseArgument) (*GetResponse, error) { ctx, span := s.tracer.Start(ctx, "org.federation.GetResponse") @@ -280,7 +389,7 @@ func (s *FederationService) resolve_Org_Federation_GetResponse(ctx context.Conte if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `'foo'`, - CacheIndex: 1, + CacheIndex: 2, Setter: func(v string) error { args.Value = v return nil @@ -317,7 +426,7 @@ func (s *FederationService) resolve_Org_Federation_GetResponse(ctx context.Conte if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[*User]{ Value: value, Expr: `sel.user`, - CacheIndex: 2, + CacheIndex: 3, Setter: func(v *User) error { ret.User = v return nil @@ -330,7 +439,7 @@ func (s *FederationService) resolve_Org_Federation_GetResponse(ctx context.Conte if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `msg_sel.message`, - CacheIndex: 3, + CacheIndex: 4, Setter: func(v string) error { ret.Msg = v return nil @@ -366,7 +475,7 @@ func (s *FederationService) resolve_Org_Federation_MessageSelection(ctx context. Value: value, Expr: `false`, OutType: reflect.TypeOf(true), - CacheIndex: 4, + CacheIndex: 5, }) if err != nil { grpcfed.RecordErrorToSpan(ctx, err) @@ -376,7 +485,7 @@ func (s *FederationService) resolve_Org_Federation_MessageSelection(ctx context. Value: value, Expr: `true`, OutType: reflect.TypeOf(true), - CacheIndex: 5, + CacheIndex: 6, }) if err != nil { grpcfed.RecordErrorToSpan(ctx, err) @@ -388,7 +497,7 @@ func (s *FederationService) resolve_Org_Federation_MessageSelection(ctx context. if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `'aaa'`, - CacheIndex: 6, + CacheIndex: 7, Setter: func(v string) error { ret.Message = &MessageSelection_MsgA{MsgA: v} return nil @@ -402,7 +511,7 @@ func (s *FederationService) resolve_Org_Federation_MessageSelection(ctx context. if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `'bbb'`, - CacheIndex: 7, + CacheIndex: 8, Setter: func(v string) error { ret.Message = &MessageSelection_MsgB{MsgB: v} return nil @@ -416,7 +525,7 @@ func (s *FederationService) resolve_Org_Federation_MessageSelection(ctx context. if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `'ccc'`, - CacheIndex: 8, + CacheIndex: 9, Setter: func(v string) error { ret.Message = &MessageSelection_MsgC{MsgC: v} return nil @@ -431,6 +540,79 @@ func (s *FederationService) resolve_Org_Federation_MessageSelection(ctx context. return ret, nil } +// resolve_Org_Federation_NoValueSelection resolve "org.federation.NoValueSelection" message. +func (s *FederationService) resolve_Org_Federation_NoValueSelection(ctx context.Context, req *FederationService_Org_Federation_NoValueSelectionArgument) (*NoValueSelection, error) { + ctx, span := s.tracer.Start(ctx, "org.federation.NoValueSelection") + defer span.End() + ctx = grpcfed.WithLogger(ctx, grpcfed.Logger(ctx), grpcfed.LogAttrs(ctx)...) + + grpcfed.Logger(ctx).DebugContext(ctx, "resolve org.federation.NoValueSelection", slog.Any("message_args", s.logvalue_Org_Federation_NoValueSelectionArgument(req))) + type localValueType struct { + *grpcfed.LocalValue + vars struct { + } + } + value := &localValueType{LocalValue: grpcfed.NewLocalValue(ctx, s.celEnvOpts, "grpc.federation.private.NoValueSelectionArgument", req)} + + // create a message value to be returned. + ret := &NoValueSelection{} + + // field binding section. + oneof_MA, err := grpcfed.EvalCEL(ctx, &grpcfed.EvalCELRequest{ + Value: value, + Expr: `false`, + OutType: reflect.TypeOf(true), + CacheIndex: 10, + }) + if err != nil { + grpcfed.RecordErrorToSpan(ctx, err) + return nil, err + } + oneof_MB, err := grpcfed.EvalCEL(ctx, &grpcfed.EvalCELRequest{ + Value: value, + Expr: `false`, + OutType: reflect.TypeOf(true), + CacheIndex: 11, + }) + if err != nil { + grpcfed.RecordErrorToSpan(ctx, err) + return nil, err + } + switch { + case oneof_MA.(bool): + + if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[*M]{ + Value: value, + Expr: `M{value: 'a'}`, + CacheIndex: 12, + Setter: func(v *M) error { + ret.NoValue = &NoValueSelection_MA{MA: v} + return nil + }, + }); err != nil { + grpcfed.RecordErrorToSpan(ctx, err) + return nil, err + } + case oneof_MB.(bool): + + if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[*M]{ + Value: value, + Expr: `M{value: 'b'}`, + CacheIndex: 13, + Setter: func(v *M) error { + ret.NoValue = &NoValueSelection_MB{MB: v} + return nil + }, + }); err != nil { + grpcfed.RecordErrorToSpan(ctx, err) + return nil, err + } + } + + grpcfed.Logger(ctx).DebugContext(ctx, "resolved org.federation.NoValueSelection", slog.Any("org.federation.NoValueSelection", s.logvalue_Org_Federation_NoValueSelection(ret))) + return ret, nil +} + // resolve_Org_Federation_User resolve "org.federation.User" message. func (s *FederationService) resolve_Org_Federation_User(ctx context.Context, req *FederationService_Org_Federation_UserArgument) (*User, error) { ctx, span := s.tracer.Start(ctx, "org.federation.User") @@ -473,7 +655,7 @@ func (s *FederationService) resolve_Org_Federation_User(ctx context.Context, req if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `$.user_id`, - CacheIndex: 9, + CacheIndex: 14, Setter: func(v string) error { args.Id = v return nil @@ -485,12 +667,12 @@ func (s *FederationService) resolve_Org_Federation_User(ctx context.Context, req if err := grpcfed.If(ctx, &grpcfed.IfParam[*localValueType]{ Value: value, Expr: `$.foo != 0`, - CacheIndex: 10, + CacheIndex: 15, Body: func(value *localValueType) error { return grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[int64]{ Value: value, Expr: `$.foo`, - CacheIndex: 11, + CacheIndex: 16, Setter: func(v int64) error { args.Foobar = &user.GetUserRequest_Foo{ Foo: v, @@ -506,12 +688,12 @@ func (s *FederationService) resolve_Org_Federation_User(ctx context.Context, req if err := grpcfed.If(ctx, &grpcfed.IfParam[*localValueType]{ Value: value, Expr: `$.bar != ''`, - CacheIndex: 12, + CacheIndex: 17, Body: func(value *localValueType) error { return grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `$.bar`, - CacheIndex: 13, + CacheIndex: 18, Setter: func(v string) error { args.Foobar = &user.GetUserRequest_Bar{ Bar: v, @@ -545,7 +727,7 @@ func (s *FederationService) resolve_Org_Federation_User(ctx context.Context, req if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `$.user_id`, - CacheIndex: 14, + CacheIndex: 19, Setter: func(v string) error { ret.Id = v return nil @@ -589,7 +771,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con Value: value, Expr: `false`, OutType: reflect.TypeOf(true), - CacheIndex: 15, + CacheIndex: 20, }) if err != nil { grpcfed.RecordErrorToSpan(ctx, err) @@ -599,7 +781,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con Value: value, Expr: `true`, OutType: reflect.TypeOf(true), - CacheIndex: 16, + CacheIndex: 21, }) if err != nil { grpcfed.RecordErrorToSpan(ctx, err) @@ -635,7 +817,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `'a'`, - CacheIndex: 17, + CacheIndex: 22, Setter: func(v string) error { args.UserId = v return nil @@ -647,7 +829,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[int64]{ Value: value, Expr: `0`, - CacheIndex: 18, + CacheIndex: 23, Setter: func(v int64) error { args.Foo = v return nil @@ -659,7 +841,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `'hello'`, - CacheIndex: 19, + CacheIndex: 24, Setter: func(v string) error { args.Bar = v return nil @@ -680,7 +862,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[*User]{ Value: value, Expr: `ua`, - CacheIndex: 20, + CacheIndex: 25, Setter: func(v *User) error { ret.User = &UserSelection_UserA{UserA: v} return nil @@ -718,7 +900,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `'b'`, - CacheIndex: 21, + CacheIndex: 26, Setter: func(v string) error { args.UserId = v return nil @@ -730,7 +912,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[int64]{ Value: value, Expr: `0`, - CacheIndex: 22, + CacheIndex: 27, Setter: func(v int64) error { args.Foo = v return nil @@ -742,7 +924,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `'hello'`, - CacheIndex: 23, + CacheIndex: 28, Setter: func(v string) error { args.Bar = v return nil @@ -763,7 +945,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[*User]{ Value: value, Expr: `ub`, - CacheIndex: 24, + CacheIndex: 29, Setter: func(v *User) error { ret.User = &UserSelection_UserB{UserB: v} return nil @@ -801,7 +983,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `$.value`, - CacheIndex: 25, + CacheIndex: 30, Setter: func(v string) error { args.UserId = v return nil @@ -813,7 +995,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[int64]{ Value: value, Expr: `0`, - CacheIndex: 26, + CacheIndex: 31, Setter: func(v int64) error { args.Foo = v return nil @@ -825,7 +1007,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[string]{ Value: value, Expr: `'hello'`, - CacheIndex: 27, + CacheIndex: 32, Setter: func(v string) error { args.Bar = v return nil @@ -846,7 +1028,7 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con if err := grpcfed.SetCELValue(ctx, &grpcfed.SetCELValueParam[*User]{ Value: value, Expr: `uc`, - CacheIndex: 28, + CacheIndex: 33, Setter: func(v *User) error { ret.User = &UserSelection_UserC{UserC: v} return nil @@ -861,6 +1043,22 @@ func (s *FederationService) resolve_Org_Federation_UserSelection(ctx context.Con return ret, nil } +func (s *FederationService) logvalue_Org_Federation_GetNoValueResponse(v *GetNoValueResponse) slog.Value { + if v == nil { + return slog.GroupValue() + } + return slog.GroupValue( + slog.Any("no_value", s.logvalue_Org_Federation_M(v.GetNoValue())), + ) +} + +func (s *FederationService) logvalue_Org_Federation_GetNoValueResponseArgument(v *FederationService_Org_Federation_GetNoValueResponseArgument) slog.Value { + if v == nil { + return slog.GroupValue() + } + return slog.GroupValue() +} + func (s *FederationService) logvalue_Org_Federation_GetResponse(v *GetResponse) slog.Value { if v == nil { return slog.GroupValue() @@ -878,6 +1076,15 @@ func (s *FederationService) logvalue_Org_Federation_GetResponseArgument(v *Feder return slog.GroupValue() } +func (s *FederationService) logvalue_Org_Federation_M(v *M) slog.Value { + if v == nil { + return slog.GroupValue() + } + return slog.GroupValue( + slog.String("value", v.GetValue()), + ) +} + func (s *FederationService) logvalue_Org_Federation_MessageSelection(v *MessageSelection) slog.Value { if v == nil { return slog.GroupValue() @@ -896,6 +1103,23 @@ func (s *FederationService) logvalue_Org_Federation_MessageSelectionArgument(v * return slog.GroupValue() } +func (s *FederationService) logvalue_Org_Federation_NoValueSelection(v *NoValueSelection) slog.Value { + if v == nil { + return slog.GroupValue() + } + return slog.GroupValue( + slog.Any("m_a", s.logvalue_Org_Federation_M(v.GetMA())), + slog.Any("m_b", s.logvalue_Org_Federation_M(v.GetMB())), + ) +} + +func (s *FederationService) logvalue_Org_Federation_NoValueSelectionArgument(v *FederationService_Org_Federation_NoValueSelectionArgument) slog.Value { + if v == nil { + return slog.GroupValue() + } + return slog.GroupValue() +} + func (s *FederationService) logvalue_Org_Federation_User(v *User) slog.Value { if v == nil { return slog.GroupValue() diff --git a/_examples/10_oneof/main_test.go b/_examples/10_oneof/main_test.go index 8b1a6d04..ddf93699 100644 --- a/_examples/10_oneof/main_test.go +++ b/_examples/10_oneof/main_test.go @@ -17,6 +17,8 @@ import ( sdktrace "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.4.0" "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "google.golang.org/grpc/test/bufconn" "example/federation" @@ -124,3 +126,69 @@ func TestFederation(t *testing.T) { t.Errorf("(-got, +want)\n%s", diff) } } + +func TestFederation_NoValue(t *testing.T) { + ctx := context.Background() + listener = bufconn.Listen(bufSize) + + if os.Getenv("ENABLE_JAEGER") != "" { + exporter, err := otlptracegrpc.New(ctx, otlptracegrpc.WithInsecure()) + if err != nil { + t.Fatal(err) + } + tp := sdktrace.NewTracerProvider( + sdktrace.WithBatcher(exporter), + sdktrace.WithResource( + resource.NewWithAttributes( + semconv.SchemaURL, + semconv.ServiceNameKey.String("example10/oneof"), + semconv.ServiceVersionKey.String("1.0.0"), + attribute.String("environment", "dev"), + ), + ), + sdktrace.WithSampler(sdktrace.AlwaysSample()), + ) + defer tp.Shutdown(ctx) + otel.SetTextMapPropagator(propagation.TraceContext{}) + otel.SetTracerProvider(tp) + } + + conn, err := grpc.DialContext(ctx, "", grpc.WithContextDialer(dialer), grpc.WithInsecure()) + if err != nil { + t.Fatal(err) + } + defer conn.Close() + + userClient = user.NewUserServiceClient(conn) + + grpcServer := grpc.NewServer() + + logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{ + Level: slog.LevelDebug, + })) + federationServer, err := federation.NewFederationService(federation.FederationServiceConfig{ + Client: new(clientConfig), + Logger: logger, + }) + if err != nil { + t.Fatal(err) + } + user.RegisterUserServiceServer(grpcServer, &UserServer{}) + federation.RegisterFederationServiceServer(grpcServer, federationServer) + + go func() { + if err := grpcServer.Serve(listener); err != nil { + t.Fatal(err) + } + }() + + client := federation.NewFederationServiceClient(conn) + _, err = client.GetNoValue(ctx, &federation.GetNoValueRequest{}) + if err == nil { + t.Fatal("unexpected error nil") + } + expectedErr := status.New(codes.Unknown, "NoValue is invalid field") + if diff := cmp.Diff(err.Error(), expectedErr.Err().Error()); diff != "" { + t.Errorf("(-got, +want)\n%s", diff) + } +} diff --git a/_examples/10_oneof/proto/federation/federation.proto b/_examples/10_oneof/proto/federation/federation.proto index 241811cb..ac2b8a7e 100644 --- a/_examples/10_oneof/proto/federation/federation.proto +++ b/_examples/10_oneof/proto/federation/federation.proto @@ -13,6 +13,7 @@ option (grpc.federation.file)= { service FederationService { option (grpc.federation.service) = {}; rpc Get(GetRequest) returns (GetResponse) {}; + rpc GetNoValue(GetNoValueRequest) returns (GetNoValueResponse) {}; } message GetRequest {} @@ -32,6 +33,15 @@ message GetResponse { string msg = 2 [(grpc.federation.field).by = "msg_sel.message"]; } +message GetNoValueRequest {} + +message GetNoValueResponse { + option (grpc.federation.message) = { + def { name: "no_value_sel" message { name: "NoValueSelection" } } + }; + M no_value = 1 [(grpc.federation.field).by = "no_value_sel.no_value"]; +} + message UserSelection { oneof user { User user_a = 1 [ @@ -113,6 +123,23 @@ message MessageSelection { } } +message NoValueSelection { + oneof no_value { + M m_a = 1 [ + (grpc.federation.field).oneof = { + if: "false" + by: "M{value: 'a'}" + } + ]; + M m_b = 2 [ + (grpc.federation.field).oneof = { + if: "false" + by: "M{value: 'b'}" + } + ]; + } +} + message M { string value = 1 [(grpc.federation.field).by = "'foo'"]; } diff --git a/grpc/federation/cel.go b/grpc/federation/cel.go index 8dc6ca18..34c463ec 100644 --- a/grpc/federation/cel.go +++ b/grpc/federation/cel.go @@ -11,9 +11,13 @@ import ( "sync" "github.com/google/cel-go/cel" + celast "github.com/google/cel-go/common/ast" + "github.com/google/cel-go/common/operators" celtypes "github.com/google/cel-go/common/types" "github.com/google/cel-go/common/types/ref" + "github.com/google/cel-go/parser" "golang.org/x/sync/singleflight" + exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" "google.golang.org/genproto/googleapis/rpc/errdetails" grpccodes "google.golang.org/grpc/codes" grpcstatus "google.golang.org/grpc/status" @@ -158,6 +162,10 @@ func NewOneofSelectorFieldType(typ *celtypes.Type, fieldName string, oneofTypes } field := rv.FieldByName(fieldName) fieldImpl := reflect.ValueOf(field.Interface()) + if !fieldImpl.IsValid() { + // prevent panic if no value assigned + return nil, fmt.Errorf("%s is invalid field", fieldName) + } for idx, oneofType := range oneofTypes { if fieldImpl.Type() != oneofType { continue @@ -731,6 +739,25 @@ func createCELAst(req *EvalCELRequest, env *cel.Env) (*cel.Ast, error) { if iss.Err() != nil { return nil, iss.Err() } + + checkedExpr, err := cel.AstToCheckedExpr(ast) + if err != nil { + return nil, err + } + if newComparingNullResolver().Resolve(checkedExpr) { + ca, err := celast.ToAST(checkedExpr) + if err != nil { + return nil, err + } + expr, err = parser.Unparse(ca.Expr(), ca.SourceInfo()) + if err != nil { + return nil, err + } + ast, iss = env.Compile(expr) + if iss.Err() != nil { + return nil, iss.Err() + } + } return ast, nil } @@ -832,3 +859,173 @@ func SetCELValue[T any](ctx context.Context, param *SetCELValueParam[T]) error { } return nil } + +// comparingNullResolver is a feature that allows to compare typed null and null value correctly. +// It parses the expression and wraps the message with grpc.federation.cast.null_value if the message is compared to null. +type comparingNullResolver struct { + checkedExpr *exprpb.CheckedExpr + lastID int64 + resolved bool +} + +func newComparingNullResolver() *comparingNullResolver { + return &comparingNullResolver{} +} + +func (r *comparingNullResolver) init(checkedExpr *exprpb.CheckedExpr) { + var lastID int64 + for k := range checkedExpr.GetReferenceMap() { + if lastID < k { + lastID = k + } + } + for k := range checkedExpr.GetTypeMap() { + if lastID < k { + lastID = k + } + } + r.checkedExpr = checkedExpr + r.lastID = lastID + r.resolved = false +} + +func (r *comparingNullResolver) nextID() int64 { + r.lastID++ + return r.lastID +} + +func (r *comparingNullResolver) Resolve(checkedExpr *exprpb.CheckedExpr) bool { + r.init(checkedExpr) + newExprVisitor().Visit(checkedExpr.GetExpr(), func(e *exprpb.Expr) { + switch e.GetExprKind().(type) { + case *exprpb.Expr_CallExpr: + r.resolveCallExpr(e) + } + }) + return r.resolved +} + +func (r *comparingNullResolver) resolveCallExpr(e *exprpb.Expr) { + target := r.lookupComparingNullCallExpr(e) + if target == nil { + return + } + newID := r.nextID() + newExprKind := &exprpb.Expr_CallExpr{ + CallExpr: &exprpb.Expr_Call{ + Function: grpcfedcel.CastNullValueFunc, + Args: []*exprpb.Expr{ + { + Id: target.GetId(), + ExprKind: target.GetExprKind(), + }, + }, + }, + } + target.Id = newID + target.ExprKind = newExprKind + r.checkedExpr.GetReferenceMap()[newID] = &exprpb.Reference{ + OverloadId: []string{grpcfedcel.CastNullValueFunc}, + } + r.checkedExpr.GetTypeMap()[newID] = &exprpb.Type{ + TypeKind: &exprpb.Type_Dyn{}, + } + r.resolved = true +} + +func (r *comparingNullResolver) lookupComparingNullCallExpr(e *exprpb.Expr) *exprpb.Expr { + call := e.GetCallExpr() + fnName := call.GetFunction() + if fnName == operators.Equals || fnName == operators.NotEquals { + lhs := call.GetArgs()[0] + rhs := call.GetArgs()[1] + var target *exprpb.Expr + if _, ok := lhs.GetConstExpr().GetConstantKind().(*exprpb.Constant_NullValue); ok { + target = rhs + } + if _, ok := rhs.GetConstExpr().GetConstantKind().(*exprpb.Constant_NullValue); ok { + if target != nil { + // maybe null == null + return nil + } + target = lhs + } + if target == nil { + return nil + } + if target.GetCallExpr() != nil && target.GetCallExpr().GetFunction() == grpcfedcel.CastNullValueFunc { + return nil + } + return target + } + return nil +} + +type exprVisitor struct { + callback func(e *exprpb.Expr) +} + +func newExprVisitor() *exprVisitor { + return &exprVisitor{} +} + +func (v *exprVisitor) Visit(e *exprpb.Expr, cb func(e *exprpb.Expr)) { + v.callback = cb + v.visit(e) +} + +func (v *exprVisitor) visit(e *exprpb.Expr) { + if e == nil { + return + } + v.callback(e) + + switch e.GetExprKind().(type) { + case *exprpb.Expr_SelectExpr: + v.visitSelect(e) + case *exprpb.Expr_CallExpr: + v.visitCall(e) + case *exprpb.Expr_ListExpr: + v.visitList(e) + case *exprpb.Expr_StructExpr: + v.visitStruct(e) + case *exprpb.Expr_ComprehensionExpr: + v.visitComprehension(e) + } +} + +func (v *exprVisitor) visitSelect(e *exprpb.Expr) { + sel := e.GetSelectExpr() + v.visit(sel.GetOperand()) +} + +func (v *exprVisitor) visitCall(e *exprpb.Expr) { + call := e.GetCallExpr() + for _, arg := range call.GetArgs() { + v.visit(arg) + } + v.visit(call.GetTarget()) +} + +func (v *exprVisitor) visitList(e *exprpb.Expr) { + l := e.GetListExpr() + for _, elem := range l.GetElements() { + v.visit(elem) + } +} + +func (v *exprVisitor) visitStruct(e *exprpb.Expr) { + msg := e.GetStructExpr() + for _, ent := range msg.GetEntries() { + v.visit(ent.GetValue()) + } +} + +func (v *exprVisitor) visitComprehension(e *exprpb.Expr) { + comp := e.GetComprehensionExpr() + v.visit(comp.GetIterRange()) + v.visit(comp.GetAccuInit()) + v.visit(comp.GetLoopCondition()) + v.visit(comp.GetLoopStep()) + v.visit(comp.GetResult()) +} diff --git a/grpc/federation/cel/bind.go b/grpc/federation/cel/bind.go index 12e65d7a..030d404d 100644 --- a/grpc/federation/cel/bind.go +++ b/grpc/federation/cel/bind.go @@ -31,7 +31,12 @@ func BindFunction(name string, opts ...BindFunctionOpt) []cel.EnvOption { if sel != "" { fqdn = sel + "." + funcName } - argsWithCtx := append([]ast.Expr{mef.NewIdent(ContextVariableName)}, args...) + var argsWithCtx []ast.Expr + if len(args) > 0 && args[0].AsIdent() == ContextVariableName { + argsWithCtx = args + } else { + argsWithCtx = append([]ast.Expr{mef.NewIdent(ContextVariableName)}, args...) + } return mef.NewCall(fqdn, argsWithCtx...), nil })), cel.Function(name, celOpts...), @@ -45,7 +50,12 @@ func BindMemberFunction(name string, opts ...BindMemberFunctionOpt) []cel.EnvOpt } return []cel.EnvOption{ cel.Macros(cel.ReceiverVarArgMacro(name, func(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *cel.Error) { - argsWithCtx := append([]ast.Expr{mef.NewIdent(ContextVariableName)}, args...) + var argsWithCtx []ast.Expr + if len(args) > 0 && args[0].AsIdent() == ContextVariableName { + argsWithCtx = args + } else { + argsWithCtx = append([]ast.Expr{mef.NewIdent(ContextVariableName)}, args...) + } return mef.NewMemberCall(name, target, argsWithCtx...), nil })), cel.Function(name, celOpts...), diff --git a/grpc/federation/cel/cast.go b/grpc/federation/cel/cast.go new file mode 100644 index 00000000..caef67bc --- /dev/null +++ b/grpc/federation/cel/cast.go @@ -0,0 +1,46 @@ +package cel + +import ( + "reflect" + + "github.com/google/cel-go/cel" + "github.com/google/cel-go/common/types" + "github.com/google/cel-go/common/types/ref" +) + +const CastPackageName = "cast" + +const ( + CastNullValueFunc = "grpc.federation.cast.null_value" +) + +type CastLibrary struct{} + +func (lib *CastLibrary) LibraryName() string { + return CastPackageName +} + +func (lib *CastLibrary) CompileOptions() []cel.EnvOption { + opts := []cel.EnvOption{ + cel.OptionalTypes(), + cel.Function(CastNullValueFunc, + cel.Overload("grpc_federation_cast_null_value", + []*cel.Type{cel.DynType}, cel.DynType, + cel.UnaryBinding(lib.nullValue), + ), + ), + } + return opts +} + +func (lib *CastLibrary) ProgramOptions() []cel.ProgramOption { + return []cel.ProgramOption{} +} + +func (lib *CastLibrary) nullValue(val ref.Val) ref.Val { + rv := reflect.ValueOf(val.Value()) + if val.Value() == nil || val.Equal(types.NullValue) == types.True || rv.Kind() == reflect.Ptr && rv.IsNil() { + return types.NullValue + } + return val +} diff --git a/grpc/federation/cel/cast_test.go b/grpc/federation/cel/cast_test.go new file mode 100644 index 00000000..728cfad0 --- /dev/null +++ b/grpc/federation/cel/cast_test.go @@ -0,0 +1,75 @@ +package cel_test + +import ( + "testing" + + "github.com/google/cel-go/cel" + "github.com/google/cel-go/common/types" + "github.com/google/cel-go/common/types/ref" + + cellib "github.com/mercari/grpc-federation/grpc/federation/cel" + "github.com/mercari/grpc-federation/grpc/federation/cel/testdata/testpb" +) + +func TestCast(t *testing.T) { + tests := []struct { + name string + expr string + msg any + expected ref.Val + }{ + { + name: "cast nil", + expr: "grpc.federation.cast.null_value(msg) == null", + msg: nil, + expected: types.True, + }, + { + name: "cast typed-nil", + expr: "grpc.federation.cast.null_value(msg) == null", + msg: (*testpb.Message)(nil), + expected: types.True, + }, + { + name: "cast struct pointer", + expr: "grpc.federation.cast.null_value(msg) == null", + msg: &testpb.Message{}, + expected: types.False, + }, + { + name: "cast lit", + expr: "grpc.federation.cast.null_value(msg) == null", + msg: 100, + expected: types.False, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + env, err := cel.NewEnv( + cel.Types(&testpb.Message{}), + cel.Lib(new(cellib.CastLibrary)), + cel.Variable("msg", cel.DynType), + ) + if err != nil { + t.Fatal(err) + } + ast, iss := env.Compile(test.expr) + if iss.Err() != nil { + t.Fatal(iss.Err()) + } + program, err := env.Program(ast) + if err != nil { + t.Fatal(err) + } + out, _, err := program.Eval(map[string]any{ + "msg": test.msg, + }) + if err != nil { + t.Fatal(err) + } + if out.Equal(test.expected) == types.False { + t.Fatalf("unexpected value: want %v but got %v", test.expected, out) + } + }) + } +} diff --git a/grpc/federation/cel/lib.go b/grpc/federation/cel/lib.go index 27359fc3..da6d74b2 100644 --- a/grpc/federation/cel/lib.go +++ b/grpc/federation/cel/lib.go @@ -25,6 +25,7 @@ func NewLibrary(typeAdapter types.Adapter) *Library { new(EnumLibrary), mdLib, logLib, + new(CastLibrary), }, } }