Skip to content

Commit 8ed4f25

Browse files
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

24 files changed

+715
-366
lines changed

packages/framework/attributor/src/runtimeAttributorDataStoreChannel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export class RuntimeAttributorDataStoreChannel
189189
/**
190190
* {@inheritdoc IFluidDataStoreChannel.reSubmit}
191191
*/
192-
public reSubmit(type: string, content: unknown, localOpMetadata: unknown): void {
192+
public reSubmit(): void {
193193
// Should not resubmit anything from the attributor as the attributor does not send ops yet.
194194
throw new Error("Should not resubmit anything from the attributor");
195195
}

0 commit comments

Comments
 (0)