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

feat: add support for optional parameters #106

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Stebalien
Copy link
Member

Any nullable parameter is now optional.

TODO:

  • Tests
  • Should we even support this?

Any nullable parameter is now optional.
@Stebalien
Copy link
Member Author

Thoughts @fridrik01 @magik6k?

Copy link
Contributor

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

  • Not a bad idea
  • Not sure if we want this to be implicit for all handlers, it's not obvious that this is the behavior of this library
  • Would be nice to have a more explicit way to tag args as optional
    • This would allow non-pointer args (like TipSetKey in lotus) to become optional, which would be extremely convenient in some cases
    • a generic jsonrpc.Optional[T] wrapper?
    • jsonrpc.OptionalArg interface?

hasRawParams = true
}
recvs[i] = method.Type.In(i + 1 + hasCtx)
if recvs[i].Kind() == reflect.Pointer {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should only apply to trailing params - the opt couter should be reset on non pointer (non optional) args.

@Stebalien
Copy link
Member Author

a generic jsonrpc.Optional[T] wrapper?

That's a really good idea. Although dealing with generics & reflection is going to be a bit tricky.

@vgonkivs
Copy link

vgonkivs commented May 7, 2024

Hey @Stebalien, was there any decision made on this feature? Will it be supported? Have you also considered supporting variadic params?

@tuxcanfly tuxcanfly mentioned this pull request Aug 28, 2024
5 tasks
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.

3 participants