Skip to content
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

improvement(client): Cleanup presence manager interface #22553

Merged
merged 2 commits into from
Sep 21, 2024

Conversation

jason-ha
Copy link
Contributor

@jason-ha jason-ha commented Sep 17, 2024

to distinguish internal needs and external uses. IPresenceManager is removed (was accidentally duplicated) and became three distinct parts:

  • IPresence (public user interface)
  • PresenceManagerInternal (needs of internal presence sub-components)
  • PresenceExtensionInterface (for future container hostable)
    • Push on("signal" up to temp DataObject and use processSignal for both paths.
    • submitSignal still needs managed.

Relocate IEphemeralRuntime to internalTypes.ts to help avoid circular dependencies.

@github-actions github-actions bot added base: main PRs targeted against main branch area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct labels Sep 17, 2024
@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Sep 17, 2024

@fluid-example/bundle-size-tests: +245 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 460.44 KB 460.47 KB +35 Bytes
azureClient.js 559.03 KB 559.08 KB +49 Bytes
connectionState.js 680 Bytes 680 Bytes No change
containerRuntime.js 261.68 KB 261.69 KB +14 Bytes
fluidFramework.js 403.45 KB 403.47 KB +14 Bytes
loader.js 134.17 KB 134.19 KB +14 Bytes
map.js 42.43 KB 42.44 KB +7 Bytes
matrix.js 145.87 KB 145.88 KB +7 Bytes
odspClient.js 526.18 KB 526.23 KB +49 Bytes
odspDriver.js 97.8 KB 97.82 KB +21 Bytes
odspPrefetchSnapshot.js 42.76 KB 42.78 KB +14 Bytes
sharedString.js 162.84 KB 162.84 KB +7 Bytes
sharedTree.js 393.92 KB 393.92 KB +7 Bytes
Total Size 3.3 MB 3.3 MB +245 Bytes

Baseline commit: e84ac46

Generated by 🚫 dangerJS against b973533

function assertSignalMessageIsValid(
message: IInboundSignalMessage | IExtensionMessage,
): asserts message is IExtensionMessage {
assert(message.clientId !== null, "Signal must have a client ID");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this source or target clientID? Self-descriptive names are usually helpful :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the long standing id for the client that sent the message. Renaming is not going to happen. A message with a target client id uses the property name targetClientId.

@@ -26,7 +38,12 @@ class PresenceManagerDataObject extends LoadableFluidObject {
if (!this._presenceManager) {
// TODO: investigate if ContainerExtensionStore (path-based address routing for
// Signals) is readily detectable here and use that presence manager directly.
this._presenceManager = createPresenceManager(this.runtime);
const manager = createPresenceManager(this.runtime);
this.runtime.on("signal", (message: IInboundSignalMessage, local: boolean) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious on why listening on events here? For a second I thought you are trying to decouple it from runtime, but runtime is still passed to presence manager.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a move in that direction (to remove IFluidDataStoreRuntime from use). Eventually only IExtensionRuntime will be this package's connection to container runtime (IExtensionRuntime will probably be a subset of IContainerRuntime). But until container extension feature is implemented we are using IFluidDataStoreRuntime. One pattern that is different between connected as DataObject with IFluidDataStoreRuntime and connected as container extension is how inbound signals are sent. For container extension pattern, the extension [optionally] provides processSignal (see PresenceExtensionInterface). Here were are adapting DataObject to look more like the container extension host. So:

  • listen to "signal" event here and call manager's processSignal
  • do pass IFluidDataStoreRuntime down to manager but as IEphemeralRuntime which is the local definition of all of the things it needs from IExtensionRuntime eventually. You won't see IExtensionRuntime in IEphemeralRuntime because IExtensionRuntime is so unbaked as are the actual needs of presence. IContainerRuntime is the temporary proxy for IExtensionRuntime.

Super clear, right? We made a number of compromises to be able to get the basic functionality out and work with system as it is. This entire file will eventually disappear.

to distinguish internal needs and external uses. IPresenceManager became three parts:
- IPresence (public user interface)
- PresenceManagerInternal (needs of internal presence components)
- PresenceExtensionInterface (for future container hostable)
   - Push `on("signal"` up to temp DataObject and use `processSignal` for both paths.
   - `submitSignal` still needs managed.
@jason-ha jason-ha force-pushed the presence/manager-interface-refactor branch from 50a57d1 to b973533 Compare September 21, 2024 17:47
@jason-ha jason-ha enabled auto-merge (squash) September 21, 2024 17:50
@jason-ha jason-ha merged commit e7a2f48 into microsoft:main Sep 21, 2024
30 checks passed
@jason-ha jason-ha deleted the presence/manager-interface-refactor branch September 23, 2024 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants