From 287e98ad670b29d849576e9f3204a6b42e91ea0c Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 1 Oct 2024 09:38:57 +0300 Subject: [PATCH 1/7] [#120] proto/test: Add protojson compatibility test It is failing, thus is skipped. But implement it now to make it easier to see it failing. Signed-off-by: Evgenii Stratonikov --- util/proto/marshal_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/proto/marshal_test.go b/util/proto/marshal_test.go index 1cd7005..98422fc 100644 --- a/util/proto/marshal_test.go +++ b/util/proto/marshal_test.go @@ -76,6 +76,13 @@ func TestStableMarshalSingle(t *testing.T) { var actual test.Primitives require.NoError(t, protojson.Unmarshal(r, &actual)) + t.Run("protojson compatibility", func(t *testing.T) { + t.Skip() + data, err := protojson.Marshal(&actual) + require.NoError(t, err) + require.JSONEq(t, string(data), string(r)) + }) + var actualFrostfs generated.Primitives require.NoError(t, actualFrostfs.UnmarshalJSON(r)) require.Equal(t, tc.input, &actualFrostfs) -- 2.45.3 From f812b1ae5bd602000da17feeb0f8d5afead4a531 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 1 Oct 2024 13:52:57 +0300 Subject: [PATCH 2/7] [#120] Regenerate proto files Signed-off-by: Evgenii Stratonikov --- accounting/grpc/service_grpc.pb.go | 4 +-- netmap/grpc/service_grpc.pb.go | 8 +++--- object/grpc/service_grpc.pb.go | 44 ++++++++++++++++++------------ 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/accounting/grpc/service_grpc.pb.go b/accounting/grpc/service_grpc.pb.go index 63207fe..87eb56b 100644 --- a/accounting/grpc/service_grpc.pb.go +++ b/accounting/grpc/service_grpc.pb.go @@ -26,7 +26,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 AccountingServiceClient interface { - // Returns the amount of funds in GAS token for the requested NeoFS account. + // Returns the amount of funds in GAS token for the requested FrostFS account. // // Statuses: // - **OK** (0, SECTION_SUCCESS): @@ -56,7 +56,7 @@ func (c *accountingServiceClient) Balance(ctx context.Context, in *BalanceReques // All implementations should embed UnimplementedAccountingServiceServer // for forward compatibility type AccountingServiceServer interface { - // Returns the amount of funds in GAS token for the requested NeoFS account. + // Returns the amount of funds in GAS token for the requested FrostFS account. // // Statuses: // - **OK** (0, SECTION_SUCCESS): diff --git a/netmap/grpc/service_grpc.pb.go b/netmap/grpc/service_grpc.pb.go index 7881cd6..9ad7fef 100644 --- a/netmap/grpc/service_grpc.pb.go +++ b/netmap/grpc/service_grpc.pb.go @@ -40,14 +40,14 @@ type NetmapServiceClient interface { // information about the server has been successfully read; // - Common failures (SECTION_FAILURE_COMMON). LocalNodeInfo(ctx context.Context, in *LocalNodeInfoRequest, opts ...grpc.CallOption) (*LocalNodeInfoResponse, error) - // Read recent information about the NeoFS network. + // Read recent information about the FrostFS network. // // Statuses: // - **OK** (0, SECTION_SUCCESS): // information about the current network state has been successfully read; // - Common failures (SECTION_FAILURE_COMMON). NetworkInfo(ctx context.Context, in *NetworkInfoRequest, opts ...grpc.CallOption) (*NetworkInfoResponse, error) - // Returns network map snapshot of the current NeoFS epoch. + // Returns network map snapshot of the current FrostFS epoch. // // Statuses: // - **OK** (0, SECTION_SUCCESS): @@ -107,14 +107,14 @@ type NetmapServiceServer interface { // information about the server has been successfully read; // - Common failures (SECTION_FAILURE_COMMON). LocalNodeInfo(context.Context, *LocalNodeInfoRequest) (*LocalNodeInfoResponse, error) - // Read recent information about the NeoFS network. + // Read recent information about the FrostFS network. // // Statuses: // - **OK** (0, SECTION_SUCCESS): // information about the current network state has been successfully read; // - Common failures (SECTION_FAILURE_COMMON). NetworkInfo(context.Context, *NetworkInfoRequest) (*NetworkInfoResponse, error) - // Returns network map snapshot of the current NeoFS epoch. + // Returns network map snapshot of the current FrostFS epoch. // // Statuses: // - **OK** (0, SECTION_SUCCESS): diff --git a/object/grpc/service_grpc.pb.go b/object/grpc/service_grpc.pb.go index 687df99..abc1c71 100644 --- a/object/grpc/service_grpc.pb.go +++ b/object/grpc/service_grpc.pb.go @@ -170,7 +170,7 @@ type ObjectServiceClient interface { // provided session token has expired. Head(ctx context.Context, in *HeadRequest, opts ...grpc.CallOption) (*HeadResponse, error) // Search objects in container. Search query allows to match by Object - // Header's filed values. Please see the corresponding NeoFS Technical + // Header's filed values. Please see the corresponding FrostFS Technical // Specification section for more details. // // Extended headers can change `Search` behaviour: @@ -301,16 +301,20 @@ type ObjectServiceClient interface { // provided session token has expired. PutSingle(ctx context.Context, in *PutSingleRequest, opts ...grpc.CallOption) (*PutSingleResponse, error) // Patch the object. Request uses gRPC stream. First message must set - // the address of the object that is going to get patched. If the object's attributes - // are patched, then these attrubutes must be set only within the first stream message. + // the address of the object that is going to get patched. If the object's + // attributes are patched, then these attrubutes must be set only within the + // first stream message. // - // If the patch request is performed by NOT the object's owner but if the actor has the permission - // to perform the patch, then `OwnerID` of the object is changed. In this case the object's owner - // loses the object's ownership after the patch request is successfully done. + // If the patch request is performed by NOT the object's owner but if the + // actor has the permission to perform the patch, then `OwnerID` of the object + // is changed. In this case the object's owner loses the object's ownership + // after the patch request is successfully done. // - // As objects are content-addressable the patching causes new object ID generation for the patched object. - // This object id is set witihn `PatchResponse`. But the object id may remain unchanged in such cases: - // 1. The chunk of the applying patch contains the same value as the object's payload within the same range; + // As objects are content-addressable the patching causes new object ID + // generation for the patched object. This object id is set witihn + // `PatchResponse`. But the object id may remain unchanged in such cases: + // 1. The chunk of the applying patch contains the same value as the object's + // payload within the same range; // 2. The patch that reverts the changes applied by preceding patch; // 3. The application of the same patches for the object a few times. // @@ -694,7 +698,7 @@ type ObjectServiceServer interface { // provided session token has expired. Head(context.Context, *HeadRequest) (*HeadResponse, error) // Search objects in container. Search query allows to match by Object - // Header's filed values. Please see the corresponding NeoFS Technical + // Header's filed values. Please see the corresponding FrostFS Technical // Specification section for more details. // // Extended headers can change `Search` behaviour: @@ -825,16 +829,20 @@ type ObjectServiceServer interface { // provided session token has expired. PutSingle(context.Context, *PutSingleRequest) (*PutSingleResponse, error) // Patch the object. Request uses gRPC stream. First message must set - // the address of the object that is going to get patched. If the object's attributes - // are patched, then these attrubutes must be set only within the first stream message. + // the address of the object that is going to get patched. If the object's + // attributes are patched, then these attrubutes must be set only within the + // first stream message. // - // If the patch request is performed by NOT the object's owner but if the actor has the permission - // to perform the patch, then `OwnerID` of the object is changed. In this case the object's owner - // loses the object's ownership after the patch request is successfully done. + // If the patch request is performed by NOT the object's owner but if the + // actor has the permission to perform the patch, then `OwnerID` of the object + // is changed. In this case the object's owner loses the object's ownership + // after the patch request is successfully done. // - // As objects are content-addressable the patching causes new object ID generation for the patched object. - // This object id is set witihn `PatchResponse`. But the object id may remain unchanged in such cases: - // 1. The chunk of the applying patch contains the same value as the object's payload within the same range; + // As objects are content-addressable the patching causes new object ID + // generation for the patched object. This object id is set witihn + // `PatchResponse`. But the object id may remain unchanged in such cases: + // 1. The chunk of the applying patch contains the same value as the object's + // payload within the same range; // 2. The patch that reverts the changes applied by preceding patch; // 3. The application of the same patches for the object a few times. // -- 2.45.3 From 805da79319a4b84b5d2a8a0c6f2234ff37f55acd Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 1 Oct 2024 09:42:40 +0300 Subject: [PATCH 3/7] [#120] protogen: Marshal enum as string Be compatible with protojson. Signed-off-by: Evgenii Stratonikov --- acl/grpc/types_frostfs.pb.go | 35 +++++++++++++++++++---- ape/grpc/types_frostfs.pb.go | 7 ++++- netmap/grpc/types_frostfs.pb.go | 21 ++++++++++++-- object/grpc/service_frostfs.pb.go | 21 ++++++++++++-- object/grpc/types_frostfs.pb.go | 14 +++++++-- refs/grpc/types_frostfs.pb.go | 14 +++++++-- session/grpc/types_frostfs.pb.go | 14 +++++++-- util/proto/test/custom/test_frostfs.pb.go | 7 ++++- util/protogen/internalgengo/json.go | 8 +++++- 9 files changed, 121 insertions(+), 20 deletions(-) diff --git a/acl/grpc/types_frostfs.pb.go b/acl/grpc/types_frostfs.pb.go index 2b116bd..b055167 100644 --- a/acl/grpc/types_frostfs.pb.go +++ b/acl/grpc/types_frostfs.pb.go @@ -356,12 +356,22 @@ func (x *EACLRecord_Filter) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"headerType\":" out.RawString(prefix[1:]) - out.Int32(int32(x.HeaderType)) + v := int32(x.HeaderType) + if vv, ok := HeaderType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"matchType\":" out.RawString(prefix) - out.Int32(int32(x.MatchType)) + v := int32(x.MatchType) + if vv, ok := MatchType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"key\":" @@ -570,7 +580,12 @@ func (x *EACLRecord_Target) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"role\":" out.RawString(prefix[1:]) - out.Int32(int32(x.Role)) + v := int32(x.Role) + if vv, ok := Role_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"keys\":" @@ -812,12 +827,22 @@ func (x *EACLRecord) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"operation\":" out.RawString(prefix[1:]) - out.Int32(int32(x.Operation)) + v := int32(x.Operation) + if vv, ok := Operation_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"action\":" out.RawString(prefix) - out.Int32(int32(x.Action)) + v := int32(x.Action) + if vv, ok := Action_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"filters\":" diff --git a/ape/grpc/types_frostfs.pb.go b/ape/grpc/types_frostfs.pb.go index 216415b..e19d9f6 100644 --- a/ape/grpc/types_frostfs.pb.go +++ b/ape/grpc/types_frostfs.pb.go @@ -159,7 +159,12 @@ func (x *ChainTarget) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"type\":" out.RawString(prefix[1:]) - out.Int32(int32(x.Type)) + v := int32(x.Type) + if vv, ok := TargetType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"name\":" diff --git a/netmap/grpc/types_frostfs.pb.go b/netmap/grpc/types_frostfs.pb.go index e7597ea..43af103 100644 --- a/netmap/grpc/types_frostfs.pb.go +++ b/netmap/grpc/types_frostfs.pb.go @@ -288,7 +288,12 @@ func (x *Filter) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"op\":" out.RawString(prefix) - out.Int32(int32(x.Op)) + v := int32(x.Op) + if vv, ok := Operation_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"value\":" @@ -572,7 +577,12 @@ func (x *Selector) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"clause\":" out.RawString(prefix) - out.Int32(int32(x.Clause)) + v := int32(x.Clause) + if vv, ok := Clause_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"attribute\":" @@ -1627,7 +1637,12 @@ func (x *NodeInfo) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"state\":" out.RawString(prefix) - out.Int32(int32(x.State)) + v := int32(x.State) + if vv, ok := NodeInfo_State_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } out.RawByte('}') } diff --git a/object/grpc/service_frostfs.pb.go b/object/grpc/service_frostfs.pb.go index dea1b5b..188d032 100644 --- a/object/grpc/service_frostfs.pb.go +++ b/object/grpc/service_frostfs.pb.go @@ -4117,7 +4117,12 @@ func (x *SearchRequest_Body_Filter) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"matchType\":" out.RawString(prefix[1:]) - out.Int32(int32(x.MatchType)) + v := int32(x.MatchType) + if vv, ok := MatchType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"key\":" @@ -6246,7 +6251,12 @@ func (x *GetRangeHashRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"type\":" out.RawString(prefix) - out.Int32(int32(x.Type)) + v := int32(x.Type) + if vv, ok := grpc.ChecksumType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } out.RawByte('}') } @@ -6659,7 +6669,12 @@ func (x *GetRangeHashResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"type\":" out.RawString(prefix[1:]) - out.Int32(int32(x.Type)) + v := int32(x.Type) + if vv, ok := grpc.ChecksumType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"hashList\":" diff --git a/object/grpc/types_frostfs.pb.go b/object/grpc/types_frostfs.pb.go index 4233417..9fc2769 100644 --- a/object/grpc/types_frostfs.pb.go +++ b/object/grpc/types_frostfs.pb.go @@ -323,7 +323,12 @@ func (x *ShortHeader) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"objectType\":" out.RawString(prefix) - out.Int32(int32(x.ObjectType)) + v := int32(x.ObjectType) + if vv, ok := ObjectType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"payloadLength\":" @@ -1659,7 +1664,12 @@ func (x *Header) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"objectType\":" out.RawString(prefix) - out.Int32(int32(x.ObjectType)) + v := int32(x.ObjectType) + if vv, ok := ObjectType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"homomorphicHash\":" diff --git a/refs/grpc/types_frostfs.pb.go b/refs/grpc/types_frostfs.pb.go index 35febe9..5f35eba 100644 --- a/refs/grpc/types_frostfs.pb.go +++ b/refs/grpc/types_frostfs.pb.go @@ -933,7 +933,12 @@ func (x *Signature) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"scheme\":" out.RawString(prefix) - out.Int32(int32(x.Scheme)) + v := int32(x.Scheme) + if vv, ok := SignatureScheme_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } out.RawByte('}') } @@ -1270,7 +1275,12 @@ func (x *Checksum) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"type\":" out.RawString(prefix[1:]) - out.Int32(int32(x.Type)) + v := int32(x.Type) + if vv, ok := ChecksumType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"sum\":" diff --git a/session/grpc/types_frostfs.pb.go b/session/grpc/types_frostfs.pb.go index 41ff5d9..c92ab28 100644 --- a/session/grpc/types_frostfs.pb.go +++ b/session/grpc/types_frostfs.pb.go @@ -362,7 +362,12 @@ func (x *ObjectSessionContext) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"verb\":" out.RawString(prefix[1:]) - out.Int32(int32(x.Verb)) + v := int32(x.Verb) + if vv, ok := ObjectSessionContext_Verb_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"target\":" @@ -600,7 +605,12 @@ func (x *ContainerSessionContext) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"verb\":" out.RawString(prefix[1:]) - out.Int32(int32(x.Verb)) + v := int32(x.Verb) + if vv, ok := ContainerSessionContext_Verb_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } { const prefix string = ",\"wildcard\":" diff --git a/util/proto/test/custom/test_frostfs.pb.go b/util/proto/test/custom/test_frostfs.pb.go index 97efa51..005d6d1 100644 --- a/util/proto/test/custom/test_frostfs.pb.go +++ b/util/proto/test/custom/test_frostfs.pb.go @@ -614,7 +614,12 @@ func (x *Primitives) MarshalEasyJSON(out *jwriter.Writer) { { const prefix string = ",\"fieldH\":" out.RawString(prefix) - out.Int32(int32(x.FieldH)) + v := int32(x.FieldH) + if vv, ok := Primitives_SomeEnum_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } switch xx := x.FieldM.(type) { case *Primitives_FieldMa: diff --git a/util/protogen/internalgengo/json.go b/util/protogen/internalgengo/json.go index f7cd284..95a06d5 100644 --- a/util/protogen/internalgengo/json.go +++ b/util/protogen/internalgengo/json.go @@ -195,7 +195,13 @@ func emitJSONFieldWrite(g *protogen.GeneratedFile, f *protogen.Field, name strin case protoreflect.BoolKind: template = "out.Bool(%s)" case protoreflect.EnumKind: - template = "out.Int32(int32(%s))" + enumType := fieldType(g, f).String() + template = `v := int32(%s) + if vv, ok := ` + enumType + `_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + }` case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: template = "out.Int32(%s)" case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: -- 2.45.3 From eeb754c327dec8e9007bb9154ab215f91240d5ec Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 1 Oct 2024 09:53:38 +0300 Subject: [PATCH 4/7] [#120] protogen: Omit empty fields from JSON output Signed-off-by: Evgenii Stratonikov --- accounting/grpc/service_frostfs.pb.go | 108 +- accounting/grpc/types_frostfs.pb.go | 27 +- acl/grpc/types_frostfs.pb.go | 433 ++++-- ape/grpc/types_frostfs.pb.go | 49 +- apemanager/grpc/service_frostfs.pb.go | 344 ++++- container/grpc/service_frostfs.pb.go | 478 +++++-- container/grpc/types_frostfs.pb.go | 130 +- lock/grpc/types_frostfs.pb.go | 22 +- netmap/grpc/service_frostfs.pb.go | 295 +++- netmap/grpc/types_frostfs.pb.go | 603 +++++--- object/grpc/service_frostfs.pb.go | 1592 ++++++++++++++++----- object/grpc/types_frostfs.pb.go | 749 +++++++--- refs/grpc/types_frostfs.pb.go | 206 ++- session/grpc/service_frostfs.pb.go | 134 +- session/grpc/types_frostfs.pb.go | 621 ++++++-- status/grpc/types_frostfs.pb.go | 83 +- tombstone/grpc/types_frostfs.pb.go | 56 +- util/proto/test/custom/test_frostfs.pb.go | 388 +++-- util/protogen/internalgengo/json.go | 31 +- 19 files changed, 4717 insertions(+), 1632 deletions(-) diff --git a/accounting/grpc/service_frostfs.pb.go b/accounting/grpc/service_frostfs.pb.go index b70fd27..4f11303 100644 --- a/accounting/grpc/service_frostfs.pb.go +++ b/accounting/grpc/service_frostfs.pb.go @@ -98,11 +98,19 @@ func (x *BalanceRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"ownerId\":" - out.RawString(prefix[1:]) - x.OwnerId.MarshalEasyJSON(out) + if x.OwnerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ownerId\":" + out.RawString(prefix) + x.OwnerId.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -295,21 +303,43 @@ func (x *BalanceRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -452,11 +482,19 @@ func (x *BalanceResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"balance\":" - out.RawString(prefix[1:]) - x.Balance.MarshalEasyJSON(out) + if x.Balance != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"balance\":" + out.RawString(prefix) + x.Balance.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -649,21 +687,43 @@ func (x *BalanceResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } diff --git a/accounting/grpc/types_frostfs.pb.go b/accounting/grpc/types_frostfs.pb.go index 182705e..0ae770b 100644 --- a/accounting/grpc/types_frostfs.pb.go +++ b/accounting/grpc/types_frostfs.pb.go @@ -113,16 +113,31 @@ func (x *Decimal) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"value\":" - out.RawString(prefix[1:]) - out.Int64(x.Value) + if x.Value != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.Int64(x.Value) + } } { - const prefix string = ",\"precision\":" - out.RawString(prefix) - out.Uint32(x.Precision) + if x.Precision != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"precision\":" + out.RawString(prefix) + out.Uint32(x.Precision) + } } out.RawByte('}') } diff --git a/acl/grpc/types_frostfs.pb.go b/acl/grpc/types_frostfs.pb.go index b055167..57e1682 100644 --- a/acl/grpc/types_frostfs.pb.go +++ b/acl/grpc/types_frostfs.pb.go @@ -352,36 +352,65 @@ func (x *EACLRecord_Filter) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"headerType\":" - out.RawString(prefix[1:]) - v := int32(x.HeaderType) - if vv, ok := HeaderType_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.HeaderType != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"headerType\":" + out.RawString(prefix) + v := int32(x.HeaderType) + if vv, ok := HeaderType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } { - const prefix string = ",\"matchType\":" - out.RawString(prefix) - v := int32(x.MatchType) - if vv, ok := MatchType_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.MatchType != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"matchType\":" + out.RawString(prefix) + v := int32(x.MatchType) + if vv, ok := MatchType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } { - const prefix string = ",\"key\":" - out.RawString(prefix) - out.String(x.Key) + if len(x.Key) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } } { - const prefix string = ",\"value\":" - out.RawString(prefix) - out.String(x.Value) + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.String(x.Value) + } } out.RawByte('}') } @@ -576,28 +605,43 @@ func (x *EACLRecord_Target) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"role\":" - out.RawString(prefix[1:]) - v := int32(x.Role) - if vv, ok := Role_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.Role != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"role\":" + out.RawString(prefix) + v := int32(x.Role) + if vv, ok := Role_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } { - const prefix string = ",\"keys\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Keys { - if i != 0 { + if len(x.Keys) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.Base64Bytes(x.Keys[i]) + const prefix string = "\"keys\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Keys { + if i != 0 { + out.RawByte(',') + } + out.Base64Bytes(x.Keys[i]) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -823,50 +867,79 @@ func (x *EACLRecord) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"operation\":" - out.RawString(prefix[1:]) - v := int32(x.Operation) - if vv, ok := Operation_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) - } - } - { - const prefix string = ",\"action\":" - out.RawString(prefix) - v := int32(x.Action) - if vv, ok := Action_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) - } - } - { - const prefix string = ",\"filters\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Filters { - if i != 0 { + if x.Operation != 0 { + if !first { out.RawByte(',') + } else { + first = false + } + const prefix string = "\"operation\":" + out.RawString(prefix) + v := int32(x.Operation) + if vv, ok := Operation_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) } - x.Filters[i].MarshalEasyJSON(out) } - out.RawByte(']') } { - const prefix string = ",\"targets\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Targets { - if i != 0 { + if x.Action != 0 { + if !first { out.RawByte(',') + } else { + first = false + } + const prefix string = "\"action\":" + out.RawString(prefix) + v := int32(x.Action) + if vv, ok := Action_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) } - x.Targets[i].MarshalEasyJSON(out) } - out.RawByte(']') + } + { + if len(x.Filters) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"filters\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Filters { + if i != 0 { + out.RawByte(',') + } + x.Filters[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + { + if len(x.Targets) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"targets\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Targets { + if i != 0 { + out.RawByte(',') + } + x.Targets[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } } out.RawByte('}') } @@ -1109,28 +1182,50 @@ func (x *EACLTable) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"version\":" - out.RawString(prefix[1:]) - x.Version.MarshalEasyJSON(out) - } - { - const prefix string = ",\"containerID\":" - out.RawString(prefix) - x.ContainerId.MarshalEasyJSON(out) - } - { - const prefix string = ",\"records\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Records { - if i != 0 { + if x.Version != nil { + if !first { out.RawByte(',') + } else { + first = false } - x.Records[i].MarshalEasyJSON(out) + const prefix string = "\"version\":" + out.RawString(prefix) + x.Version.MarshalEasyJSON(out) + } + } + { + if x.ContainerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerID\":" + out.RawString(prefix) + x.ContainerId.MarshalEasyJSON(out) + } + } + { + if len(x.Records) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"records\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Records { + if i != 0 { + out.RawByte(',') + } + x.Records[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -1317,21 +1412,43 @@ func (x *BearerToken_Body_TokenLifetime) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"exp\":" - out.RawString(prefix[1:]) - out.Uint64(x.Exp) + if x.Exp != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"exp\":" + out.RawString(prefix) + out.Uint64(x.Exp) + } } { - const prefix string = ",\"nbf\":" - out.RawString(prefix) - out.Uint64(x.Nbf) + if x.Nbf != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nbf\":" + out.RawString(prefix) + out.Uint64(x.Nbf) + } } { - const prefix string = ",\"iat\":" - out.RawString(prefix) - out.Uint64(x.Iat) + if x.Iat != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"iat\":" + out.RawString(prefix) + out.Uint64(x.Iat) + } } out.RawByte('}') } @@ -1497,23 +1614,38 @@ func (x *BearerToken_Body_APEOverride) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"target\":" - out.RawString(prefix[1:]) - x.Target.MarshalEasyJSON(out) + if x.Target != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"target\":" + out.RawString(prefix) + x.Target.MarshalEasyJSON(out) + } } { - const prefix string = ",\"chains\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Chains { - if i != 0 { + if len(x.Chains) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Chains[i].MarshalEasyJSON(out) + const prefix string = "\"chains\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Chains { + if i != 0 { + out.RawByte(',') + } + x.Chains[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -1745,31 +1877,67 @@ func (x *BearerToken_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"eaclTable\":" - out.RawString(prefix[1:]) - x.EaclTable.MarshalEasyJSON(out) + if x.EaclTable != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"eaclTable\":" + out.RawString(prefix) + x.EaclTable.MarshalEasyJSON(out) + } } { - const prefix string = ",\"ownerID\":" - out.RawString(prefix) - x.OwnerId.MarshalEasyJSON(out) + if x.OwnerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ownerID\":" + out.RawString(prefix) + x.OwnerId.MarshalEasyJSON(out) + } } { - const prefix string = ",\"lifetime\":" - out.RawString(prefix) - x.Lifetime.MarshalEasyJSON(out) + if x.Lifetime != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"lifetime\":" + out.RawString(prefix) + x.Lifetime.MarshalEasyJSON(out) + } } { - const prefix string = ",\"allowImpersonate\":" - out.RawString(prefix) - out.Bool(x.AllowImpersonate) + if x.AllowImpersonate { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"allowImpersonate\":" + out.RawString(prefix) + out.Bool(x.AllowImpersonate) + } } { - const prefix string = ",\"apeOverride\":" - out.RawString(prefix) - x.ApeOverride.MarshalEasyJSON(out) + if x.ApeOverride != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"apeOverride\":" + out.RawString(prefix) + x.ApeOverride.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1948,16 +2116,31 @@ func (x *BearerToken) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"signature\":" - out.RawString(prefix) - x.Signature.MarshalEasyJSON(out) + if x.Signature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } } out.RawByte('}') } diff --git a/ape/grpc/types_frostfs.pb.go b/ape/grpc/types_frostfs.pb.go index e19d9f6..7967e13 100644 --- a/ape/grpc/types_frostfs.pb.go +++ b/ape/grpc/types_frostfs.pb.go @@ -155,21 +155,36 @@ func (x *ChainTarget) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"type\":" - out.RawString(prefix[1:]) - v := int32(x.Type) - if vv, ok := TargetType_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.Type != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"type\":" + out.RawString(prefix) + v := int32(x.Type) + if vv, ok := TargetType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } { - const prefix string = ",\"name\":" - out.RawString(prefix) - out.String(x.Name) + if len(x.Name) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"name\":" + out.RawString(prefix) + out.String(x.Name) + } } out.RawByte('}') } @@ -338,13 +353,21 @@ func (x *Chain) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') switch xx := x.Kind.(type) { case *Chain_Raw: { - const prefix string = ",\"raw\":" - out.RawString(prefix[1:]) - out.Base64Bytes(xx.Raw) + if len(xx.Raw) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"raw\":" + out.RawString(prefix) + out.Base64Bytes(xx.Raw) + } } } out.RawByte('}') diff --git a/apemanager/grpc/service_frostfs.pb.go b/apemanager/grpc/service_frostfs.pb.go index 99abeb2..2a30850 100644 --- a/apemanager/grpc/service_frostfs.pb.go +++ b/apemanager/grpc/service_frostfs.pb.go @@ -121,16 +121,31 @@ func (x *AddChainRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"target\":" - out.RawString(prefix[1:]) - x.Target.MarshalEasyJSON(out) + if x.Target != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"target\":" + out.RawString(prefix) + x.Target.MarshalEasyJSON(out) + } } { - const prefix string = ",\"chain\":" - out.RawString(prefix) - x.Chain.MarshalEasyJSON(out) + if x.Chain != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"chain\":" + out.RawString(prefix) + x.Chain.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -330,21 +345,43 @@ func (x *AddChainRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -484,11 +521,19 @@ func (x *AddChainResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"chainId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.ChainId) + if len(x.ChainId) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"chainId\":" + out.RawString(prefix) + out.Base64Bytes(x.ChainId) + } } out.RawByte('}') } @@ -680,21 +725,43 @@ func (x *AddChainResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -857,16 +924,31 @@ func (x *RemoveChainRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"target\":" - out.RawString(prefix[1:]) - x.Target.MarshalEasyJSON(out) + if x.Target != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"target\":" + out.RawString(prefix) + x.Target.MarshalEasyJSON(out) + } } { - const prefix string = ",\"chainId\":" - out.RawString(prefix) - out.Base64Bytes(x.ChainId) + if len(x.ChainId) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"chainId\":" + out.RawString(prefix) + out.Base64Bytes(x.ChainId) + } } out.RawByte('}') } @@ -1065,21 +1147,43 @@ func (x *RemoveChainRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1381,21 +1485,43 @@ func (x *RemoveChainResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1538,11 +1664,19 @@ func (x *ListChainsRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"target\":" - out.RawString(prefix[1:]) - x.Target.MarshalEasyJSON(out) + if x.Target != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"target\":" + out.RawString(prefix) + x.Target.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1735,21 +1869,43 @@ func (x *ListChainsRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1895,18 +2051,26 @@ func (x *ListChainsResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"chains\":" - out.RawString(prefix[1:]) - out.RawByte('[') - for i := range x.Chains { - if i != 0 { + if len(x.Chains) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Chains[i].MarshalEasyJSON(out) + const prefix string = "\"chains\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Chains { + if i != 0 { + out.RawByte(',') + } + x.Chains[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -2106,21 +2270,43 @@ func (x *ListChainsResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } diff --git a/container/grpc/service_frostfs.pb.go b/container/grpc/service_frostfs.pb.go index ffdc730..4ccb595 100644 --- a/container/grpc/service_frostfs.pb.go +++ b/container/grpc/service_frostfs.pb.go @@ -121,16 +121,31 @@ func (x *PutRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"container\":" - out.RawString(prefix[1:]) - x.Container.MarshalEasyJSON(out) + if x.Container != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"container\":" + out.RawString(prefix) + x.Container.MarshalEasyJSON(out) + } } { - const prefix string = ",\"signature\":" - out.RawString(prefix) - x.Signature.MarshalEasyJSON(out) + if x.Signature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -330,21 +345,43 @@ func (x *PutRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -487,11 +524,19 @@ func (x *PutResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - x.ContainerId.MarshalEasyJSON(out) + if x.ContainerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + x.ContainerId.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -684,21 +729,43 @@ func (x *PutResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -864,16 +931,31 @@ func (x *DeleteRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - x.ContainerId.MarshalEasyJSON(out) + if x.ContainerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + x.ContainerId.MarshalEasyJSON(out) + } } { - const prefix string = ",\"signature\":" - out.RawString(prefix) - x.Signature.MarshalEasyJSON(out) + if x.Signature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1073,21 +1155,43 @@ func (x *DeleteRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1389,21 +1493,43 @@ func (x *DeleteResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1546,11 +1672,19 @@ func (x *GetRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - x.ContainerId.MarshalEasyJSON(out) + if x.ContainerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + x.ContainerId.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1743,21 +1877,43 @@ func (x *GetRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1946,21 +2102,43 @@ func (x *GetResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"container\":" - out.RawString(prefix[1:]) - x.Container.MarshalEasyJSON(out) + if x.Container != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"container\":" + out.RawString(prefix) + x.Container.MarshalEasyJSON(out) + } } { - const prefix string = ",\"signature\":" - out.RawString(prefix) - x.Signature.MarshalEasyJSON(out) + if x.Signature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } } { - const prefix string = ",\"sessionToken\":" - out.RawString(prefix) - x.SessionToken.MarshalEasyJSON(out) + if x.SessionToken != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"sessionToken\":" + out.RawString(prefix) + x.SessionToken.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2167,21 +2345,43 @@ func (x *GetResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2324,11 +2524,19 @@ func (x *ListRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"ownerId\":" - out.RawString(prefix[1:]) - x.OwnerId.MarshalEasyJSON(out) + if x.OwnerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ownerId\":" + out.RawString(prefix) + x.OwnerId.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2521,21 +2729,43 @@ func (x *ListRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2681,18 +2911,26 @@ func (x *ListResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerIds\":" - out.RawString(prefix[1:]) - out.RawByte('[') - for i := range x.ContainerIds { - if i != 0 { + if len(x.ContainerIds) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.ContainerIds[i].MarshalEasyJSON(out) + const prefix string = "\"containerIds\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.ContainerIds { + if i != 0 { + out.RawByte(',') + } + x.ContainerIds[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -2892,21 +3130,43 @@ func (x *ListResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } diff --git a/container/grpc/types_frostfs.pb.go b/container/grpc/types_frostfs.pb.go index 3010eb0..9db07ed 100644 --- a/container/grpc/types_frostfs.pb.go +++ b/container/grpc/types_frostfs.pb.go @@ -115,16 +115,31 @@ func (x *Container_Attribute) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"key\":" - out.RawString(prefix[1:]) - out.String(x.Key) + if len(x.Key) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } } { - const prefix string = ",\"value\":" - out.RawString(prefix) - out.String(x.Value) + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.String(x.Value) + } } out.RawByte('}') } @@ -370,43 +385,86 @@ func (x *Container) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"version\":" - out.RawString(prefix[1:]) - x.Version.MarshalEasyJSON(out) - } - { - const prefix string = ",\"ownerID\":" - out.RawString(prefix) - x.OwnerId.MarshalEasyJSON(out) - } - { - const prefix string = ",\"nonce\":" - out.RawString(prefix) - out.Base64Bytes(x.Nonce) - } - { - const prefix string = ",\"basicACL\":" - out.RawString(prefix) - out.Uint32(x.BasicAcl) - } - { - const prefix string = ",\"attributes\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Attributes { - if i != 0 { + if x.Version != nil { + if !first { out.RawByte(',') + } else { + first = false } - x.Attributes[i].MarshalEasyJSON(out) + const prefix string = "\"version\":" + out.RawString(prefix) + x.Version.MarshalEasyJSON(out) } - out.RawByte(']') } { - const prefix string = ",\"placementPolicy\":" - out.RawString(prefix) - x.PlacementPolicy.MarshalEasyJSON(out) + if x.OwnerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ownerID\":" + out.RawString(prefix) + x.OwnerId.MarshalEasyJSON(out) + } + } + { + if len(x.Nonce) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nonce\":" + out.RawString(prefix) + out.Base64Bytes(x.Nonce) + } + } + { + if x.BasicAcl != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"basicACL\":" + out.RawString(prefix) + out.Uint32(x.BasicAcl) + } + } + { + if len(x.Attributes) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"attributes\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Attributes { + if i != 0 { + out.RawByte(',') + } + x.Attributes[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + { + if x.PlacementPolicy != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"placementPolicy\":" + out.RawString(prefix) + x.PlacementPolicy.MarshalEasyJSON(out) + } } out.RawByte('}') } diff --git a/lock/grpc/types_frostfs.pb.go b/lock/grpc/types_frostfs.pb.go index 58be895..33f22c5 100644 --- a/lock/grpc/types_frostfs.pb.go +++ b/lock/grpc/types_frostfs.pb.go @@ -100,18 +100,26 @@ func (x *Lock) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"members\":" - out.RawString(prefix[1:]) - out.RawByte('[') - for i := range x.Members { - if i != 0 { + if len(x.Members) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Members[i].MarshalEasyJSON(out) + const prefix string = "\"members\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Members { + if i != 0 { + out.RawByte(',') + } + x.Members[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } diff --git a/netmap/grpc/service_frostfs.pb.go b/netmap/grpc/service_frostfs.pb.go index 3d62855..4d53031 100644 --- a/netmap/grpc/service_frostfs.pb.go +++ b/netmap/grpc/service_frostfs.pb.go @@ -257,21 +257,43 @@ func (x *LocalNodeInfoRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -437,16 +459,31 @@ func (x *LocalNodeInfoResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"version\":" - out.RawString(prefix[1:]) - x.Version.MarshalEasyJSON(out) + if x.Version != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"version\":" + out.RawString(prefix) + x.Version.MarshalEasyJSON(out) + } } { - const prefix string = ",\"nodeInfo\":" - out.RawString(prefix) - x.NodeInfo.MarshalEasyJSON(out) + if x.NodeInfo != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nodeInfo\":" + out.RawString(prefix) + x.NodeInfo.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -646,21 +683,43 @@ func (x *LocalNodeInfoResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -962,21 +1021,43 @@ func (x *NetworkInfoRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1119,11 +1200,19 @@ func (x *NetworkInfoResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"networkInfo\":" - out.RawString(prefix[1:]) - x.NetworkInfo.MarshalEasyJSON(out) + if x.NetworkInfo != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"networkInfo\":" + out.RawString(prefix) + x.NetworkInfo.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1316,21 +1405,43 @@ func (x *NetworkInfoResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1632,21 +1743,43 @@ func (x *NetmapSnapshotRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1789,11 +1922,19 @@ func (x *NetmapSnapshotResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"netmap\":" - out.RawString(prefix[1:]) - x.Netmap.MarshalEasyJSON(out) + if x.Netmap != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"netmap\":" + out.RawString(prefix) + x.Netmap.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1986,21 +2127,43 @@ func (x *NetmapSnapshotResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } diff --git a/netmap/grpc/types_frostfs.pb.go b/netmap/grpc/types_frostfs.pb.go index 43af103..d082910 100644 --- a/netmap/grpc/types_frostfs.pb.go +++ b/netmap/grpc/types_frostfs.pb.go @@ -274,43 +274,79 @@ func (x *Filter) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"name\":" - out.RawString(prefix[1:]) - out.String(x.Name) - } - { - const prefix string = ",\"key\":" - out.RawString(prefix) - out.String(x.Key) - } - { - const prefix string = ",\"op\":" - out.RawString(prefix) - v := int32(x.Op) - if vv, ok := Operation_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) - } - } - { - const prefix string = ",\"value\":" - out.RawString(prefix) - out.String(x.Value) - } - { - const prefix string = ",\"filters\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Filters { - if i != 0 { + if len(x.Name) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Filters[i].MarshalEasyJSON(out) + const prefix string = "\"name\":" + out.RawString(prefix) + out.String(x.Name) + } + } + { + if len(x.Key) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } + } + { + if x.Op != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"op\":" + out.RawString(prefix) + v := int32(x.Op) + if vv, ok := Operation_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } + } + } + { + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.String(x.Value) + } + } + { + if len(x.Filters) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"filters\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Filters { + if i != 0 { + out.RawByte(',') + } + x.Filters[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -563,36 +599,72 @@ func (x *Selector) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"name\":" - out.RawString(prefix[1:]) - out.String(x.Name) - } - { - const prefix string = ",\"count\":" - out.RawString(prefix) - out.Uint32(x.Count) - } - { - const prefix string = ",\"clause\":" - out.RawString(prefix) - v := int32(x.Clause) - if vv, ok := Clause_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if len(x.Name) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"name\":" + out.RawString(prefix) + out.String(x.Name) } } { - const prefix string = ",\"attribute\":" - out.RawString(prefix) - out.String(x.Attribute) + if x.Count != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"count\":" + out.RawString(prefix) + out.Uint32(x.Count) + } } { - const prefix string = ",\"filter\":" - out.RawString(prefix) - out.String(x.Filter) + if x.Clause != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"clause\":" + out.RawString(prefix) + v := int32(x.Clause) + if vv, ok := Clause_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } + } + } + { + if len(x.Attribute) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"attribute\":" + out.RawString(prefix) + out.String(x.Attribute) + } + } + { + if len(x.Filter) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"filter\":" + out.RawString(prefix) + out.String(x.Filter) + } } out.RawByte('}') } @@ -817,26 +889,55 @@ func (x *Replica) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"count\":" - out.RawString(prefix[1:]) - out.Uint32(x.Count) + if x.Count != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"count\":" + out.RawString(prefix) + out.Uint32(x.Count) + } } { - const prefix string = ",\"selector\":" - out.RawString(prefix) - out.String(x.Selector) + if len(x.Selector) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"selector\":" + out.RawString(prefix) + out.String(x.Selector) + } } { - const prefix string = ",\"ecDataCount\":" - out.RawString(prefix) - out.Uint32(x.EcDataCount) + if x.EcDataCount != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ecDataCount\":" + out.RawString(prefix) + out.Uint32(x.EcDataCount) + } } { - const prefix string = ",\"ecParityCount\":" - out.RawString(prefix) - out.Uint32(x.EcParityCount) + if x.EcParityCount != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ecParityCount\":" + out.RawString(prefix) + out.Uint32(x.EcParityCount) + } } out.RawByte('}') } @@ -1077,52 +1178,88 @@ func (x *PlacementPolicy) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"replicas\":" - out.RawString(prefix[1:]) - out.RawByte('[') - for i := range x.Replicas { - if i != 0 { + if len(x.Replicas) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Replicas[i].MarshalEasyJSON(out) + const prefix string = "\"replicas\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Replicas { + if i != 0 { + out.RawByte(',') + } + x.Replicas[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } { - const prefix string = ",\"containerBackupFactor\":" - out.RawString(prefix) - out.Uint32(x.ContainerBackupFactor) - } - { - const prefix string = ",\"selectors\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Selectors { - if i != 0 { + if x.ContainerBackupFactor != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Selectors[i].MarshalEasyJSON(out) + const prefix string = "\"containerBackupFactor\":" + out.RawString(prefix) + out.Uint32(x.ContainerBackupFactor) } - out.RawByte(']') } { - const prefix string = ",\"filters\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Filters { - if i != 0 { + if len(x.Selectors) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Filters[i].MarshalEasyJSON(out) + const prefix string = "\"selectors\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Selectors { + if i != 0 { + out.RawByte(',') + } + x.Selectors[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } { - const prefix string = ",\"unique\":" - out.RawString(prefix) - out.Bool(x.Unique) + if len(x.Filters) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"filters\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Filters { + if i != 0 { + out.RawByte(',') + } + x.Filters[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + { + if x.Unique { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"unique\":" + out.RawString(prefix) + out.Bool(x.Unique) + } } out.RawByte('}') } @@ -1373,28 +1510,50 @@ func (x *NodeInfo_Attribute) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"key\":" - out.RawString(prefix[1:]) - out.String(x.Key) - } - { - const prefix string = ",\"value\":" - out.RawString(prefix) - out.String(x.Value) - } - { - const prefix string = ",\"parents\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Parents { - if i != 0 { + if len(x.Key) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.String(x.Parents[i]) + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } + } + { + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.String(x.Value) + } + } + { + if len(x.Parents) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parents\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Parents { + if i != 0 { + out.RawByte(',') + } + out.String(x.Parents[i]) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -1604,44 +1763,73 @@ func (x *NodeInfo) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"publicKey\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.PublicKey) - } - { - const prefix string = ",\"addresses\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Addresses { - if i != 0 { + if len(x.PublicKey) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.String(x.Addresses[i]) + const prefix string = "\"publicKey\":" + out.RawString(prefix) + out.Base64Bytes(x.PublicKey) } - out.RawByte(']') } { - const prefix string = ",\"attributes\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Attributes { - if i != 0 { + if len(x.Addresses) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Attributes[i].MarshalEasyJSON(out) + const prefix string = "\"addresses\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Addresses { + if i != 0 { + out.RawByte(',') + } + out.String(x.Addresses[i]) + } + out.RawByte(']') } - out.RawByte(']') } { - const prefix string = ",\"state\":" - out.RawString(prefix) - v := int32(x.State) - if vv, ok := NodeInfo_State_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if len(x.Attributes) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"attributes\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Attributes { + if i != 0 { + out.RawByte(',') + } + x.Attributes[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + { + if x.State != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"state\":" + out.RawString(prefix) + v := int32(x.State) + if vv, ok := NodeInfo_State_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } out.RawByte('}') @@ -1842,23 +2030,38 @@ func (x *Netmap) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"epoch\":" - out.RawString(prefix[1:]) - out.Uint64(x.Epoch) + if x.Epoch != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"epoch\":" + out.RawString(prefix) + out.Uint64(x.Epoch) + } } { - const prefix string = ",\"nodes\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Nodes { - if i != 0 { + if len(x.Nodes) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Nodes[i].MarshalEasyJSON(out) + const prefix string = "\"nodes\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Nodes { + if i != 0 { + out.RawByte(',') + } + x.Nodes[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -2017,16 +2220,31 @@ func (x *NetworkConfig_Parameter) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"key\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.Key) + if len(x.Key) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.Base64Bytes(x.Key) + } } { - const prefix string = ",\"value\":" - out.RawString(prefix) - out.Base64Bytes(x.Value) + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.Base64Bytes(x.Value) + } } out.RawByte('}') } @@ -2163,18 +2381,26 @@ func (x *NetworkConfig) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"parameters\":" - out.RawString(prefix[1:]) - out.RawByte('[') - for i := range x.Parameters { - if i != 0 { + if len(x.Parameters) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Parameters[i].MarshalEasyJSON(out) + const prefix string = "\"parameters\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Parameters { + if i != 0 { + out.RawByte(',') + } + x.Parameters[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -2370,26 +2596,55 @@ func (x *NetworkInfo) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"currentEpoch\":" - out.RawString(prefix[1:]) - out.Uint64(x.CurrentEpoch) + if x.CurrentEpoch != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"currentEpoch\":" + out.RawString(prefix) + out.Uint64(x.CurrentEpoch) + } } { - const prefix string = ",\"magicNumber\":" - out.RawString(prefix) - out.Uint64(x.MagicNumber) + if x.MagicNumber != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"magicNumber\":" + out.RawString(prefix) + out.Uint64(x.MagicNumber) + } } { - const prefix string = ",\"msPerBlock\":" - out.RawString(prefix) - out.Int64(x.MsPerBlock) + if x.MsPerBlock != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"msPerBlock\":" + out.RawString(prefix) + out.Int64(x.MsPerBlock) + } } { - const prefix string = ",\"networkConfig\":" - out.RawString(prefix) - x.NetworkConfig.MarshalEasyJSON(out) + if x.NetworkConfig != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"networkConfig\":" + out.RawString(prefix) + x.NetworkConfig.MarshalEasyJSON(out) + } } out.RawByte('}') } diff --git a/object/grpc/service_frostfs.pb.go b/object/grpc/service_frostfs.pb.go index 188d032..2434bd3 100644 --- a/object/grpc/service_frostfs.pb.go +++ b/object/grpc/service_frostfs.pb.go @@ -119,16 +119,31 @@ func (x *GetRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"address\":" - out.RawString(prefix[1:]) - x.Address.MarshalEasyJSON(out) + if x.Address != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"address\":" + out.RawString(prefix) + x.Address.MarshalEasyJSON(out) + } } { - const prefix string = ",\"raw\":" - out.RawString(prefix) - out.Bool(x.Raw) + if x.Raw { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"raw\":" + out.RawString(prefix) + out.Bool(x.Raw) + } } out.RawByte('}') } @@ -327,21 +342,43 @@ func (x *GetRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -530,21 +567,43 @@ func (x *GetResponse_Body_Init) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"objectId\":" - out.RawString(prefix[1:]) - x.ObjectId.MarshalEasyJSON(out) + if x.ObjectId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"objectId\":" + out.RawString(prefix) + x.ObjectId.MarshalEasyJSON(out) + } } { - const prefix string = ",\"signature\":" - out.RawString(prefix) - x.Signature.MarshalEasyJSON(out) + if x.Signature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } } { - const prefix string = ",\"header\":" - out.RawString(prefix) - x.Header.MarshalEasyJSON(out) + if x.Header != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"header\":" + out.RawString(prefix) + x.Header.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -787,31 +846,60 @@ func (x *GetResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') switch xx := x.ObjectPart.(type) { case *GetResponse_Body_Init_: { - const prefix string = ",\"init\":" - out.RawString(prefix[1:]) - xx.Init.MarshalEasyJSON(out) + if xx.Init != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"init\":" + out.RawString(prefix) + xx.Init.MarshalEasyJSON(out) + } } case *GetResponse_Body_Chunk: { - const prefix string = ",\"chunk\":" - out.RawString(prefix[1:]) - out.Base64Bytes(xx.Chunk) + if len(xx.Chunk) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"chunk\":" + out.RawString(prefix) + out.Base64Bytes(xx.Chunk) + } } case *GetResponse_Body_SplitInfo: { - const prefix string = ",\"splitInfo\":" - out.RawString(prefix[1:]) - xx.SplitInfo.MarshalEasyJSON(out) + if xx.SplitInfo != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"splitInfo\":" + out.RawString(prefix) + xx.SplitInfo.MarshalEasyJSON(out) + } } case *GetResponse_Body_EcInfo: { - const prefix string = ",\"ecInfo\":" - out.RawString(prefix[1:]) - xx.EcInfo.MarshalEasyJSON(out) + if xx.EcInfo != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ecInfo\":" + out.RawString(prefix) + xx.EcInfo.MarshalEasyJSON(out) + } } } out.RawByte('}') @@ -1061,21 +1149,43 @@ func (x *GetResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1286,33 +1396,62 @@ func (x *PutRequest_Body_Init) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"objectId\":" - out.RawString(prefix[1:]) - x.ObjectId.MarshalEasyJSON(out) - } - { - const prefix string = ",\"signature\":" - out.RawString(prefix) - x.Signature.MarshalEasyJSON(out) - } - { - const prefix string = ",\"header\":" - out.RawString(prefix) - x.Header.MarshalEasyJSON(out) - } - { - const prefix string = ",\"copiesNumber\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.CopiesNumber { - if i != 0 { + if x.ObjectId != nil { + if !first { out.RawByte(',') + } else { + first = false } - out.Uint32(x.CopiesNumber[i]) + const prefix string = "\"objectId\":" + out.RawString(prefix) + x.ObjectId.MarshalEasyJSON(out) + } + } + { + if x.Signature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + } + { + if x.Header != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"header\":" + out.RawString(prefix) + x.Header.MarshalEasyJSON(out) + } + } + { + if len(x.CopiesNumber) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"copiesNumber\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.CopiesNumber { + if i != 0 { + out.RawByte(',') + } + out.Uint32(x.CopiesNumber[i]) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -1514,19 +1653,34 @@ func (x *PutRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') switch xx := x.ObjectPart.(type) { case *PutRequest_Body_Init_: { - const prefix string = ",\"init\":" - out.RawString(prefix[1:]) - xx.Init.MarshalEasyJSON(out) + if xx.Init != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"init\":" + out.RawString(prefix) + xx.Init.MarshalEasyJSON(out) + } } case *PutRequest_Body_Chunk: { - const prefix string = ",\"chunk\":" - out.RawString(prefix[1:]) - out.Base64Bytes(xx.Chunk) + if len(xx.Chunk) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"chunk\":" + out.RawString(prefix) + out.Base64Bytes(xx.Chunk) + } } } out.RawByte('}') @@ -1746,21 +1900,43 @@ func (x *PutRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1903,11 +2079,19 @@ func (x *PutResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"objectId\":" - out.RawString(prefix[1:]) - x.ObjectId.MarshalEasyJSON(out) + if x.ObjectId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"objectId\":" + out.RawString(prefix) + x.ObjectId.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2100,21 +2284,43 @@ func (x *PutResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2257,11 +2463,19 @@ func (x *DeleteRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"address\":" - out.RawString(prefix[1:]) - x.Address.MarshalEasyJSON(out) + if x.Address != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"address\":" + out.RawString(prefix) + x.Address.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2454,21 +2668,43 @@ func (x *DeleteRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2611,11 +2847,19 @@ func (x *DeleteResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"tombstone\":" - out.RawString(prefix[1:]) - x.Tombstone.MarshalEasyJSON(out) + if x.Tombstone != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"tombstone\":" + out.RawString(prefix) + x.Tombstone.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2808,21 +3052,43 @@ func (x *DeleteResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -3005,21 +3271,43 @@ func (x *HeadRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"address\":" - out.RawString(prefix[1:]) - x.Address.MarshalEasyJSON(out) + if x.Address != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"address\":" + out.RawString(prefix) + x.Address.MarshalEasyJSON(out) + } } { - const prefix string = ",\"mainOnly\":" - out.RawString(prefix) - out.Bool(x.MainOnly) + if x.MainOnly { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"mainOnly\":" + out.RawString(prefix) + out.Bool(x.MainOnly) + } } { - const prefix string = ",\"raw\":" - out.RawString(prefix) - out.Bool(x.Raw) + if x.Raw { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"raw\":" + out.RawString(prefix) + out.Bool(x.Raw) + } } out.RawByte('}') } @@ -3224,21 +3512,43 @@ func (x *HeadRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -3404,16 +3714,31 @@ func (x *HeaderWithSignature) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"header\":" - out.RawString(prefix[1:]) - x.Header.MarshalEasyJSON(out) + if x.Header != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"header\":" + out.RawString(prefix) + x.Header.MarshalEasyJSON(out) + } } { - const prefix string = ",\"signature\":" - out.RawString(prefix) - x.Signature.MarshalEasyJSON(out) + if x.Signature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -3644,31 +3969,60 @@ func (x *HeadResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') switch xx := x.Head.(type) { case *HeadResponse_Body_Header: { - const prefix string = ",\"header\":" - out.RawString(prefix[1:]) - xx.Header.MarshalEasyJSON(out) + if xx.Header != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"header\":" + out.RawString(prefix) + xx.Header.MarshalEasyJSON(out) + } } case *HeadResponse_Body_ShortHeader: { - const prefix string = ",\"shortHeader\":" - out.RawString(prefix[1:]) - xx.ShortHeader.MarshalEasyJSON(out) + if xx.ShortHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"shortHeader\":" + out.RawString(prefix) + xx.ShortHeader.MarshalEasyJSON(out) + } } case *HeadResponse_Body_SplitInfo: { - const prefix string = ",\"splitInfo\":" - out.RawString(prefix[1:]) - xx.SplitInfo.MarshalEasyJSON(out) + if xx.SplitInfo != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"splitInfo\":" + out.RawString(prefix) + xx.SplitInfo.MarshalEasyJSON(out) + } } case *HeadResponse_Body_EcInfo: { - const prefix string = ",\"ecInfo\":" - out.RawString(prefix[1:]) - xx.EcInfo.MarshalEasyJSON(out) + if xx.EcInfo != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ecInfo\":" + out.RawString(prefix) + xx.EcInfo.MarshalEasyJSON(out) + } } } out.RawByte('}') @@ -3919,21 +4273,43 @@ func (x *HeadResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -4113,26 +4489,48 @@ func (x *SearchRequest_Body_Filter) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"matchType\":" - out.RawString(prefix[1:]) - v := int32(x.MatchType) - if vv, ok := MatchType_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.MatchType != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"matchType\":" + out.RawString(prefix) + v := int32(x.MatchType) + if vv, ok := MatchType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } { - const prefix string = ",\"key\":" - out.RawString(prefix) - out.String(x.Key) + if len(x.Key) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } } { - const prefix string = ",\"value\":" - out.RawString(prefix) - out.String(x.Value) + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.String(x.Value) + } } out.RawByte('}') } @@ -4334,28 +4732,50 @@ func (x *SearchRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - x.ContainerId.MarshalEasyJSON(out) - } - { - const prefix string = ",\"version\":" - out.RawString(prefix) - out.Uint32(x.Version) - } - { - const prefix string = ",\"filters\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Filters { - if i != 0 { + if x.ContainerId != nil { + if !first { out.RawByte(',') + } else { + first = false } - x.Filters[i].MarshalEasyJSON(out) + const prefix string = "\"containerId\":" + out.RawString(prefix) + x.ContainerId.MarshalEasyJSON(out) + } + } + { + if x.Version != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"version\":" + out.RawString(prefix) + out.Uint32(x.Version) + } + } + { + if len(x.Filters) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"filters\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Filters { + if i != 0 { + out.RawByte(',') + } + x.Filters[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -4568,21 +4988,43 @@ func (x *SearchRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -4728,18 +5170,26 @@ func (x *SearchResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"idList\":" - out.RawString(prefix[1:]) - out.RawByte('[') - for i := range x.IdList { - if i != 0 { + if len(x.IdList) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.IdList[i].MarshalEasyJSON(out) + const prefix string = "\"idList\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.IdList { + if i != 0 { + out.RawByte(',') + } + x.IdList[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -4939,21 +5389,43 @@ func (x *SearchResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -5113,16 +5585,31 @@ func (x *Range) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"offset\":" - out.RawString(prefix[1:]) - out.Uint64(x.Offset) + if x.Offset != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"offset\":" + out.RawString(prefix) + out.Uint64(x.Offset) + } } { - const prefix string = ",\"length\":" - out.RawString(prefix) - out.Uint64(x.Length) + if x.Length != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"length\":" + out.RawString(prefix) + out.Uint64(x.Length) + } } out.RawByte('}') } @@ -5299,21 +5786,43 @@ func (x *GetRangeRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"address\":" - out.RawString(prefix[1:]) - x.Address.MarshalEasyJSON(out) + if x.Address != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"address\":" + out.RawString(prefix) + x.Address.MarshalEasyJSON(out) + } } { - const prefix string = ",\"range\":" - out.RawString(prefix) - x.Range.MarshalEasyJSON(out) + if x.Range != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"range\":" + out.RawString(prefix) + x.Range.MarshalEasyJSON(out) + } } { - const prefix string = ",\"raw\":" - out.RawString(prefix) - out.Bool(x.Raw) + if x.Raw { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"raw\":" + out.RawString(prefix) + out.Bool(x.Raw) + } } out.RawByte('}') } @@ -5519,21 +6028,43 @@ func (x *GetRangeRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -5749,25 +6280,47 @@ func (x *GetRangeResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') switch xx := x.RangePart.(type) { case *GetRangeResponse_Body_Chunk: { - const prefix string = ",\"chunk\":" - out.RawString(prefix[1:]) - out.Base64Bytes(xx.Chunk) + if len(xx.Chunk) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"chunk\":" + out.RawString(prefix) + out.Base64Bytes(xx.Chunk) + } } case *GetRangeResponse_Body_SplitInfo: { - const prefix string = ",\"splitInfo\":" - out.RawString(prefix[1:]) - xx.SplitInfo.MarshalEasyJSON(out) + if xx.SplitInfo != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"splitInfo\":" + out.RawString(prefix) + xx.SplitInfo.MarshalEasyJSON(out) + } } case *GetRangeResponse_Body_EcInfo: { - const prefix string = ",\"ecInfo\":" - out.RawString(prefix[1:]) - xx.EcInfo.MarshalEasyJSON(out) + if xx.EcInfo != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ecInfo\":" + out.RawString(prefix) + xx.EcInfo.MarshalEasyJSON(out) + } } } out.RawByte('}') @@ -6002,21 +6555,43 @@ func (x *GetRangeResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -6225,37 +6800,66 @@ func (x *GetRangeHashRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"address\":" - out.RawString(prefix[1:]) - x.Address.MarshalEasyJSON(out) - } - { - const prefix string = ",\"ranges\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Ranges { - if i != 0 { + if x.Address != nil { + if !first { out.RawByte(',') + } else { + first = false } - x.Ranges[i].MarshalEasyJSON(out) + const prefix string = "\"address\":" + out.RawString(prefix) + x.Address.MarshalEasyJSON(out) } - out.RawByte(']') } { - const prefix string = ",\"salt\":" - out.RawString(prefix) - out.Base64Bytes(x.Salt) + if len(x.Ranges) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ranges\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Ranges { + if i != 0 { + out.RawByte(',') + } + x.Ranges[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } } { - const prefix string = ",\"type\":" - out.RawString(prefix) - v := int32(x.Type) - if vv, ok := grpc.ChecksumType_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if len(x.Salt) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"salt\":" + out.RawString(prefix) + out.Base64Bytes(x.Salt) + } + } + { + if x.Type != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"type\":" + out.RawString(prefix) + v := int32(x.Type) + if vv, ok := grpc.ChecksumType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } out.RawByte('}') @@ -6491,21 +7095,43 @@ func (x *GetRangeHashRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -6665,28 +7291,43 @@ func (x *GetRangeHashResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"type\":" - out.RawString(prefix[1:]) - v := int32(x.Type) - if vv, ok := grpc.ChecksumType_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.Type != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"type\":" + out.RawString(prefix) + v := int32(x.Type) + if vv, ok := grpc.ChecksumType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } { - const prefix string = ",\"hashList\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.HashList { - if i != 0 { + if len(x.HashList) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.Base64Bytes(x.HashList[i]) + const prefix string = "\"hashList\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.HashList { + if i != 0 { + out.RawByte(',') + } + out.Base64Bytes(x.HashList[i]) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -6907,21 +7548,43 @@ func (x *GetRangeHashResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -7086,23 +7749,38 @@ func (x *PutSingleRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"object\":" - out.RawString(prefix[1:]) - x.Object.MarshalEasyJSON(out) + if x.Object != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"object\":" + out.RawString(prefix) + x.Object.MarshalEasyJSON(out) + } } { - const prefix string = ",\"copiesNumber\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.CopiesNumber { - if i != 0 { + if len(x.CopiesNumber) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.Uint32(x.CopiesNumber[i]) + const prefix string = "\"copiesNumber\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.CopiesNumber { + if i != 0 { + out.RawByte(',') + } + out.Uint32(x.CopiesNumber[i]) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -7308,21 +7986,43 @@ func (x *PutSingleRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -7624,21 +8324,43 @@ func (x *PutSingleResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -7801,16 +8523,31 @@ func (x *PatchRequest_Body_Patch) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"sourceRange\":" - out.RawString(prefix[1:]) - x.SourceRange.MarshalEasyJSON(out) + if x.SourceRange != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"sourceRange\":" + out.RawString(prefix) + x.SourceRange.MarshalEasyJSON(out) + } } { - const prefix string = ",\"chunk\":" - out.RawString(prefix) - out.Base64Bytes(x.Chunk) + if len(x.Chunk) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"chunk\":" + out.RawString(prefix) + out.Base64Bytes(x.Chunk) + } } out.RawByte('}') } @@ -8014,33 +8751,62 @@ func (x *PatchRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"address\":" - out.RawString(prefix[1:]) - x.Address.MarshalEasyJSON(out) - } - { - const prefix string = ",\"newAttributes\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.NewAttributes { - if i != 0 { + if x.Address != nil { + if !first { out.RawByte(',') + } else { + first = false } - x.NewAttributes[i].MarshalEasyJSON(out) + const prefix string = "\"address\":" + out.RawString(prefix) + x.Address.MarshalEasyJSON(out) } - out.RawByte(']') } { - const prefix string = ",\"replaceAttributes\":" - out.RawString(prefix) - out.Bool(x.ReplaceAttributes) + if len(x.NewAttributes) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"newAttributes\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.NewAttributes { + if i != 0 { + out.RawByte(',') + } + x.NewAttributes[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } } { - const prefix string = ",\"patch\":" - out.RawString(prefix) - x.Patch.MarshalEasyJSON(out) + if x.ReplaceAttributes { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"replaceAttributes\":" + out.RawString(prefix) + out.Bool(x.ReplaceAttributes) + } + } + { + if x.Patch != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"patch\":" + out.RawString(prefix) + x.Patch.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -8260,21 +9026,43 @@ func (x *PatchRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -8417,11 +9205,19 @@ func (x *PatchResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"objectId\":" - out.RawString(prefix[1:]) - x.ObjectId.MarshalEasyJSON(out) + if x.ObjectId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"objectId\":" + out.RawString(prefix) + x.ObjectId.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -8614,21 +9410,43 @@ func (x *PatchResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } diff --git a/object/grpc/types_frostfs.pb.go b/object/grpc/types_frostfs.pb.go index 9fc2769..5b1eb2c 100644 --- a/object/grpc/types_frostfs.pb.go +++ b/object/grpc/types_frostfs.pb.go @@ -304,46 +304,96 @@ func (x *ShortHeader) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"version\":" - out.RawString(prefix[1:]) - x.Version.MarshalEasyJSON(out) - } - { - const prefix string = ",\"creationEpoch\":" - out.RawString(prefix) - out.Uint64(x.CreationEpoch) - } - { - const prefix string = ",\"ownerID\":" - out.RawString(prefix) - x.OwnerId.MarshalEasyJSON(out) - } - { - const prefix string = ",\"objectType\":" - out.RawString(prefix) - v := int32(x.ObjectType) - if vv, ok := ObjectType_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.Version != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"version\":" + out.RawString(prefix) + x.Version.MarshalEasyJSON(out) } } { - const prefix string = ",\"payloadLength\":" - out.RawString(prefix) - out.Uint64(x.PayloadLength) + if x.CreationEpoch != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"creationEpoch\":" + out.RawString(prefix) + out.Uint64(x.CreationEpoch) + } } { - const prefix string = ",\"payloadHash\":" - out.RawString(prefix) - x.PayloadHash.MarshalEasyJSON(out) + if x.OwnerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ownerID\":" + out.RawString(prefix) + x.OwnerId.MarshalEasyJSON(out) + } } { - const prefix string = ",\"homomorphicHash\":" - out.RawString(prefix) - x.HomomorphicHash.MarshalEasyJSON(out) + if x.ObjectType != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"objectType\":" + out.RawString(prefix) + v := int32(x.ObjectType) + if vv, ok := ObjectType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } + } + } + { + if x.PayloadLength != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"payloadLength\":" + out.RawString(prefix) + out.Uint64(x.PayloadLength) + } + } + { + if x.PayloadHash != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"payloadHash\":" + out.RawString(prefix) + x.PayloadHash.MarshalEasyJSON(out) + } + } + { + if x.HomomorphicHash != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"homomorphicHash\":" + out.RawString(prefix) + x.HomomorphicHash.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -544,16 +594,31 @@ func (x *Header_Attribute) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"key\":" - out.RawString(prefix[1:]) - out.String(x.Key) + if len(x.Key) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } } { - const prefix string = ",\"value\":" - out.RawString(prefix) - out.String(x.Value) + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.String(x.Value) + } } out.RawByte('}') } @@ -802,43 +867,86 @@ func (x *Header_Split) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"parent\":" - out.RawString(prefix[1:]) - x.Parent.MarshalEasyJSON(out) - } - { - const prefix string = ",\"previous\":" - out.RawString(prefix) - x.Previous.MarshalEasyJSON(out) - } - { - const prefix string = ",\"parentSignature\":" - out.RawString(prefix) - x.ParentSignature.MarshalEasyJSON(out) - } - { - const prefix string = ",\"parentHeader\":" - out.RawString(prefix) - x.ParentHeader.MarshalEasyJSON(out) - } - { - const prefix string = ",\"children\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Children { - if i != 0 { + if x.Parent != nil { + if !first { out.RawByte(',') + } else { + first = false } - x.Children[i].MarshalEasyJSON(out) + const prefix string = "\"parent\":" + out.RawString(prefix) + x.Parent.MarshalEasyJSON(out) } - out.RawByte(']') } { - const prefix string = ",\"splitID\":" - out.RawString(prefix) - out.Base64Bytes(x.SplitId) + if x.Previous != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"previous\":" + out.RawString(prefix) + x.Previous.MarshalEasyJSON(out) + } + } + { + if x.ParentSignature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentSignature\":" + out.RawString(prefix) + x.ParentSignature.MarshalEasyJSON(out) + } + } + { + if x.ParentHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentHeader\":" + out.RawString(prefix) + x.ParentHeader.MarshalEasyJSON(out) + } + } + { + if len(x.Children) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"children\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Children { + if i != 0 { + out.RawByte(',') + } + x.Children[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + { + if len(x.SplitId) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"splitID\":" + out.RawString(prefix) + out.Base64Bytes(x.SplitId) + } } out.RawByte('}') } @@ -1157,53 +1265,110 @@ func (x *Header_EC) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"parent\":" - out.RawString(prefix[1:]) - x.Parent.MarshalEasyJSON(out) - } - { - const prefix string = ",\"index\":" - out.RawString(prefix) - out.Uint32(x.Index) - } - { - const prefix string = ",\"total\":" - out.RawString(prefix) - out.Uint32(x.Total) - } - { - const prefix string = ",\"headerLength\":" - out.RawString(prefix) - out.Uint32(x.HeaderLength) - } - { - const prefix string = ",\"header\":" - out.RawString(prefix) - out.Base64Bytes(x.Header) - } - { - const prefix string = ",\"parentSplitID\":" - out.RawString(prefix) - out.Base64Bytes(x.ParentSplitId) - } - { - const prefix string = ",\"parentSplitParentID\":" - out.RawString(prefix) - x.ParentSplitParentId.MarshalEasyJSON(out) - } - { - const prefix string = ",\"parentAttributes\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.ParentAttributes { - if i != 0 { + if x.Parent != nil { + if !first { out.RawByte(',') + } else { + first = false } - x.ParentAttributes[i].MarshalEasyJSON(out) + const prefix string = "\"parent\":" + out.RawString(prefix) + x.Parent.MarshalEasyJSON(out) + } + } + { + if x.Index != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"index\":" + out.RawString(prefix) + out.Uint32(x.Index) + } + } + { + if x.Total != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"total\":" + out.RawString(prefix) + out.Uint32(x.Total) + } + } + { + if x.HeaderLength != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"headerLength\":" + out.RawString(prefix) + out.Uint32(x.HeaderLength) + } + } + { + if len(x.Header) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"header\":" + out.RawString(prefix) + out.Base64Bytes(x.Header) + } + } + { + if len(x.ParentSplitId) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentSplitID\":" + out.RawString(prefix) + out.Base64Bytes(x.ParentSplitId) + } + } + { + if x.ParentSplitParentId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentSplitParentID\":" + out.RawString(prefix) + x.ParentSplitParentId.MarshalEasyJSON(out) + } + } + { + if len(x.ParentAttributes) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentAttributes\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.ParentAttributes { + if i != 0 { + out.RawByte(',') + } + x.ParentAttributes[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -1630,78 +1795,163 @@ func (x *Header) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"version\":" - out.RawString(prefix[1:]) - x.Version.MarshalEasyJSON(out) - } - { - const prefix string = ",\"containerID\":" - out.RawString(prefix) - x.ContainerId.MarshalEasyJSON(out) - } - { - const prefix string = ",\"ownerID\":" - out.RawString(prefix) - x.OwnerId.MarshalEasyJSON(out) - } - { - const prefix string = ",\"creationEpoch\":" - out.RawString(prefix) - out.Uint64(x.CreationEpoch) - } - { - const prefix string = ",\"payloadLength\":" - out.RawString(prefix) - out.Uint64(x.PayloadLength) - } - { - const prefix string = ",\"payloadHash\":" - out.RawString(prefix) - x.PayloadHash.MarshalEasyJSON(out) - } - { - const prefix string = ",\"objectType\":" - out.RawString(prefix) - v := int32(x.ObjectType) - if vv, ok := ObjectType_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) - } - } - { - const prefix string = ",\"homomorphicHash\":" - out.RawString(prefix) - x.HomomorphicHash.MarshalEasyJSON(out) - } - { - const prefix string = ",\"sessionToken\":" - out.RawString(prefix) - x.SessionToken.MarshalEasyJSON(out) - } - { - const prefix string = ",\"attributes\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Attributes { - if i != 0 { + if x.Version != nil { + if !first { out.RawByte(',') + } else { + first = false } - x.Attributes[i].MarshalEasyJSON(out) + const prefix string = "\"version\":" + out.RawString(prefix) + x.Version.MarshalEasyJSON(out) } - out.RawByte(']') } { - const prefix string = ",\"split\":" - out.RawString(prefix) - x.Split.MarshalEasyJSON(out) + if x.ContainerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerID\":" + out.RawString(prefix) + x.ContainerId.MarshalEasyJSON(out) + } } { - const prefix string = ",\"ec\":" - out.RawString(prefix) - x.Ec.MarshalEasyJSON(out) + if x.OwnerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ownerID\":" + out.RawString(prefix) + x.OwnerId.MarshalEasyJSON(out) + } + } + { + if x.CreationEpoch != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"creationEpoch\":" + out.RawString(prefix) + out.Uint64(x.CreationEpoch) + } + } + { + if x.PayloadLength != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"payloadLength\":" + out.RawString(prefix) + out.Uint64(x.PayloadLength) + } + } + { + if x.PayloadHash != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"payloadHash\":" + out.RawString(prefix) + x.PayloadHash.MarshalEasyJSON(out) + } + } + { + if x.ObjectType != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"objectType\":" + out.RawString(prefix) + v := int32(x.ObjectType) + if vv, ok := ObjectType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } + } + } + { + if x.HomomorphicHash != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"homomorphicHash\":" + out.RawString(prefix) + x.HomomorphicHash.MarshalEasyJSON(out) + } + } + { + if x.SessionToken != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"sessionToken\":" + out.RawString(prefix) + x.SessionToken.MarshalEasyJSON(out) + } + } + { + if len(x.Attributes) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"attributes\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Attributes { + if i != 0 { + out.RawByte(',') + } + x.Attributes[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + { + if x.Split != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"split\":" + out.RawString(prefix) + x.Split.MarshalEasyJSON(out) + } + } + { + if x.Ec != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ec\":" + out.RawString(prefix) + x.Ec.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1993,26 +2243,55 @@ func (x *Object) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"objectID\":" - out.RawString(prefix[1:]) - x.ObjectId.MarshalEasyJSON(out) + if x.ObjectId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"objectID\":" + out.RawString(prefix) + x.ObjectId.MarshalEasyJSON(out) + } } { - const prefix string = ",\"signature\":" - out.RawString(prefix) - x.Signature.MarshalEasyJSON(out) + if x.Signature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } } { - const prefix string = ",\"header\":" - out.RawString(prefix) - x.Header.MarshalEasyJSON(out) + if x.Header != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"header\":" + out.RawString(prefix) + x.Header.MarshalEasyJSON(out) + } } { - const prefix string = ",\"payload\":" - out.RawString(prefix) - out.Base64Bytes(x.Payload) + if len(x.Payload) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"payload\":" + out.RawString(prefix) + out.Base64Bytes(x.Payload) + } } out.RawByte('}') } @@ -2204,21 +2483,43 @@ func (x *SplitInfo) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"splitId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.SplitId) + if len(x.SplitId) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"splitId\":" + out.RawString(prefix) + out.Base64Bytes(x.SplitId) + } } { - const prefix string = ",\"lastPart\":" - out.RawString(prefix) - x.LastPart.MarshalEasyJSON(out) + if x.LastPart != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"lastPart\":" + out.RawString(prefix) + x.LastPart.MarshalEasyJSON(out) + } } { - const prefix string = ",\"link\":" - out.RawString(prefix) - x.Link.MarshalEasyJSON(out) + if x.Link != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"link\":" + out.RawString(prefix) + x.Link.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2400,21 +2701,43 @@ func (x *ECInfo_Chunk) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"id\":" - out.RawString(prefix[1:]) - x.Id.MarshalEasyJSON(out) + if x.Id != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"id\":" + out.RawString(prefix) + x.Id.MarshalEasyJSON(out) + } } { - const prefix string = ",\"index\":" - out.RawString(prefix) - out.Uint32(x.Index) + if x.Index != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"index\":" + out.RawString(prefix) + out.Uint32(x.Index) + } } { - const prefix string = ",\"total\":" - out.RawString(prefix) - out.Uint32(x.Total) + if x.Total != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"total\":" + out.RawString(prefix) + out.Uint32(x.Total) + } } out.RawByte('}') } @@ -2558,18 +2881,26 @@ func (x *ECInfo) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"chunks\":" - out.RawString(prefix[1:]) - out.RawByte('[') - for i := range x.Chunks { - if i != 0 { + if len(x.Chunks) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Chunks[i].MarshalEasyJSON(out) + const prefix string = "\"chunks\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Chunks { + if i != 0 { + out.RawByte(',') + } + x.Chunks[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } diff --git a/refs/grpc/types_frostfs.pb.go b/refs/grpc/types_frostfs.pb.go index 5f35eba..869620f 100644 --- a/refs/grpc/types_frostfs.pb.go +++ b/refs/grpc/types_frostfs.pb.go @@ -190,16 +190,31 @@ func (x *Address) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerID\":" - out.RawString(prefix[1:]) - x.ContainerId.MarshalEasyJSON(out) + if x.ContainerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerID\":" + out.RawString(prefix) + x.ContainerId.MarshalEasyJSON(out) + } } { - const prefix string = ",\"objectID\":" - out.RawString(prefix) - x.ObjectId.MarshalEasyJSON(out) + if x.ObjectId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"objectID\":" + out.RawString(prefix) + x.ObjectId.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -332,11 +347,19 @@ func (x *ObjectID) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"value\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.Value) + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.Base64Bytes(x.Value) + } } out.RawByte('}') } @@ -461,11 +484,19 @@ func (x *ContainerID) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"value\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.Value) + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.Base64Bytes(x.Value) + } } out.RawByte('}') } @@ -590,11 +621,19 @@ func (x *OwnerID) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"value\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.Value) + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.Base64Bytes(x.Value) + } } out.RawByte('}') } @@ -739,16 +778,31 @@ func (x *Version) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"major\":" - out.RawString(prefix[1:]) - out.Uint32(x.Major) + if x.Major != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"major\":" + out.RawString(prefix) + out.Uint32(x.Major) + } } { - const prefix string = ",\"minor\":" - out.RawString(prefix) - out.Uint32(x.Minor) + if x.Minor != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"minor\":" + out.RawString(prefix) + out.Uint32(x.Minor) + } } out.RawByte('}') } @@ -919,25 +973,47 @@ func (x *Signature) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"key\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.Key) + if len(x.Key) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.Base64Bytes(x.Key) + } } { - const prefix string = ",\"signature\":" - out.RawString(prefix) - out.Base64Bytes(x.Sign) + if len(x.Sign) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + out.Base64Bytes(x.Sign) + } } { - const prefix string = ",\"scheme\":" - out.RawString(prefix) - v := int32(x.Scheme) - if vv, ok := SignatureScheme_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.Scheme != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"scheme\":" + out.RawString(prefix) + v := int32(x.Scheme) + if vv, ok := SignatureScheme_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } out.RawByte('}') @@ -1111,16 +1187,31 @@ func (x *SignatureRFC6979) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"key\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.Key) + if len(x.Key) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.Base64Bytes(x.Key) + } } { - const prefix string = ",\"signature\":" - out.RawString(prefix) - out.Base64Bytes(x.Sign) + if len(x.Sign) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + out.Base64Bytes(x.Sign) + } } out.RawByte('}') } @@ -1271,21 +1362,36 @@ func (x *Checksum) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"type\":" - out.RawString(prefix[1:]) - v := int32(x.Type) - if vv, ok := ChecksumType_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.Type != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"type\":" + out.RawString(prefix) + v := int32(x.Type) + if vv, ok := ChecksumType_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } { - const prefix string = ",\"sum\":" - out.RawString(prefix) - out.Base64Bytes(x.Sum) + if len(x.Sum) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"sum\":" + out.RawString(prefix) + out.Base64Bytes(x.Sum) + } } out.RawByte('}') } diff --git a/session/grpc/service_frostfs.pb.go b/session/grpc/service_frostfs.pb.go index aa42ee8..a3f0111 100644 --- a/session/grpc/service_frostfs.pb.go +++ b/session/grpc/service_frostfs.pb.go @@ -117,16 +117,31 @@ func (x *CreateRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"ownerId\":" - out.RawString(prefix[1:]) - x.OwnerId.MarshalEasyJSON(out) + if x.OwnerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ownerId\":" + out.RawString(prefix) + x.OwnerId.MarshalEasyJSON(out) + } } { - const prefix string = ",\"expiration\":" - out.RawString(prefix) - out.Uint64(x.Expiration) + if x.Expiration != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"expiration\":" + out.RawString(prefix) + out.Uint64(x.Expiration) + } } out.RawByte('}') } @@ -325,21 +340,43 @@ func (x *CreateRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -499,16 +536,31 @@ func (x *CreateResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"id\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.Id) + if len(x.Id) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"id\":" + out.RawString(prefix) + out.Base64Bytes(x.Id) + } } { - const prefix string = ",\"sessionKey\":" - out.RawString(prefix) - out.Base64Bytes(x.SessionKey) + if len(x.SessionKey) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"sessionKey\":" + out.RawString(prefix) + out.Base64Bytes(x.SessionKey) + } } out.RawByte('}') } @@ -706,21 +758,43 @@ func (x *CreateResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaHeader\":" - out.RawString(prefix) - x.MetaHeader.MarshalEasyJSON(out) + if x.MetaHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaHeader\":" + out.RawString(prefix) + x.MetaHeader.MarshalEasyJSON(out) + } } { - const prefix string = ",\"verifyHeader\":" - out.RawString(prefix) - x.VerifyHeader.MarshalEasyJSON(out) + if x.VerifyHeader != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verifyHeader\":" + out.RawString(prefix) + x.VerifyHeader.MarshalEasyJSON(out) + } } out.RawByte('}') } diff --git a/session/grpc/types_frostfs.pb.go b/session/grpc/types_frostfs.pb.go index c92ab28..58807fe 100644 --- a/session/grpc/types_frostfs.pb.go +++ b/session/grpc/types_frostfs.pb.go @@ -179,23 +179,38 @@ func (x *ObjectSessionContext_Target) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"container\":" - out.RawString(prefix[1:]) - x.Container.MarshalEasyJSON(out) + if x.Container != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"container\":" + out.RawString(prefix) + x.Container.MarshalEasyJSON(out) + } } { - const prefix string = ",\"objects\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Objects { - if i != 0 { + if len(x.Objects) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Objects[i].MarshalEasyJSON(out) + const prefix string = "\"objects\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Objects { + if i != 0 { + out.RawByte(',') + } + x.Objects[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } @@ -358,21 +373,36 @@ func (x *ObjectSessionContext) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"verb\":" - out.RawString(prefix[1:]) - v := int32(x.Verb) - if vv, ok := ObjectSessionContext_Verb_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.Verb != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verb\":" + out.RawString(prefix) + v := int32(x.Verb) + if vv, ok := ObjectSessionContext_Verb_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } { - const prefix string = ",\"target\":" - out.RawString(prefix) - x.Target.MarshalEasyJSON(out) + if x.Target != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"target\":" + out.RawString(prefix) + x.Target.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -601,26 +631,48 @@ func (x *ContainerSessionContext) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"verb\":" - out.RawString(prefix[1:]) - v := int32(x.Verb) - if vv, ok := ContainerSessionContext_Verb_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.Verb != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"verb\":" + out.RawString(prefix) + v := int32(x.Verb) + if vv, ok := ContainerSessionContext_Verb_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } { - const prefix string = ",\"wildcard\":" - out.RawString(prefix) - out.Bool(x.Wildcard) + if x.Wildcard { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"wildcard\":" + out.RawString(prefix) + out.Bool(x.Wildcard) + } } { - const prefix string = ",\"containerID\":" - out.RawString(prefix) - x.ContainerId.MarshalEasyJSON(out) + if x.ContainerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerID\":" + out.RawString(prefix) + x.ContainerId.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -814,21 +866,43 @@ func (x *SessionToken_Body_TokenLifetime) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"exp\":" - out.RawString(prefix[1:]) - out.Uint64(x.Exp) + if x.Exp != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"exp\":" + out.RawString(prefix) + out.Uint64(x.Exp) + } } { - const prefix string = ",\"nbf\":" - out.RawString(prefix) - out.Uint64(x.Nbf) + if x.Nbf != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nbf\":" + out.RawString(prefix) + out.Uint64(x.Nbf) + } } { - const prefix string = ",\"iat\":" - out.RawString(prefix) - out.Uint64(x.Iat) + if x.Iat != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"iat\":" + out.RawString(prefix) + out.Uint64(x.Iat) + } } out.RawByte('}') } @@ -1095,39 +1169,82 @@ func (x *SessionToken_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"id\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.Id) + if len(x.Id) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"id\":" + out.RawString(prefix) + out.Base64Bytes(x.Id) + } } { - const prefix string = ",\"ownerID\":" - out.RawString(prefix) - x.OwnerId.MarshalEasyJSON(out) + if x.OwnerId != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ownerID\":" + out.RawString(prefix) + x.OwnerId.MarshalEasyJSON(out) + } } { - const prefix string = ",\"lifetime\":" - out.RawString(prefix) - x.Lifetime.MarshalEasyJSON(out) + if x.Lifetime != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"lifetime\":" + out.RawString(prefix) + x.Lifetime.MarshalEasyJSON(out) + } } { - const prefix string = ",\"sessionKey\":" - out.RawString(prefix) - out.Base64Bytes(x.SessionKey) + if len(x.SessionKey) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"sessionKey\":" + out.RawString(prefix) + out.Base64Bytes(x.SessionKey) + } } switch xx := x.Context.(type) { case *SessionToken_Body_Object: { - const prefix string = ",\"object\":" - out.RawString(prefix) - xx.Object.MarshalEasyJSON(out) + if xx.Object != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"object\":" + out.RawString(prefix) + xx.Object.MarshalEasyJSON(out) + } } case *SessionToken_Body_Container: { - const prefix string = ",\"container\":" - out.RawString(prefix) - xx.Container.MarshalEasyJSON(out) + if xx.Container != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"container\":" + out.RawString(prefix) + xx.Container.MarshalEasyJSON(out) + } } } out.RawByte('}') @@ -1333,16 +1450,31 @@ func (x *SessionToken) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - x.Body.MarshalEasyJSON(out) + if x.Body != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } } { - const prefix string = ",\"signature\":" - out.RawString(prefix) - x.Signature.MarshalEasyJSON(out) + if x.Signature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -1495,16 +1627,31 @@ func (x *XHeader) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"key\":" - out.RawString(prefix[1:]) - out.String(x.Key) + if len(x.Key) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } } { - const prefix string = ",\"value\":" - out.RawString(prefix) - out.String(x.Value) + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.String(x.Value) + } } out.RawByte('}') } @@ -1793,53 +1940,110 @@ func (x *RequestMetaHeader) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"version\":" - out.RawString(prefix[1:]) - x.Version.MarshalEasyJSON(out) - } - { - const prefix string = ",\"epoch\":" - out.RawString(prefix) - out.Uint64(x.Epoch) - } - { - const prefix string = ",\"ttl\":" - out.RawString(prefix) - out.Uint32(x.Ttl) - } - { - const prefix string = ",\"xHeaders\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.XHeaders { - if i != 0 { + if x.Version != nil { + if !first { out.RawByte(',') + } else { + first = false } - x.XHeaders[i].MarshalEasyJSON(out) + const prefix string = "\"version\":" + out.RawString(prefix) + x.Version.MarshalEasyJSON(out) } - out.RawByte(']') } { - const prefix string = ",\"sessionToken\":" - out.RawString(prefix) - x.SessionToken.MarshalEasyJSON(out) + if x.Epoch != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"epoch\":" + out.RawString(prefix) + out.Uint64(x.Epoch) + } } { - const prefix string = ",\"bearerToken\":" - out.RawString(prefix) - x.BearerToken.MarshalEasyJSON(out) + if x.Ttl != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ttl\":" + out.RawString(prefix) + out.Uint32(x.Ttl) + } } { - const prefix string = ",\"origin\":" - out.RawString(prefix) - x.Origin.MarshalEasyJSON(out) + if len(x.XHeaders) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"xHeaders\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.XHeaders { + if i != 0 { + out.RawByte(',') + } + x.XHeaders[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } } { - const prefix string = ",\"magicNumber\":" - out.RawString(prefix) - out.Uint64(x.MagicNumber) + if x.SessionToken != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"sessionToken\":" + out.RawString(prefix) + x.SessionToken.MarshalEasyJSON(out) + } + } + { + if x.BearerToken != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bearerToken\":" + out.RawString(prefix) + x.BearerToken.MarshalEasyJSON(out) + } + } + { + if x.Origin != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"origin\":" + out.RawString(prefix) + x.Origin.MarshalEasyJSON(out) + } + } + { + if x.MagicNumber != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"magicNumber\":" + out.RawString(prefix) + out.Uint64(x.MagicNumber) + } } out.RawByte('}') } @@ -2133,43 +2337,86 @@ func (x *ResponseMetaHeader) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"version\":" - out.RawString(prefix[1:]) - x.Version.MarshalEasyJSON(out) - } - { - const prefix string = ",\"epoch\":" - out.RawString(prefix) - out.Uint64(x.Epoch) - } - { - const prefix string = ",\"ttl\":" - out.RawString(prefix) - out.Uint32(x.Ttl) - } - { - const prefix string = ",\"xHeaders\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.XHeaders { - if i != 0 { + if x.Version != nil { + if !first { out.RawByte(',') + } else { + first = false } - x.XHeaders[i].MarshalEasyJSON(out) + const prefix string = "\"version\":" + out.RawString(prefix) + x.Version.MarshalEasyJSON(out) } - out.RawByte(']') } { - const prefix string = ",\"origin\":" - out.RawString(prefix) - x.Origin.MarshalEasyJSON(out) + if x.Epoch != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"epoch\":" + out.RawString(prefix) + out.Uint64(x.Epoch) + } } { - const prefix string = ",\"status\":" - out.RawString(prefix) - x.Status.MarshalEasyJSON(out) + if x.Ttl != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ttl\":" + out.RawString(prefix) + out.Uint32(x.Ttl) + } + } + { + if len(x.XHeaders) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"xHeaders\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.XHeaders { + if i != 0 { + out.RawByte(',') + } + x.XHeaders[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + { + if x.Origin != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"origin\":" + out.RawString(prefix) + x.Origin.MarshalEasyJSON(out) + } + } + { + if x.Status != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"status\":" + out.RawString(prefix) + x.Status.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2407,26 +2654,55 @@ func (x *RequestVerificationHeader) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"bodySignature\":" - out.RawString(prefix[1:]) - x.BodySignature.MarshalEasyJSON(out) + if x.BodySignature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bodySignature\":" + out.RawString(prefix) + x.BodySignature.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaSignature\":" - out.RawString(prefix) - x.MetaSignature.MarshalEasyJSON(out) + if x.MetaSignature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaSignature\":" + out.RawString(prefix) + x.MetaSignature.MarshalEasyJSON(out) + } } { - const prefix string = ",\"originSignature\":" - out.RawString(prefix) - x.OriginSignature.MarshalEasyJSON(out) + if x.OriginSignature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"originSignature\":" + out.RawString(prefix) + x.OriginSignature.MarshalEasyJSON(out) + } } { - const prefix string = ",\"origin\":" - out.RawString(prefix) - x.Origin.MarshalEasyJSON(out) + if x.Origin != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"origin\":" + out.RawString(prefix) + x.Origin.MarshalEasyJSON(out) + } } out.RawByte('}') } @@ -2645,26 +2921,55 @@ func (x *ResponseVerificationHeader) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"bodySignature\":" - out.RawString(prefix[1:]) - x.BodySignature.MarshalEasyJSON(out) + if x.BodySignature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bodySignature\":" + out.RawString(prefix) + x.BodySignature.MarshalEasyJSON(out) + } } { - const prefix string = ",\"metaSignature\":" - out.RawString(prefix) - x.MetaSignature.MarshalEasyJSON(out) + if x.MetaSignature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"metaSignature\":" + out.RawString(prefix) + x.MetaSignature.MarshalEasyJSON(out) + } } { - const prefix string = ",\"originSignature\":" - out.RawString(prefix) - x.OriginSignature.MarshalEasyJSON(out) + if x.OriginSignature != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"originSignature\":" + out.RawString(prefix) + x.OriginSignature.MarshalEasyJSON(out) + } } { - const prefix string = ",\"origin\":" - out.RawString(prefix) - x.Origin.MarshalEasyJSON(out) + if x.Origin != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"origin\":" + out.RawString(prefix) + x.Origin.MarshalEasyJSON(out) + } } out.RawByte('}') } diff --git a/status/grpc/types_frostfs.pb.go b/status/grpc/types_frostfs.pb.go index 29dfebe..7581dbe 100644 --- a/status/grpc/types_frostfs.pb.go +++ b/status/grpc/types_frostfs.pb.go @@ -368,16 +368,31 @@ func (x *Status_Detail) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"id\":" - out.RawString(prefix[1:]) - out.Uint32(x.Id) + if x.Id != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"id\":" + out.RawString(prefix) + out.Uint32(x.Id) + } } { - const prefix string = ",\"value\":" - out.RawString(prefix) - out.Base64Bytes(x.Value) + if len(x.Value) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" + out.RawString(prefix) + out.Base64Bytes(x.Value) + } } out.RawByte('}') } @@ -554,28 +569,50 @@ func (x *Status) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"code\":" - out.RawString(prefix[1:]) - out.Uint32(x.Code) - } - { - const prefix string = ",\"message\":" - out.RawString(prefix) - out.String(x.Message) - } - { - const prefix string = ",\"details\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Details { - if i != 0 { + if x.Code != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Details[i].MarshalEasyJSON(out) + const prefix string = "\"code\":" + out.RawString(prefix) + out.Uint32(x.Code) + } + } + { + if len(x.Message) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"message\":" + out.RawString(prefix) + out.String(x.Message) + } + } + { + if len(x.Details) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"details\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Details { + if i != 0 { + out.RawByte(',') + } + x.Details[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } diff --git a/tombstone/grpc/types_frostfs.pb.go b/tombstone/grpc/types_frostfs.pb.go index f7bc48c..79afdfc 100644 --- a/tombstone/grpc/types_frostfs.pb.go +++ b/tombstone/grpc/types_frostfs.pb.go @@ -140,28 +140,50 @@ func (x *Tombstone) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"expirationEpoch\":" - out.RawString(prefix[1:]) - out.Uint64(x.ExpirationEpoch) - } - { - const prefix string = ",\"splitID\":" - out.RawString(prefix) - out.Base64Bytes(x.SplitId) - } - { - const prefix string = ",\"members\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.Members { - if i != 0 { + if x.ExpirationEpoch != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.Members[i].MarshalEasyJSON(out) + const prefix string = "\"expirationEpoch\":" + out.RawString(prefix) + out.Uint64(x.ExpirationEpoch) + } + } + { + if len(x.SplitId) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"splitID\":" + out.RawString(prefix) + out.Base64Bytes(x.SplitId) + } + } + { + if len(x.Members) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"members\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Members { + if i != 0 { + out.RawByte(',') + } + x.Members[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } diff --git a/util/proto/test/custom/test_frostfs.pb.go b/util/proto/test/custom/test_frostfs.pb.go index 005d6d1..03f3ece 100644 --- a/util/proto/test/custom/test_frostfs.pb.go +++ b/util/proto/test/custom/test_frostfs.pb.go @@ -130,11 +130,19 @@ func (x *Primitives_Aux) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"innerField\":" - out.RawString(prefix[1:]) - out.Uint32(x.InnerField) + if x.InnerField != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"innerField\":" + out.RawString(prefix) + out.Uint32(x.InnerField) + } } out.RawByte('}') } @@ -560,85 +568,184 @@ func (x *Primitives) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"fieldA\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.FieldA) + if len(x.FieldA) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldA\":" + out.RawString(prefix) + out.Base64Bytes(x.FieldA) + } } { - const prefix string = ",\"fieldB\":" - out.RawString(prefix) - out.String(x.FieldB) + if len(x.FieldB) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldB\":" + out.RawString(prefix) + out.String(x.FieldB) + } } { - const prefix string = ",\"fieldC\":" - out.RawString(prefix) - out.Bool(x.FieldC) + if x.FieldC { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldC\":" + out.RawString(prefix) + out.Bool(x.FieldC) + } } { - const prefix string = ",\"fieldD\":" - out.RawString(prefix) - out.Int32(x.FieldD) + if x.FieldD != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldD\":" + out.RawString(prefix) + out.Int32(x.FieldD) + } } { - const prefix string = ",\"fieldE\":" - out.RawString(prefix) - out.Uint32(x.FieldE) + if x.FieldE != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldE\":" + out.RawString(prefix) + out.Uint32(x.FieldE) + } } { - const prefix string = ",\"fieldF\":" - out.RawString(prefix) - out.Int64(x.FieldF) + if x.FieldF != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldF\":" + out.RawString(prefix) + out.Int64(x.FieldF) + } } { - const prefix string = ",\"fieldG\":" - out.RawString(prefix) - out.Uint64(x.FieldG) + if x.FieldG != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldG\":" + out.RawString(prefix) + out.Uint64(x.FieldG) + } } { - const prefix string = ",\"fieldI\":" - out.RawString(prefix) - out.Uint64(x.FieldI) + if x.FieldI != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldI\":" + out.RawString(prefix) + out.Uint64(x.FieldI) + } } { - const prefix string = ",\"fieldJ\":" - out.RawString(prefix) - out.Float64(x.FieldJ) + if x.FieldJ != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldJ\":" + out.RawString(prefix) + out.Float64(x.FieldJ) + } } { - const prefix string = ",\"fieldK\":" - out.RawString(prefix) - out.Uint32(x.FieldK) + if x.FieldK != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldK\":" + out.RawString(prefix) + out.Uint32(x.FieldK) + } } { - const prefix string = ",\"fieldH\":" - out.RawString(prefix) - v := int32(x.FieldH) - if vv, ok := Primitives_SomeEnum_name[v]; ok { - out.String(vv) - } else { - out.Int32(v) + if x.FieldH != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldH\":" + out.RawString(prefix) + v := int32(x.FieldH) + if vv, ok := Primitives_SomeEnum_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } } switch xx := x.FieldM.(type) { case *Primitives_FieldMa: { - const prefix string = ",\"fieldMa\":" - out.RawString(prefix) - out.Base64Bytes(xx.FieldMa) + if len(xx.FieldMa) != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldMa\":" + out.RawString(prefix) + out.Base64Bytes(xx.FieldMa) + } } case *Primitives_FieldMe: { - const prefix string = ",\"fieldMe\":" - out.RawString(prefix) - out.Uint32(xx.FieldMe) + if xx.FieldMe != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldMe\":" + out.RawString(prefix) + out.Uint32(xx.FieldMe) + } } case *Primitives_FieldAux: { - const prefix string = ",\"fieldAux\":" - out.RawString(prefix) - xx.FieldAux.MarshalEasyJSON(out) + if xx.FieldAux != nil { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"fieldAux\":" + out.RawString(prefix) + xx.FieldAux.MarshalEasyJSON(out) + } } } out.RawByte('}') @@ -887,11 +994,19 @@ func (x *RepPrimitives_Aux) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"innerField\":" - out.RawString(prefix[1:]) - out.Uint32(x.InnerField) + if x.InnerField != 0 { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"innerField\":" + out.RawString(prefix) + out.Uint32(x.InnerField) + } } out.RawByte('}') } @@ -1169,102 +1284,159 @@ func (x *RepPrimitives) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"fieldA\":" - out.RawString(prefix[1:]) - out.RawByte('[') - for i := range x.FieldA { - if i != 0 { + if len(x.FieldA) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.Base64Bytes(x.FieldA[i]) + const prefix string = "\"fieldA\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.FieldA { + if i != 0 { + out.RawByte(',') + } + out.Base64Bytes(x.FieldA[i]) + } + out.RawByte(']') } - out.RawByte(']') } { - const prefix string = ",\"fieldB\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.FieldB { - if i != 0 { + if len(x.FieldB) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.String(x.FieldB[i]) + const prefix string = "\"fieldB\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.FieldB { + if i != 0 { + out.RawByte(',') + } + out.String(x.FieldB[i]) + } + out.RawByte(']') } - out.RawByte(']') } { - const prefix string = ",\"fieldC\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.FieldC { - if i != 0 { + if len(x.FieldC) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.Int32(x.FieldC[i]) + const prefix string = "\"fieldC\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.FieldC { + if i != 0 { + out.RawByte(',') + } + out.Int32(x.FieldC[i]) + } + out.RawByte(']') } - out.RawByte(']') } { - const prefix string = ",\"fieldD\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.FieldD { - if i != 0 { + if len(x.FieldD) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.Uint32(x.FieldD[i]) + const prefix string = "\"fieldD\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.FieldD { + if i != 0 { + out.RawByte(',') + } + out.Uint32(x.FieldD[i]) + } + out.RawByte(']') } - out.RawByte(']') } { - const prefix string = ",\"fieldE\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.FieldE { - if i != 0 { + if len(x.FieldE) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.Int64(x.FieldE[i]) + const prefix string = "\"fieldE\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.FieldE { + if i != 0 { + out.RawByte(',') + } + out.Int64(x.FieldE[i]) + } + out.RawByte(']') } - out.RawByte(']') } { - const prefix string = ",\"fieldF\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.FieldF { - if i != 0 { + if len(x.FieldF) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.Uint64(x.FieldF[i]) + const prefix string = "\"fieldF\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.FieldF { + if i != 0 { + out.RawByte(',') + } + out.Uint64(x.FieldF[i]) + } + out.RawByte(']') } - out.RawByte(']') } { - const prefix string = ",\"fieldFu\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.FieldFu { - if i != 0 { + if len(x.FieldFu) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - out.Uint64(x.FieldFu[i]) + const prefix string = "\"fieldFu\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.FieldFu { + if i != 0 { + out.RawByte(',') + } + out.Uint64(x.FieldFu[i]) + } + out.RawByte(']') } - out.RawByte(']') } { - const prefix string = ",\"fieldAux\":" - out.RawString(prefix) - out.RawByte('[') - for i := range x.FieldAux { - if i != 0 { + if len(x.FieldAux) != 0 { + if !first { out.RawByte(',') + } else { + first = false } - x.FieldAux[i].MarshalEasyJSON(out) + const prefix string = "\"fieldAux\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.FieldAux { + if i != 0 { + out.RawByte(',') + } + x.FieldAux[i].MarshalEasyJSON(out) + } + out.RawByte(']') } - out.RawByte(']') } out.RawByte('}') } diff --git a/util/protogen/internalgengo/json.go b/util/protogen/internalgengo/json.go index 95a06d5..ec70155 100644 --- a/util/protogen/internalgengo/json.go +++ b/util/protogen/internalgengo/json.go @@ -147,8 +147,11 @@ func emitJSONMarshal(g *protogen.GeneratedFile, msg *protogen.Message) { g.P("func (x *", msg.GoIdent.GoName, ") MarshalEasyJSON(out *", jwriterPackage.Ident("Writer"), ") {") g.P(`if x == nil { out.RawString("null"); return }`) + if len(msg.Fields) != 0 { + g.P("first := true") + } g.P("out.RawByte('{')") - for i, f := range msg.Fields { + for _, f := range msg.Fields { if f.Oneof != nil { if f.Oneof.Fields[0] != f { continue @@ -157,29 +160,35 @@ func emitJSONMarshal(g *protogen.GeneratedFile, msg *protogen.Message) { g.P("switch xx := x.", f.Oneof.GoName, ".(type) {") for _, ff := range f.Oneof.Fields { g.P("case *", ff.GoIdent, ":") - emitJSONFieldWrite(g, ff, "xx", i == 0) + emitJSONFieldWrite(g, ff, "xx") } g.P("}") continue } - emitJSONFieldWrite(g, f, "x", i == 0) + emitJSONFieldWrite(g, f, "x") } g.P("out.RawByte('}')") g.P("}") } -func emitJSONFieldWrite(g *protogen.GeneratedFile, f *protogen.Field, name string, first bool) { +func emitJSONFieldWrite(g *protogen.GeneratedFile, f *protogen.Field, name string) { g.P("{") defer g.P("}") - g.P("const prefix string = ", `",\"`, fieldJSONName(f), `\":"`) - if first { - g.P("out.RawString(prefix[1:])") - } else { - g.P("out.RawString(prefix)") - } - selector := name + "." + f.GoName + + isNotDefault := notNil + if f.Desc.IsList() { + isNotDefault = notEmpty + } else if f.Desc.Kind() != protoreflect.MessageKind { + _, isNotDefault = easyprotoKindInfo(f.Desc.Kind()) + } + g.P("if ", isNotDefault(selector), "{") + defer g.P("}") + + g.P("if !first { out.RawByte(','); } else { first = false; }") + g.P("const prefix string = ", `"\"`, fieldJSONName(f), `\":"`) + g.P("out.RawString(prefix)") if f.Desc.IsList() { selector += "[i]" g.P("out.RawByte('[')") -- 2.45.3 From d94b9c6d0d6030e551a58ae260d943290fd8e38e Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 1 Oct 2024 13:50:27 +0300 Subject: [PATCH 5/7] [#120] protogen: Unmarshal stringified integers from JSON Signed-off-by: Evgenii Stratonikov --- accounting/grpc/types_frostfs.pb.go | 21 +++- acl/grpc/types_frostfs.pb.go | 30 ++++- container/grpc/types_frostfs.pb.go | 11 +- netmap/grpc/types_frostfs.pb.go | 90 ++++++++++++-- object/grpc/service_frostfs.pb.go | 50 +++++++- object/grpc/types_frostfs.pb.go | 90 ++++++++++++-- refs/grpc/types_frostfs.pb.go | 20 +++- session/grpc/service_frostfs.pb.go | 11 +- session/grpc/types_frostfs.pb.go | 80 +++++++++++-- status/grpc/types_frostfs.pb.go | 20 +++- tombstone/grpc/types_frostfs.pb.go | 11 +- util/proto/test/custom/test_frostfs.pb.go | 140 +++++++++++++++++++--- util/protogen/internalgengo/json.go | 23 +++- 13 files changed, 536 insertions(+), 61 deletions(-) diff --git a/accounting/grpc/types_frostfs.pb.go b/accounting/grpc/types_frostfs.pb.go index 0ae770b..438cd03 100644 --- a/accounting/grpc/types_frostfs.pb.go +++ b/accounting/grpc/types_frostfs.pb.go @@ -11,6 +11,7 @@ import ( easyproto "github.com/VictoriaMetrics/easyproto" jlexer "github.com/mailru/easyjson/jlexer" jwriter "github.com/mailru/easyjson/jwriter" + strconv "strconv" ) type Decimal struct { @@ -170,13 +171,29 @@ func (x *Decimal) UnmarshalEasyJSON(in *jlexer.Lexer) { case "value": { var f int64 - f = in.Int64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseInt(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := int64(v) + f = pv x.Value = f } case "precision": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Precision = f } } diff --git a/acl/grpc/types_frostfs.pb.go b/acl/grpc/types_frostfs.pb.go index 57e1682..6ebaf63 100644 --- a/acl/grpc/types_frostfs.pb.go +++ b/acl/grpc/types_frostfs.pb.go @@ -1481,19 +1481,43 @@ func (x *BearerToken_Body_TokenLifetime) UnmarshalEasyJSON(in *jlexer.Lexer) { case "exp": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Exp = f } case "nbf": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Nbf = f } case "iat": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Iat = f } } diff --git a/container/grpc/types_frostfs.pb.go b/container/grpc/types_frostfs.pb.go index 9db07ed..e5da35f 100644 --- a/container/grpc/types_frostfs.pb.go +++ b/container/grpc/types_frostfs.pb.go @@ -13,6 +13,7 @@ import ( easyproto "github.com/VictoriaMetrics/easyproto" jlexer "github.com/mailru/easyjson/jlexer" jwriter "github.com/mailru/easyjson/jwriter" + strconv "strconv" ) type Container_Attribute struct { @@ -517,7 +518,15 @@ func (x *Container) UnmarshalEasyJSON(in *jlexer.Lexer) { case "basicACL": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.BasicAcl = f } case "attributes": diff --git a/netmap/grpc/types_frostfs.pb.go b/netmap/grpc/types_frostfs.pb.go index d082910..24b7575 100644 --- a/netmap/grpc/types_frostfs.pb.go +++ b/netmap/grpc/types_frostfs.pb.go @@ -703,7 +703,15 @@ func (x *Selector) UnmarshalEasyJSON(in *jlexer.Lexer) { case "count": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Count = f } case "clause": @@ -970,7 +978,15 @@ func (x *Replica) UnmarshalEasyJSON(in *jlexer.Lexer) { case "count": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Count = f } case "selector": @@ -982,13 +998,29 @@ func (x *Replica) UnmarshalEasyJSON(in *jlexer.Lexer) { case "ecDataCount": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.EcDataCount = f } case "ecParityCount": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.EcParityCount = f } } @@ -1306,7 +1338,15 @@ func (x *PlacementPolicy) UnmarshalEasyJSON(in *jlexer.Lexer) { case "containerBackupFactor": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.ContainerBackupFactor = f } case "selectors": @@ -2094,7 +2134,15 @@ func (x *Netmap) UnmarshalEasyJSON(in *jlexer.Lexer) { case "epoch": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Epoch = f } case "nodes": @@ -2677,19 +2725,43 @@ func (x *NetworkInfo) UnmarshalEasyJSON(in *jlexer.Lexer) { case "currentEpoch": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.CurrentEpoch = f } case "magicNumber": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.MagicNumber = f } case "msPerBlock": { var f int64 - f = in.Int64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseInt(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := int64(v) + f = pv x.MsPerBlock = f } case "networkConfig": diff --git a/object/grpc/service_frostfs.pb.go b/object/grpc/service_frostfs.pb.go index 2434bd3..0130ee3 100644 --- a/object/grpc/service_frostfs.pb.go +++ b/object/grpc/service_frostfs.pb.go @@ -1508,7 +1508,15 @@ func (x *PutRequest_Body_Init) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []uint32 in.Delim('[') for !in.IsDelim(']') { - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv list = append(list, f) in.WantComma() } @@ -4815,7 +4823,15 @@ func (x *SearchRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "version": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Version = f } case "filters": @@ -5642,13 +5658,29 @@ func (x *Range) UnmarshalEasyJSON(in *jlexer.Lexer) { case "offset": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Offset = f } case "length": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Length = f } } @@ -7823,7 +7855,15 @@ func (x *PutSingleRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []uint32 in.Delim('[') for !in.IsDelim(']') { - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv list = append(list, f) in.WantComma() } diff --git a/object/grpc/types_frostfs.pb.go b/object/grpc/types_frostfs.pb.go index 5b1eb2c..bc246cf 100644 --- a/object/grpc/types_frostfs.pb.go +++ b/object/grpc/types_frostfs.pb.go @@ -433,7 +433,15 @@ func (x *ShortHeader) UnmarshalEasyJSON(in *jlexer.Lexer) { case "creationEpoch": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.CreationEpoch = f } case "ownerID": @@ -468,7 +476,15 @@ func (x *ShortHeader) UnmarshalEasyJSON(in *jlexer.Lexer) { case "payloadLength": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.PayloadLength = f } case "payloadHash": @@ -1408,19 +1424,43 @@ func (x *Header_EC) UnmarshalEasyJSON(in *jlexer.Lexer) { case "index": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Index = f } case "total": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Total = f } case "headerLength": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.HeaderLength = f } case "header": @@ -2005,13 +2045,29 @@ func (x *Header) UnmarshalEasyJSON(in *jlexer.Lexer) { case "creationEpoch": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.CreationEpoch = f } case "payloadLength": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.PayloadLength = f } case "payloadHash": @@ -2777,13 +2833,29 @@ func (x *ECInfo_Chunk) UnmarshalEasyJSON(in *jlexer.Lexer) { case "index": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Index = f } case "total": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Total = f } } diff --git a/refs/grpc/types_frostfs.pb.go b/refs/grpc/types_frostfs.pb.go index 869620f..3ed647c 100644 --- a/refs/grpc/types_frostfs.pb.go +++ b/refs/grpc/types_frostfs.pb.go @@ -835,13 +835,29 @@ func (x *Version) UnmarshalEasyJSON(in *jlexer.Lexer) { case "major": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Major = f } case "minor": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Minor = f } } diff --git a/session/grpc/service_frostfs.pb.go b/session/grpc/service_frostfs.pb.go index a3f0111..71a6a41 100644 --- a/session/grpc/service_frostfs.pb.go +++ b/session/grpc/service_frostfs.pb.go @@ -12,6 +12,7 @@ import ( easyproto "github.com/VictoriaMetrics/easyproto" jlexer "github.com/mailru/easyjson/jlexer" jwriter "github.com/mailru/easyjson/jwriter" + strconv "strconv" ) type CreateRequest_Body struct { @@ -181,7 +182,15 @@ func (x *CreateRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "expiration": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Expiration = f } } diff --git a/session/grpc/types_frostfs.pb.go b/session/grpc/types_frostfs.pb.go index 58807fe..1b6a664 100644 --- a/session/grpc/types_frostfs.pb.go +++ b/session/grpc/types_frostfs.pb.go @@ -935,19 +935,43 @@ func (x *SessionToken_Body_TokenLifetime) UnmarshalEasyJSON(in *jlexer.Lexer) { case "exp": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Exp = f } case "nbf": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Nbf = f } case "iat": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Iat = f } } @@ -2083,13 +2107,29 @@ func (x *RequestMetaHeader) UnmarshalEasyJSON(in *jlexer.Lexer) { case "epoch": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Epoch = f } case "ttl": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Ttl = f } case "xHeaders": @@ -2130,7 +2170,15 @@ func (x *RequestMetaHeader) UnmarshalEasyJSON(in *jlexer.Lexer) { case "magicNumber": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.MagicNumber = f } } @@ -2456,13 +2504,29 @@ func (x *ResponseMetaHeader) UnmarshalEasyJSON(in *jlexer.Lexer) { case "epoch": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Epoch = f } case "ttl": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Ttl = f } case "xHeaders": diff --git a/status/grpc/types_frostfs.pb.go b/status/grpc/types_frostfs.pb.go index 7581dbe..609fc03 100644 --- a/status/grpc/types_frostfs.pb.go +++ b/status/grpc/types_frostfs.pb.go @@ -425,7 +425,15 @@ func (x *Status_Detail) UnmarshalEasyJSON(in *jlexer.Lexer) { case "id": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Id = f } case "value": @@ -645,7 +653,15 @@ func (x *Status) UnmarshalEasyJSON(in *jlexer.Lexer) { case "code": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Code = f } case "message": diff --git a/tombstone/grpc/types_frostfs.pb.go b/tombstone/grpc/types_frostfs.pb.go index 79afdfc..0971045 100644 --- a/tombstone/grpc/types_frostfs.pb.go +++ b/tombstone/grpc/types_frostfs.pb.go @@ -12,6 +12,7 @@ import ( easyproto "github.com/VictoriaMetrics/easyproto" jlexer "github.com/mailru/easyjson/jlexer" jwriter "github.com/mailru/easyjson/jwriter" + strconv "strconv" ) type Tombstone struct { @@ -216,7 +217,15 @@ func (x *Tombstone) UnmarshalEasyJSON(in *jlexer.Lexer) { case "expirationEpoch": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.ExpirationEpoch = f } case "splitID": diff --git a/util/proto/test/custom/test_frostfs.pb.go b/util/proto/test/custom/test_frostfs.pb.go index 03f3ece..15e77af 100644 --- a/util/proto/test/custom/test_frostfs.pb.go +++ b/util/proto/test/custom/test_frostfs.pb.go @@ -175,7 +175,15 @@ func (x *Primitives_Aux) UnmarshalEasyJSON(in *jlexer.Lexer) { case "innerField": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.InnerField = f } } @@ -797,31 +805,71 @@ func (x *Primitives) UnmarshalEasyJSON(in *jlexer.Lexer) { case "fieldD": { var f int32 - f = in.Int32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseInt(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := int32(v) + f = pv x.FieldD = f } case "fieldE": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.FieldE = f } case "fieldF": { var f int64 - f = in.Int64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseInt(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := int64(v) + f = pv x.FieldF = f } case "fieldG": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.FieldG = f } case "fieldI": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.FieldI = f } case "fieldJ": @@ -833,7 +881,15 @@ func (x *Primitives) UnmarshalEasyJSON(in *jlexer.Lexer) { case "fieldK": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.FieldK = f } case "fieldH": @@ -871,7 +927,15 @@ func (x *Primitives) UnmarshalEasyJSON(in *jlexer.Lexer) { x.FieldM = xx { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv xx.FieldMe = f } case "fieldAux": @@ -1039,7 +1103,15 @@ func (x *RepPrimitives_Aux) UnmarshalEasyJSON(in *jlexer.Lexer) { case "innerField": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.InnerField = f } } @@ -1498,7 +1570,15 @@ func (x *RepPrimitives) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []int32 in.Delim('[') for !in.IsDelim(']') { - f = in.Int32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseInt(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := int32(v) + f = pv list = append(list, f) in.WantComma() } @@ -1511,7 +1591,15 @@ func (x *RepPrimitives) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []uint32 in.Delim('[') for !in.IsDelim(']') { - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv list = append(list, f) in.WantComma() } @@ -1524,7 +1612,15 @@ func (x *RepPrimitives) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []int64 in.Delim('[') for !in.IsDelim(']') { - f = in.Int64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseInt(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := int64(v) + f = pv list = append(list, f) in.WantComma() } @@ -1537,7 +1633,15 @@ func (x *RepPrimitives) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []uint64 in.Delim('[') for !in.IsDelim(']') { - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv list = append(list, f) in.WantComma() } @@ -1550,7 +1654,15 @@ func (x *RepPrimitives) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []uint64 in.Delim('[') for !in.IsDelim(']') { - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv list = append(list, f) in.WantComma() } diff --git a/util/protogen/internalgengo/json.go b/util/protogen/internalgengo/json.go index ec70155..4d7f4be 100644 --- a/util/protogen/internalgengo/json.go +++ b/util/protogen/internalgengo/json.go @@ -59,6 +59,17 @@ func emitJSONUnmarshal(g *protogen.GeneratedFile, msg *protogen.Message) { g.P("}") } +func emitJSONParseInteger(g *protogen.GeneratedFile, ident string, method string, bitSize int, typ string) { + g.P("r := in.JsonNumber()") + g.P("n := r.String()") + g.P("v, err := ", strconvPackage.Ident(method), "(n, 10, ", bitSize, ")") + g.P("if err != nil {") + g.P(" in.AddError(err)") + g.P(" return") + g.P("}") + g.P(ident, " := ", typ, "(v)") +} + func emitJSONFieldRead(g *protogen.GeneratedFile, f *protogen.Field, name string) { g.P("{") defer g.P("}") @@ -100,13 +111,17 @@ func emitJSONFieldRead(g *protogen.GeneratedFile, f *protogen.Field, name string }`) template = "%s = parsedValue" case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: - template = "%s = in.Int32()" + emitJSONParseInteger(g, "pv", "ParseInt", 32, "int32") + template = "%s = pv" case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: - template = "%s = in.Uint32()" + emitJSONParseInteger(g, "pv", "ParseUint", 32, "uint32") + template = "%s = pv" case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: - template = "%s = in.Int64()" + emitJSONParseInteger(g, "pv", "ParseInt", 64, "int64") + template = "%s = pv" case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: - template = "%s = in.Uint64()" + emitJSONParseInteger(g, "pv", "ParseUint", 64, "uint64") + template = "%s = pv" case protoreflect.FloatKind: template = "%s = in.Float32()" case protoreflect.DoubleKind: -- 2.45.3 From b06dad731c711082abfb6f88a54a77ee7cc6d043 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 1 Oct 2024 13:50:43 +0300 Subject: [PATCH 6/7] [#120] protogen: Marshal 64-bit integers as strings Signed-off-by: Evgenii Stratonikov --- accounting/grpc/types_frostfs.pb.go | 4 +++- acl/grpc/types_frostfs.pb.go | 12 +++++++++--- netmap/grpc/types_frostfs.pb.go | 16 +++++++++++---- object/grpc/service_frostfs.pb.go | 8 ++++++-- object/grpc/types_frostfs.pb.go | 16 +++++++++++---- session/grpc/service_frostfs.pb.go | 4 +++- session/grpc/types_frostfs.pb.go | 24 +++++++++++++++++------ tombstone/grpc/types_frostfs.pb.go | 4 +++- util/proto/test/custom/test_frostfs.pb.go | 24 +++++++++++++++++------ util/protogen/internalgengo/json.go | 10 ++++++++-- 10 files changed, 92 insertions(+), 30 deletions(-) diff --git a/accounting/grpc/types_frostfs.pb.go b/accounting/grpc/types_frostfs.pb.go index 438cd03..8585583 100644 --- a/accounting/grpc/types_frostfs.pb.go +++ b/accounting/grpc/types_frostfs.pb.go @@ -125,7 +125,9 @@ func (x *Decimal) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"value\":" out.RawString(prefix) - out.Int64(x.Value) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendInt(out.Buffer.Buf, x.Value, 10) + out.RawByte('"') } } { diff --git a/acl/grpc/types_frostfs.pb.go b/acl/grpc/types_frostfs.pb.go index 6ebaf63..1ba6c53 100644 --- a/acl/grpc/types_frostfs.pb.go +++ b/acl/grpc/types_frostfs.pb.go @@ -1423,7 +1423,9 @@ func (x *BearerToken_Body_TokenLifetime) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"exp\":" out.RawString(prefix) - out.Uint64(x.Exp) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Exp, 10) + out.RawByte('"') } } { @@ -1435,7 +1437,9 @@ func (x *BearerToken_Body_TokenLifetime) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"nbf\":" out.RawString(prefix) - out.Uint64(x.Nbf) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Nbf, 10) + out.RawByte('"') } } { @@ -1447,7 +1451,9 @@ func (x *BearerToken_Body_TokenLifetime) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"iat\":" out.RawString(prefix) - out.Uint64(x.Iat) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Iat, 10) + out.RawByte('"') } } out.RawByte('}') diff --git a/netmap/grpc/types_frostfs.pb.go b/netmap/grpc/types_frostfs.pb.go index 24b7575..a4b10f9 100644 --- a/netmap/grpc/types_frostfs.pb.go +++ b/netmap/grpc/types_frostfs.pb.go @@ -2081,7 +2081,9 @@ func (x *Netmap) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"epoch\":" out.RawString(prefix) - out.Uint64(x.Epoch) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Epoch, 10) + out.RawByte('"') } } { @@ -2655,7 +2657,9 @@ func (x *NetworkInfo) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"currentEpoch\":" out.RawString(prefix) - out.Uint64(x.CurrentEpoch) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.CurrentEpoch, 10) + out.RawByte('"') } } { @@ -2667,7 +2671,9 @@ func (x *NetworkInfo) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"magicNumber\":" out.RawString(prefix) - out.Uint64(x.MagicNumber) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.MagicNumber, 10) + out.RawByte('"') } } { @@ -2679,7 +2685,9 @@ func (x *NetworkInfo) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"msPerBlock\":" out.RawString(prefix) - out.Int64(x.MsPerBlock) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendInt(out.Buffer.Buf, x.MsPerBlock, 10) + out.RawByte('"') } } { diff --git a/object/grpc/service_frostfs.pb.go b/object/grpc/service_frostfs.pb.go index 0130ee3..f934f3b 100644 --- a/object/grpc/service_frostfs.pb.go +++ b/object/grpc/service_frostfs.pb.go @@ -5612,7 +5612,9 @@ func (x *Range) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"offset\":" out.RawString(prefix) - out.Uint64(x.Offset) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Offset, 10) + out.RawByte('"') } } { @@ -5624,7 +5626,9 @@ func (x *Range) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"length\":" out.RawString(prefix) - out.Uint64(x.Length) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Length, 10) + out.RawByte('"') } } out.RawByte('}') diff --git a/object/grpc/types_frostfs.pb.go b/object/grpc/types_frostfs.pb.go index bc246cf..0ee939a 100644 --- a/object/grpc/types_frostfs.pb.go +++ b/object/grpc/types_frostfs.pb.go @@ -327,7 +327,9 @@ func (x *ShortHeader) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"creationEpoch\":" out.RawString(prefix) - out.Uint64(x.CreationEpoch) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.CreationEpoch, 10) + out.RawByte('"') } } { @@ -368,7 +370,9 @@ func (x *ShortHeader) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"payloadLength\":" out.RawString(prefix) - out.Uint64(x.PayloadLength) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.PayloadLength, 10) + out.RawByte('"') } } { @@ -1882,7 +1886,9 @@ func (x *Header) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"creationEpoch\":" out.RawString(prefix) - out.Uint64(x.CreationEpoch) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.CreationEpoch, 10) + out.RawByte('"') } } { @@ -1894,7 +1900,9 @@ func (x *Header) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"payloadLength\":" out.RawString(prefix) - out.Uint64(x.PayloadLength) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.PayloadLength, 10) + out.RawByte('"') } } { diff --git a/session/grpc/service_frostfs.pb.go b/session/grpc/service_frostfs.pb.go index 71a6a41..c71325a 100644 --- a/session/grpc/service_frostfs.pb.go +++ b/session/grpc/service_frostfs.pb.go @@ -141,7 +141,9 @@ func (x *CreateRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"expiration\":" out.RawString(prefix) - out.Uint64(x.Expiration) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Expiration, 10) + out.RawByte('"') } } out.RawByte('}') diff --git a/session/grpc/types_frostfs.pb.go b/session/grpc/types_frostfs.pb.go index 1b6a664..e18c1ab 100644 --- a/session/grpc/types_frostfs.pb.go +++ b/session/grpc/types_frostfs.pb.go @@ -877,7 +877,9 @@ func (x *SessionToken_Body_TokenLifetime) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"exp\":" out.RawString(prefix) - out.Uint64(x.Exp) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Exp, 10) + out.RawByte('"') } } { @@ -889,7 +891,9 @@ func (x *SessionToken_Body_TokenLifetime) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"nbf\":" out.RawString(prefix) - out.Uint64(x.Nbf) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Nbf, 10) + out.RawByte('"') } } { @@ -901,7 +905,9 @@ func (x *SessionToken_Body_TokenLifetime) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"iat\":" out.RawString(prefix) - out.Uint64(x.Iat) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Iat, 10) + out.RawByte('"') } } out.RawByte('}') @@ -1987,7 +1993,9 @@ func (x *RequestMetaHeader) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"epoch\":" out.RawString(prefix) - out.Uint64(x.Epoch) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Epoch, 10) + out.RawByte('"') } } { @@ -2066,7 +2074,9 @@ func (x *RequestMetaHeader) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"magicNumber\":" out.RawString(prefix) - out.Uint64(x.MagicNumber) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.MagicNumber, 10) + out.RawByte('"') } } out.RawByte('}') @@ -2408,7 +2418,9 @@ func (x *ResponseMetaHeader) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"epoch\":" out.RawString(prefix) - out.Uint64(x.Epoch) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Epoch, 10) + out.RawByte('"') } } { diff --git a/tombstone/grpc/types_frostfs.pb.go b/tombstone/grpc/types_frostfs.pb.go index 0971045..e5b67d5 100644 --- a/tombstone/grpc/types_frostfs.pb.go +++ b/tombstone/grpc/types_frostfs.pb.go @@ -152,7 +152,9 @@ func (x *Tombstone) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"expirationEpoch\":" out.RawString(prefix) - out.Uint64(x.ExpirationEpoch) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.ExpirationEpoch, 10) + out.RawByte('"') } } { diff --git a/util/proto/test/custom/test_frostfs.pb.go b/util/proto/test/custom/test_frostfs.pb.go index 15e77af..3804e46 100644 --- a/util/proto/test/custom/test_frostfs.pb.go +++ b/util/proto/test/custom/test_frostfs.pb.go @@ -647,7 +647,9 @@ func (x *Primitives) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"fieldF\":" out.RawString(prefix) - out.Int64(x.FieldF) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendInt(out.Buffer.Buf, x.FieldF, 10) + out.RawByte('"') } } { @@ -659,7 +661,9 @@ func (x *Primitives) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"fieldG\":" out.RawString(prefix) - out.Uint64(x.FieldG) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.FieldG, 10) + out.RawByte('"') } } { @@ -671,7 +675,9 @@ func (x *Primitives) MarshalEasyJSON(out *jwriter.Writer) { } const prefix string = "\"fieldI\":" out.RawString(prefix) - out.Uint64(x.FieldI) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.FieldI, 10) + out.RawByte('"') } } { @@ -1448,7 +1454,9 @@ func (x *RepPrimitives) MarshalEasyJSON(out *jwriter.Writer) { if i != 0 { out.RawByte(',') } - out.Int64(x.FieldE[i]) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendInt(out.Buffer.Buf, x.FieldE[i], 10) + out.RawByte('"') } out.RawByte(']') } @@ -1467,7 +1475,9 @@ func (x *RepPrimitives) MarshalEasyJSON(out *jwriter.Writer) { if i != 0 { out.RawByte(',') } - out.Uint64(x.FieldF[i]) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.FieldF[i], 10) + out.RawByte('"') } out.RawByte(']') } @@ -1486,7 +1496,9 @@ func (x *RepPrimitives) MarshalEasyJSON(out *jwriter.Writer) { if i != 0 { out.RawByte(',') } - out.Uint64(x.FieldFu[i]) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.FieldFu[i], 10) + out.RawByte('"') } out.RawByte(']') } diff --git a/util/protogen/internalgengo/json.go b/util/protogen/internalgengo/json.go index 4d7f4be..3267955 100644 --- a/util/protogen/internalgengo/json.go +++ b/util/protogen/internalgengo/json.go @@ -231,9 +231,15 @@ func emitJSONFieldWrite(g *protogen.GeneratedFile, f *protogen.Field, name strin case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: template = "out.Uint32(%s)" case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: - template = "out.Int64(%s)" + g.P("out.RawByte('\"')") + g.P("out.Buffer.Buf = ", strconvPackage.Ident("AppendInt"), "(out.Buffer.Buf, ", selector, ", 10)") + g.P("out.RawByte('\"')") + return case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: - template = "out.Uint64(%s)" + g.P("out.RawByte('\"')") + g.P("out.Buffer.Buf = ", strconvPackage.Ident("AppendUint"), "(out.Buffer.Buf, ", selector, ", 10)") + g.P("out.RawByte('\"')") + return case protoreflect.FloatKind: template = "out.Float32(%s)" case protoreflect.DoubleKind: -- 2.45.3 From d9a604fbc16fdcd988716a74cfd839eb3f83f50c Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 1 Oct 2024 13:54:32 +0300 Subject: [PATCH 7/7] [#120] proto/test: Unskip protojson compatibility test Signed-off-by: Evgenii Stratonikov --- util/proto/marshal_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/util/proto/marshal_test.go b/util/proto/marshal_test.go index 98422fc..8b717be 100644 --- a/util/proto/marshal_test.go +++ b/util/proto/marshal_test.go @@ -77,7 +77,6 @@ func TestStableMarshalSingle(t *testing.T) { require.NoError(t, protojson.Unmarshal(r, &actual)) t.Run("protojson compatibility", func(t *testing.T) { - t.Skip() data, err := protojson.Marshal(&actual) require.NoError(t, err) require.JSONEq(t, string(data), string(r)) -- 2.45.3