-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
@@ -0,0 +1,171 @@ | |||
/* | |||
Copyright 2015 The Kubernetes Authors. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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!
put this PR on hold for now and to focus on the end to end test effort first. |
close this PR. new PR #107 has the changes |
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.