-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(encoding): replace msgpack with JSON encoding #115
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,6 @@ import ( | |
| "time" | ||
|
|
||
| "github.com/sirupsen/logrus" | ||
| "github.com/vmihailenco/msgpack/v5" | ||
| "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" | ||
| ) | ||
|
|
||
|
|
@@ -51,7 +50,7 @@ func (hs handshakeService) send(ctx context.Context, path string, jsonData []byt | |
| return | ||
| } | ||
|
|
||
| req.Header.Set("Content-Type", "application/msgpack") | ||
| req.Header.Set("Content-Type", "application/json") | ||
| req.Header.Set("User-Agent", fmt.Sprintf("shelltimeCLI@%s", commitID)) | ||
| resp, err := hc.Do(req) | ||
| if err != nil { | ||
|
|
@@ -103,7 +102,7 @@ func (hs handshakeService) Init(ctx context.Context) (string, error) { | |
| OSVersion: sysInfo.Version, | ||
| } | ||
|
|
||
| jsonData, err := msgpack.Marshal(data) | ||
| jsonData, err := json.Marshal(data) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While you've correctly switched to This needs to be updated to Additionally, for code cleanup, the |
||
| if err != nil { | ||
| logrus.Errorln(err) | ||
| return "", err | ||
|
|
@@ -130,7 +129,7 @@ func (hs handshakeService) Check(ctx context.Context, handshakeId string) (token | |
| EncodedID: handshakeId, | ||
| } | ||
|
|
||
| jsonData, err := msgpack.Marshal(data) | ||
| jsonData, err := json.Marshal(data) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the Also, the |
||
| if err != nil { | ||
| logrus.Errorln(err) | ||
| return "", err | ||
|
|
||
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.
While you've updated this
Marshalcall to use JSON, the function still usesmsgpackat the beginning (lines 14-21) to process thesocketMsgPayload. To complete the refactoring in this file and fully remove themsgpackdependency, that initial processing should also be updated to usejson.Marshalandjson.Unmarshal.