Skip to content

[store] json encoding generics - #1626

Merged
mickmis merged 1 commit into
interuss:masterfrom
Orbitalize:json_generics
Aug 19, 2026
Merged

[store] json encoding generics#1626
mickmis merged 1 commit into
interuss:masterfrom
Orbitalize:json_generics

Conversation

@MariemBaccari

@MariemBaccari MariemBaccari commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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.

@mickmis mickmis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestions for simplification. I might not have the overall picture though.

Comment thread pkg/store/store.go
Comment thread pkg/store/store.go
}

// EncodeJSON is a general-purpose OperationHandler.Encode that marshals the request as JSON.
func EncodeJSON(request OperationRequest) ([]byte, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Checking how it used in #1597, can't those be actually attached instead to OperationHandler, and T be an additional type parameter of OperationHandler?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In that case please add in both function docs a TODO mentioning that.

Comment thread pkg/store/store.go
Comment thread pkg/store/store.go
}

// EncodeJSON is a general-purpose OperationHandler.Encode that marshals the request as JSON.
func EncodeJSON(request OperationRequest) ([]byte, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In that case please add in both function docs a TODO mentioning that.

@mickmis
mickmis merged commit 6584341 into interuss:master Aug 19, 2026
12 checks passed
@mickmis
mickmis deleted the json_generics branch August 19, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants