-
Notifications
You must be signed in to change notification settings - Fork 492
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
Simplify PayloadConvention to enable non-JSON payloads #3189
Conversation
bc8ae5d
to
64085b4
Compare
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.
optimistic sign off
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.
- As suggested in Support Binary Payloads in V2 #2977 the convention should be an interface (or abstract class) to serialized from/to bytes, there is no need to encode any string. Which encoding should I use when using Protobuf?
- The serializer should be configured at operation (Telemetry, Property or Command) level. If I want to use AVRO for Telemetry, then I cannot use Twins or Commands.
- Have consistent API surface using Generics instead of
object
, providing an overload in TelemetryMessage to use the sameT
The base class is an abstract class.
I'll change it to a string. It is used when sending telemetry to set the content encoding property.
We don't have the design sufficiently complicated to enable someone to change their convention per hub primitive nor per operation. While we can see someone maybe wanting to do that, we don't see it as mainstream enough to warrant the cost to implement/maintain nor the added complexity to the API.
In JSON, serialization doesn't require the type to serialize. All classes inherit from System.Object, so that is sufficient. If you see a need to do that for binary conventions, let us know. |
ef1b2c1
to
f76f73b
Compare
Why is it called convention? I dont see any convention here, just a way to provide custom serializers. |
Okay, I didn't know what part of your sentence the key point was, then. If your only complaint is that there is a method that takes a string and returns a type specified by the user, I found that is required for getting a type from a value on a twin. The payload convention class is used for that too and must be JSON. When we're performing twin operations, the client is configurable to customize how that is deserialized.
What? Why? We can use it for telemetry, direct methods, C2D, and twins. They all have an opportunity de/serialize a custom payload.
I don't understand. This isn't required for JSON serialization. The type passed by the user is a real type, but the method doesn't need to know it, though. That's why However, I accept it might matter for binary serialization. Do you know that it does?
A service and device pass payloads back and forth in a serialized state by a convention they choose. The Hub dictates JSON for Twins and promotes JSON for everything else.
It isn't just for telemetry. |
b8604d7
to
2e754f0
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
2e754f0
to
b48249f
Compare
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.
The changes overall look good to me. I have some small questions here and there, but nothing major.
My apologies again on the delay it took getting to this PR. 😑
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
No description provided.