Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thanks for the contribution! I think there is a misunderstanding of what this is doing though and this isn't something we generally support. At the boundary level (inputs and outputs), every piece of data that goes across needs an encoding. we can't really pass bytes across purely based on types. it might seem like a contradiction given the case above checks for type === 'string', but that's a backward compat thing and will eventually be changed to something like
isUtf8Encoded(ex.output)
.So to pass a float, what you need to do here is either choose an existing encoding or we create a new encoding. Two possible encoding you could choose would be either json or raw binary.
example w/ contentType
application/json
:example w/ contentType =
application/x-binary
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.
Thanks for the detailed explanation! So, just to be clear, the way my schema is currently set up, the plugin constructed from the default bundle throws an error. If I am using
application/x-binary
withnumber
anfloat
as mytype
andformat
, then I will be expected to implement that interface myself. If I am usingapplication/json
or another potential standard encoding, the default bundle should be expected to produce a functioning plugin out of the box if the encoding is supported and there is valid stub code. Is my understanding accurate?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.
Sorry if it's not clear yet, those shouldn't be valid combinations.
number
andjson
are valid combinations because json specifies how to encode and decode numbers. Withapplication/x-binary
, there isn't really a valid type other thanbuffer
. we don't know how to map a float to a binary in a cross language way without a specified encoding. x-binary is effectively "no encoding" and it just gives you a raw buffer that you have to map to and from yourself.So your options are:
contentType: application/x-binary
&type: buffer
and map yourselfThere 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.
ok, gotcha, this make sense. My use case is kinda weird. I think I will make my own rules for now. If it helps, the motivation behind this combination is a desire to generate code that clearly indicates to the user that they are supposed to make a function that returns a float, but then behind the scenes I would like to extend my PDK in order to pass it back to the host in a buffer. I am assuming that the combination of
contentType: application/x-binary
&type: buffer
would generate code that asks the user to return a buffer in their user-defined function.It is still nice to also have a gateway to directly access the user-implemented function that returns the return val in an encoding like JSON for debug purposes, which I am not sure would automatically be generated for me if I used
type: buffer
I think I've figured out how to do what I need, open to trade some more ideas if it seems like there is more to discuss here.