You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Assume an environment where we do not control deployment ordering, such for a given release, producers or consumers may be deployed before each other.</p>
733
736
734
-
<p>If an engineer needs to narrow a message, such as trying to add a <code>required</code>
735
-
field they create an incompatibility risk. A message sent by an old producer breaks a new consumer:</p>
737
+
<p>If an engineer needs to narrow a message, such as trying to add a <code>required</code>, field they create an incompatibility risk. A message sent by an old producer can break a new consumer:</p>
736
738
737
739
738
740
<!-- TODO: required string doesn't trigger a deserialization error because it has a deserialization defualt. We need a new example
<p>This also occurs when widening a message, by removing a <code>required</code> field. A message sent by a new producer breaks an old consumer:</p>
826
+
<p>This also occurs when widening a message, by removing a <code>required</code> field. A message sent by a new producer can break an old consumer:</p>
This incompatibility risk doesn't just happen when adding or removing a <code>required</code> field directly: the same kind of risk occurs when transitioning an <code>optional</code> field to <code>required</code>, or <code>required</code> to <code>optional</code>.
911
+
This incompatibility risk doesn't just happen when adding or removing a <code>required</code> field directly: the same kind of risk occurs when evolving an <code>optional</code> field to <code>required</code>, or <code>required</code> to <code>optional</code>.
910
912
</p>
911
913
912
914
<!-- TODO: verify that these enums actually explode. I think it might be related to the `required`-ness of the enum field reference. -->
913
915
<!-- TODO explain open and closed enums in an aside https://protobuf.dev/programming-guides/enum/#:~:text=enum%E2%80%99s%20default%20value.-,Implications%20of%20Closed%20Enums,-The%20behavior%20of -->
914
-
<p>Enum evolutions also carry incompatibility risk, <i>when the enum is used as a <code>required</code> field</i>, for example, when narrowing an enum, by removing an enum value. An enum sent by an old producer breaks a new consumer:</p>
916
+
<p>Enum evolutions also carry incompatibility risk, <i>when the enum is used as a <code>required</code> field</i>, for example, when narrowing an enum, by removing an enum value. An enum sent by an old producer can break a new consumer:</p>
<p>In <ahref="https://github.com/stepchowfun/typical#required-optional-and-asymmetric-fields">Typical</a>, the <code>asymmetric</code> label forces writers to provide a non-null value at the construction site but permits
1543
-
readers to deserialize payloads where that value is absent.</p>
1543
+
<p>In <ahref="https://github.com/stepchowfun/typical#required-optional-and-asymmetric-fields">Typical</a> adding the <code>asymmetric</code> label to a field generates code treats the field as required in the constructor, such that it must be parameterized, whilst treating it as optional in its deserializer and by public field access.
1544
+
1544
1545
1545
-
<p>Using the email API example from Typical's tutorial, we can add a new <code>from</code> field to <code>SendEmailRequest</code> via a safe intermediate state:</p>
1546
+
<!-- TODO: should we explicit `required` syntax? Does Typical support that? -->
1547
+
<p>Using the example from Typical README, we can see that by first adding field <code>from</code> with an<code>asymmetric</code> label, we can safely evolve it it to a (labelless) required.</p>
0 commit comments