Commit 8ed4f25
authored
improvement(client): improved internal submitMessage, reSubmit, rollback, and submitSignal type-safety (microsoft#24319)
improvement(client): improved internal submitMessage, reSubmit,
rollback, and submitSignal type-safety
In Legacy API:
- Add type parameter to `IEnvelope` for `contents` to support stricter
typing where desired.
- Remove unused parameters from mock `submitMessage` and `submitSignal`
methods.
- Clean up some mock types.
Internally:
- Replace `any` in `ISignalEnvelope` with `unknown`.
- Relocate `FluidDataStoreMessage` to runtime-definitions. Eventually
this can serve as basis for message types for DataStores.
- In `datastore`, create `LocalFluidDataStoreRuntimeMessage`
representing the two known messages for DataStores.
- `FluidDataStoreContext` requires `OutboundFluidDataStoreMessage` for
stricter `reSubmit` and `rollback` methods.
- Create `IFluidRootParentContextPrivate` for the transition from
DataStore to `ContainerRuntime` and use explicit types in
`ContainerRuntime` and `ChannelCollection`.
- In `ChannelCollection` restore some old method names with strict
typing that internal callers must conform to. The
`IFluidDataStoreChannel` portions that were not required by current use
were refactored to new `ComposableChannelCollection` class.
- Replace `wrapContext` with `formParentContext` that handles both
`IFluidParentContextPrivate` and `IFluidRootParentContextPrivate` by
requiring the specific `submitMessage` and `submitSignal` functions
- Within `ContainerRuntime`:
- Update `submitMessage` to expect specific messages
- Update `submitSignal` to expect new
`AddressedUnsequencedSignalEnvelope` that is specific subset of
`ISignalEnvelope` and is exactly
`IEnvelope<ISignalEnvelope["contents"]>`
- Fixup tests to use more realistic data (as required by stricter
typing).
Potential Future Improvements:
- Change {@link IFluidDataStoreChannel} and {@link IFluidParentContext},
to have a generic specifying `T extends FluidDataStoreMessage` and uses
`T["type"]` and `T["content"]` to qualify message related methods,
preferably where `submitMessage`, `reSubmit`, and `rollback` have
overloads to ensure callers pair values correctly.
- A further improvement would be to reshape `submitMessage`, `reSubmit`,
and `rollback` to accept `T` as `message` parameter instead of `type`
and `content` parameters that are hard to convince TypeScript must be
paired in implementations.1 parent 474c6bd commit 8ed4f25
File tree
24 files changed
+715
-366
lines changed- packages
- framework/attributor/src
- runtime
- container-runtime/src
- test
- opLifecycle
- datastore/src
- runtime-definitions
- api-report
- src
- test-runtime-utils
- api-report
- src
- test/local-server-tests/src/test
24 files changed
+715
-366
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| |||
0 commit comments