WIP: Generate StableMarshaler/StableSize methods for protobufs #43
No reviewers
Labels
No labels
P0
P1
P2
P3
good first issue
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-api-go#43
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "aarifullin/frostfs-api-go:feature/40-autogen_marsh/proto"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Signed-off-by: Airat Arifullin a.arifullin@yadro.com
[#40] types: Generate StableMarshaler methods for refsto WIP: [#40] types: Generate StableMarshaler methods for refs9d0993aa6f
to29d9637345
29d9637345
toff0c16d853
ff0c16d853
to88864fe7b0
WIP: [#40] types: Generate StableMarshaler methods for refsto WIP: [#40] types: Generate StableMarshaler/StableSize methods for protobufsWIP: [#40] types: Generate StableMarshaler/StableSize methods for protobufsto [#40] types: Generate StableMarshaler/StableSize methods for protobufs@ -47,3 +47,3 @@
echo "⇒ Processing $$f "; \
protoc \
--proto_path=.:./vendor:/usr/local/include \
--proto_path=.:./vendor:/usr/local/include:/home/aarifullin/ws/frostfs-api \
will be fixed
@ -0,0 +65,4 @@
// See also HomomorphicHashingState.
func (c *Container) SetHomomorphicHashingState(enable bool) {
for i := range c.Attributes {
if c.Attributes[i].GetKey() == SysAttributeHomomorphicHashing || c.Attributes[i].GetKey() == SysAttributeHomomorphicHashingNeoFS {
You use method access (
.GetKey
) and field access (.Attributes[i]
) in one statement. Maybe it's better to select one? I prefer method access, because it has nil checks.I like this point. I have fixed the snippet
@ -14,3 +14,2 @@
GetMetaHeader() *session.RequestMetaHeader
GetVerificationHeader() *session.RequestVerificationHeader
SetVerificationHeader(*session.RequestVerificationHeader)
GetVerifyHeader() *session.RequestVerificationHeader
Why renamed?
neo.fs.v2.session.RequestVerificationHeader verify_header = 3;
Because protobufs are generated with such getter (based on field name)
@ -17,2 +20,2 @@
imp := string(f.GoImportPath)
if strings.HasSuffix(imp, "/tree") || strings.HasSuffix(imp, "/control") {
impPath := f.GoImportPath.String()
if strings.HasSuffix(impPath, "/tree") || strings.HasSuffix(impPath, "/control") ||
Could you explain this change?
This is probably my dirty trick. The plugin has not been used for
frostfs-api-go
so far, only forfrostfs-node
(/tree
,/control
).grpc
is needed to generate pb-s in frostfs-api-go folders :) I'll consider better solutionThis how SDK will probably look like TrueCloudLab/frostfs-sdk-go#100
88864fe7b0
to87584983ac
87584983ac
toe957278c57
e957278c57
to80e6a0bbd6
@ -48,2 +48,3 @@
protoc \
--proto_path=.:./vendor:/usr/local/include \
--proto_path=.:./vendor:/usr/local/include:/home/aarifullin/ws/frostfs-api \
--plugin=protoc-gen-go-frostfs=/home/aarifullin/ws/frostfs-api-go/util/protogen/protogen \
./bin
?This will be fixed. BTW, I left the comment with my note at this line above but it was automatically outdated :(
I mean what is the problem with fixing it right now? Does current implementation has some benefits?
@ -1,14 +0,0 @@
package accounting
It seems only
message_test.go
files are left, do we need agrpc
package at all?Good question.
The folders that contain not only
message_test.go
filesacl/
container/
object/
session/
status/
For me it's really better to keep pb files in
/grpc/
folders:/grpc/
contains autogenerated pb-s and extra methods (types.go
,service.go
)/grpc/
or in their rootfrostfs-api
(go_package
-s etc) and plugin@ -196,6 +224,29 @@ func (x *NetworkConfig) SetParameters(v []*NetworkConfig_Parameter) {
x.Parameters = v
}
// // NumberOfParameters returns number of network parameters.
Double comment
@ -199,0 +237,4 @@
// Breaks iteration on f's true return.
//
// Handler must not be nil.
func (x *NetworkConfig) IterateParameters(f func(*NetworkConfig_Parameter) bool) {
While we are here, do you think it is worth having such non-autogenerated code here?
From my POV
types.go
,service.go
files contain protobuf helper methods. So, yes, I think that's absolutely fine.For me it is more weird to move helpers and wrappers from
/grpc/
folder@ -8,0 +9,4 @@
type GetRangeResponseBodyRangePart isGetRangeResponse_Body_RangePart
type HeadResponseBodyHead = isHeadResponse_Body_Head
Why do we need this synonyms?
oneof
generates protobuf like thatBut the interface cannot be exported. So, alias is the trick
Example of usage:
@ -54,3 +17,1 @@
if bm, ok := msg.(binaryMessage); ok {
t.Run(fmt.Sprintf("Binary_%T", msg), func(t *testing.T) {
if bm, ok := msg1.(utilproto.StableMarshaller); ok {
Where did JSON test go?
Added. Please, note: since we no longer use proxy-types, we need to use std packages to work with protobufs
proto, protojson
for assigning, comparing, marshalling etcAs the result - I removed many converters and marshallers that dealt with standard golang types
@ -26,2 +30,4 @@
// generateFile generates a *.pb.go file enforcing field-order serialization.
func generateFile(gen *protogen.Plugin, file *protogen.File) *protogen.GeneratedFile {
emitMask := MethodMask(0)
if imp := string(file.GoImportPath); strings.HasSuffix(imp, "/tree") || strings.HasSuffix(imp, "/control") {
While we are here: what about using command-line options?
tree
is from a different repo, I think it makes sense to give user control.80e6a0bbd6
to9e291ff6b1
@ -8,4 +5,3 @@
statustest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status/test"
)
func TestMessageConvert(t *testing.T) {
Why not to remove it?
Thank u! I forgot to remove
9e291ff6b1
toc8b3fc0db2
c8b3fc0db2
tobe3cfff1e1
be3cfff1e1
tobc16a32c24
[#40] types: Generate StableMarshaler/StableSize methods for protobufsto WIP: [#40] types: Generate StableMarshaler/StableSize methods for protobufsWIP: [#40] types: Generate StableMarshaler/StableSize methods for protobufsto WIP: Generate StableMarshaler/StableSize methods for protobufsPostponed.
Pull request closed