[store] json encoding generics - #1626
Conversation
c122f4c to
1d87e3e
Compare
1d87e3e to
968cd4c
Compare
mickmis
left a comment
There was a problem hiding this comment.
Suggestions for simplification. I might not have the overall picture though.
| } | ||
|
|
||
| // EncodeJSON is a general-purpose OperationHandler.Encode that marshals the request as JSON. | ||
| func EncodeJSON(request OperationRequest) ([]byte, error) { |
There was a problem hiding this comment.
Checking how it used in #1597, can't those be actually attached instead to OperationHandler, and T be an additional type parameter of OperationHandler?
There was a problem hiding this comment.
This wouldn't work since the registry is defined as a map:
var Registry = map[string]dssstore.OperationHandler[repos.Repository]{}
and we would need to provide a specific request type there.
However, since we expect to have custom encoding, I think it's okay to leave things as they are now. I extracted the json encoding and decoding methods in this PR to make things simpler for the naive implementation and for the transition to the optimized encoding.
There was a problem hiding this comment.
In that case please add in both function docs a TODO mentioning that.
933d167 to
a8016cb
Compare
| } | ||
|
|
||
| // EncodeJSON is a general-purpose OperationHandler.Encode that marshals the request as JSON. | ||
| func EncodeJSON(request OperationRequest) ([]byte, error) { |
There was a problem hiding this comment.
In that case please add in both function docs a TODO mentioning that.
a8016cb to
e63d928
Compare
e63d928 to
7051c2b
Compare
Chained PR: #1622 -> #1528 -> #1626 -> #1597 -> #1623 -> #1627 -> #1642 -> #1643
Since all requests will be json encoded and decoded for now, this PR adds generic functions that implement this functionality to be used in the
OperationHandler. They will eventually be replaced by the custom encoding.