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

Upgrade rpc router internals #178

Merged
merged 8 commits into from
Jan 3, 2024
Merged

Upgrade rpc router internals #178

merged 8 commits into from
Jan 3, 2024

Conversation

jangko
Copy link
Contributor

@jangko jangko commented Jan 3, 2024

fix #128
fix #90
fix #151
fix #20

And also completing migration to json-serialization

json_rpc/client.nim Outdated Show resolved Hide resolved
@jangko
Copy link
Contributor Author

jangko commented Jan 3, 2024

Thank you for your review @arnetheduck, I've remove all unsafe serializer. Now the user have to explicitly register their types or custom serializer for json rpc to work.

{.gcsafe, raises: [IOError].} =
w.writeValue JsonRPC2Literal

proc readValue*(r: var JsonReader[JrpcSys], val: var ResponseError)
Copy link
Member

Choose a reason for hiding this comment

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

if we disable automatic object serialization in JrcpSys and then opt in for these few types, I think we can avoid these manual case implementations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, it's too easy to write custom serializer using the new json-serialization, make me forget to use new features in nim-serialization. Now it's fixed.

Copy link
Member

Choose a reason for hiding this comment

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

🤣

@@ -142,6 +143,11 @@ type
createJsonFlavor JrpcSys,
requireAllFields = false

ResponseError.useDefaultSerializationIn JrpcSys
Copy link
Member

Choose a reason for hiding this comment

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

or JrpcSys.useDefaultSerializationFor(ResponseError, RequestTx, ...), right?

My preferred option would actually be type RequestTx {.json: [JrpcSys].} or something along those lines that but I suspect we might run into macro constraints implementing that..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

JrpcSys.useDefaultSerializationFor(ResponseError, RequestTx, ...), right?

No, because only ResponseError using both reader dan writer, while the rest use only reader or writer, not both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My preferred option would actually be type RequestTx {.json: [JrpcSys].} or something along those lines that but I suspect we might run into macro constraints implementing that..

I think it's doable. We can use simple template custom pragma instead of macro. The macro part already in nim-serialization. So it's still fall within nim-serialization capabilities.

@jangko jangko merged commit e0b077f into v0.2.0 Jan 3, 2024
12 checks passed
@jangko jangko deleted the upgrade-router-internal branch January 3, 2024 13:06
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