Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use local serialization lib, part-1 #30

Closed
wants to merge 3 commits into from

Conversation

yb01
Copy link
Collaborator

@yb01 yb01 commented Jun 10, 2022

code-level reuse the serializer package from the apimachinery/serializer package.
the heavy meta data, such as multiple type, versioning conversion in the serializer package has been removed.

@yb01 yb01 requested review from Sindica, sonyafenge and q131172019 and removed request for Sindica and sonyafenge June 10, 2022 04:32
@@ -0,0 +1,171 @@
/*
Copyright 2015 The Kubernetes Authors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the file was copied from Arktos. But the copyright header here looks a bit strange since all others do not have the header.

Identifier() Identifier
}

//// MemoryAllocator is responsible for allocating memory.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of code commented out. Can those be simply deleted?

//type lengthDelimitedFramer struct{}
//
//// NewFrameWriter implements stream framing for this serializer
//func (lengthDelimitedFramer) NewFrameWriter(w io.Writer) io.Writer {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why FrameWriter here was commented?

@@ -217,30 +233,30 @@ func getResourceVersionsMap(req *http.Request) (types.ResourceVersionMap, error)

wr := apiTypes.WatchRequest{}

err = json.Unmarshal(body, wr)
r, err := s.Decode(body, wr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested protobuf encoding/decoding object as map index?

@@ -103,18 +114,28 @@ func TestHttpGet(t *testing.T) {

dec := json.NewDecoder(recorder.Body)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here only test Json as client, right? Any plan for protobuf client test?

"global-resource-service/resource-management/pkg/common-lib/types"
"global-resource-service/resource-management/pkg/common-lib/types/event"
apiTypes "global-resource-service/resource-management/pkg/service-api/types"
)

type Installer struct {
dist di.Interface
js serializer.Serializer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

names and types are confusing. Can you make the name more self explainable or change the type?

content := req.Header.Get("Content-Type")
if content == "application/json" {
desiredSerializer = i.js
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default to protobuf does not seem right


// Write writes a single frame to the nested writer, prepending it with the length in
// in bytes of data (as a 4 byte, bigendian uint32).
func (w *lengthDelimitedFrameWriter) Write(data []byte) (int, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you have time, can you make a quick introduction to the framer? Many thanks!

@yb01
Copy link
Collaborator Author

yb01 commented Jun 14, 2022

put this PR on hold for now and to focus on the end to end test effort first.

@yb01
Copy link
Collaborator Author

yb01 commented Aug 30, 2022

close this PR. new PR #107 has the changes

@yb01 yb01 closed this Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants