-
Notifications
You must be signed in to change notification settings - Fork 5
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
Slice driven encoding #69
Comments
How would this work for testing, for example in the operation tests we have https://github.com/zeroc-ice/icerpc-csharp/blob/2a257ae36d94e0bbb3f43f80118a9c9f5fcda83d/tests/IceRpc.Tests.Slice/OperationsTests.cs#L10-L12 And the protocol encoding is used to select the request encoding, but once the encoding is defined in Slice can we change it without having duplicate Slice definitions? |
IMO, these tests are wrong in the first place by relying on the protocol encoding. We could consider supporting an |
To clarify the effect of
The proxy generated code for C# uses a Slice20Encoder to encode the args and a Slice20Decoder to decode the return value. If we get back a 1.1-encoded return value, it's an error.
The skeleton generated code decodes the args based on the Slice encoding specified in the request, and encodes the return value with the same Slice encoding. Naturally if any param / return implies a single encoding, the skeleton code can be encoding-specific:
|
One interesting question is what is the encoding for the operations of
I think it needs to be
Maybe overkill? |
Adding new methods sounds a bit overkill and aren't we going to run out of ideas for names when we add the 3.0 encoding :)? |
I think this would be cleaner if it was a single attribute with an argument:
Maybe instead of strings, we could take enum arguments like I think it would be nice to de-couple proxy protocol and request encoding, but I think this approach will really hurt code re-usability (like you already saw with Service). Most operations could be encoded with either 1.1 or 2.0, so tying it to a specified encoding at the Slice level seems pretty limiting. Especially thinking in the long term. Right now this is reasonable because we only have 2 supported encodings, but eventually we'll likely have 2.1 and 3.0 etc. Like @bentoi says, this will get pretty untenable. |
For Service, I think we should have simply:
Please name a single downside of using the 1.1 encoding for these payloads.
I think it's actually unlikely; it's more likely we won't introduce another encoding version. A common mistake is to think "new feature requires new encoding version". Look at the Unicode encodings: they keep adding new characters and introducing new versions of Unicode (latest is version version 14.0 - https://en.wikipedia.org/wiki/Unicode#Versions). And yet, when you encode/decode a UTF-8 string, you don't encode/decode the Unicode version first. As for:
I find the replacement syntax more painful to type and more error-prone - not an improvement. |
Replaced by #87. |
Currently, the Slice encoding of a request payload depends on:
And this works today since the proxy has always a protocol (ice1 or ice2).
This is a proposal to:
With this proposal, it's also possible/easier to make the Ice protocol of a proxy truly optional.
Proposal
Encoding Attributes
Add
[encoding11]
and[encoding20]
attributes to Slice operations and the containers of operations (interfaces, module openings).This attribute applies only to request parameters and means: when encoding these parameters, the Slice engine uses the specified encoding. For example:
This attribute is not used for response payloads: the server still uses the request's payload encoding to encode the response (like today).
Remove the "+" in encoding 1.1
Encoding 1.1 is about interop with ZeroC Ice. There is no point to support new Slice syntax such as optional types and streams with 1.1.
Enforce Encoding Compatibility During Slice Compilation
Unlike what we do today, the Slice compiler does not automatically infer the encoding to select from the parameters/return of your operation. If you specify
[encoding11]
, all the parameters and return value of your operation must be 1.1-compatible (else, compilation failure). Likewise, if you specify[encoding20]
, all the parameters and return value of your operation must be 2.0-compatible (else, compilation failure).If you don't specify anything, it's equivalent to specifying
[encoding20]
on the enclosing module opening*.For example:
(*) module opening because the attribute applies to all the interfaces/operations in this particular module opening, not all opening of this module.
The net effect is most of the time the encoding of your request and even response is fully specified. This proposal uses attributes (not keywords) for encoding which allows for client / server Slice definition mismatches. For example:
For example:
Here the client will send a 1.1-encoded request and the server will return a 1.1-encoded response, even though the server Slice definitions make no mention of 1.1.
The text was updated successfully, but these errors were encountered: