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

Move events library to core-interfaces and core-utils #23037

Closed

Conversation

sonalideshpandemsft
Copy link
Contributor

@sonalideshpandemsft sonalideshpandemsft commented Nov 8, 2024

This change relocates event library from SharedTree to core-utils and core-interfaces. It updates imports in both the tree and presence packages to reference the event library.

ADO

@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: tree public api change Changes to a public API base: main PRs targeted against main branch labels Nov 8, 2024
@github-actions github-actions bot added area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct dependencies Pull requests that update a dependency file labels Nov 12, 2024
@github-actions github-actions bot removed the dependencies Pull requests that update a dependency file label Nov 12, 2024
@sonalideshpandemsft sonalideshpandemsft changed the title Move events library to core-interfaces Move events library to core-utils Nov 12, 2024
Copy link
Collaborator

@msfluid-bot msfluid-bot left a comment

Choose a reason for hiding this comment

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

Code Coverage Summary

No packages impacted by the change.


Baseline commit: 3fe3fa5
Baseline build: 306842
Happy Coding!!

Code coverage comparison check passed!!

@@ -168,7 +171,7 @@ export class EventEmitter<TListeners extends Listeners<TListeners>>
const eventDescription =
typeof eventName === "symbol" ? eventName.description : String(eventName.toString());

throw new UsageError(
throw new Error(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

UsageError has been replaced with the standard Error type because telemetry-utils cannot be added as a dependency in core-utils, due to a layer-check failure.

fyi: @noencke

@@ -5,7 +5,7 @@

import { strict as assert } from "node:assert";

import { validateAssertionError } from "@fluidframework/test-runtime-utils/internal";
// import { validateAssertionError } from "@fluidframework/test-runtime-utils/internal";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

validateAssertionError has been replaced with the standard Error type because test-runtime-utils cannot be added as a dependency in core-utils, due to a layer-check failure.

fyi, @noencke

@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Nov 14, 2024

@fluid-example/bundle-size-tests: +391 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 465.72 KB 465.75 KB +35 Bytes
azureClient.js 563.04 KB 563.09 KB +49 Bytes
connectionState.js 724 Bytes 724 Bytes No change
containerRuntime.js 262.34 KB 262.35 KB +14 Bytes
fluidFramework.js 426.99 KB 427.08 KB +87 Bytes
loader.js 134.18 KB 134.19 KB +14 Bytes
map.js 42.71 KB 42.71 KB +7 Bytes
matrix.js 149.84 KB 149.85 KB +7 Bytes
odspClient.js 528.83 KB 528.88 KB +49 Bytes
odspDriver.js 97.88 KB 97.9 KB +21 Bytes
odspPrefetchSnapshot.js 42.81 KB 42.83 KB +14 Bytes
sharedString.js 165.77 KB 165.78 KB +7 Bytes
sharedTree.js 417.45 KB 417.53 KB +80 Bytes
Total Size 3.37 MB 3.37 MB +391 Bytes

Baseline commit: 3fe3fa5

Generated by 🚫 dangerJS against 3ec50b1

@sonalideshpandemsft sonalideshpandemsft changed the title Move events library to core-utils Move events library to core-interfaces and core-utils Nov 14, 2024
@sonalideshpandemsft sonalideshpandemsft marked this pull request as ready for review November 14, 2024 17:28
* @system
* @public
*/
export type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (
Copy link
Contributor

Choose a reason for hiding this comment

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

nit. this file doesn't really need to be edited. if you keep your local main branch up to date you can run git checkout main -- packages/dds/tree/src/util/typeUtils.ts to clobber it with the version from main, kind of like a revert. you can even do it on whole sub-paths if you want to undo changes in an area.

Copy link
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

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

I haven't looked at the whole PR, but wondering if client-utils a better fit to move eventing to (core-utils says it's for fluid-agnostic utilities). If the whole set of features we're moving don't have dependencies on Fluid-specific things, then core-utils might be fine, but the fact that core-utils now requires a new dependency on core-interfaces (which contains Fluid-specific types) makes me think that's not the case and that client-utils might indeed be a better target.

Also, we'll want a changeset for this PR.

@@ -4,7 +4,7 @@
*/

/**
* `true` iff the given type is an acceptable shape for a {@link Listeners | event} listener
* `true` if the given type is an acceptable shape for a {@link Listeners | event} listener
Copy link
Contributor

Choose a reason for hiding this comment

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

iff might have been a deliberate abbreviation of "if and only if" but I think in this context it doesn't make a difference.

@@ -3,7 +3,8 @@
* Licensed under the MIT License.
*/

import { type NestedMap, getOrDefaultInNestedMap, setInNestedMap } from "./nestedMap.js";
import type { NestedMap } from "@fluidframework/core-interfaces/internal";
import { getOrDefaultInNestedMap, setInNestedMap } from "./nestedMap.js";
Copy link
Contributor

Choose a reason for hiding this comment

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

With NestedMap moving to a common place, I find it a bit weird that some of the functions to use it are in tree and not in core-utils. Should we move the functions there?

Copy link
Contributor

Choose a reason for hiding this comment

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

I had this same concern but IMO this is too much scope growth. I'm inclined to duplicate what's needed for emitter.ts into client-utils and change none of the utility functions' homes in this PR.

At a glance I'm not a fan of this nested map concept and I think it needs to defend itself in its own PR.

@@ -17,7 +19,6 @@ import type {
JsonSerializable,
} from "@fluid-experimental/presence/internal/core-interfaces";
import type { ISubscribable } from "@fluid-experimental/presence/internal/events";
import { createEmitter } from "@fluid-experimental/presence/internal/events";
Copy link
Contributor

Choose a reason for hiding this comment

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

Tangent: I'm a bit confused here. Presence does all its imports with the full package name instead of relative paths? (cc @jason-ha).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

core-utils also does: https://github.com/microsoft/FluidFramework/blob/main/packages/common/core-utils/src/test/timer.spec.ts#L12. I think that's to avoid adding eslint suppression.

Copy link
Contributor

Choose a reason for hiding this comment

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

It isn't lint suppression.
The best use for "self-references" is in testing. We should test against the public API more. For that we should use package reference where possible. Then we can also see where we are violating API to do certain testing.
Here it is used to manage the temp duplication of the tree events package and workaround api-extractor fussiness. Everything in presence that is using one these complex presence/internal/foo paths has a plan to get rid of them.

@sonalideshpandemsft
Copy link
Contributor Author

I haven't looked at the whole PR, but wondering if client-utils a better fit to move eventing to (core-utils says it's for fluid-agnostic utilities). If the whole set of features we're moving don't have dependencies on Fluid-specific things, then core-utils might be fine, but the fact that core-utils now requires a new dependency on core-interfaces (which contains Fluid-specific types) makes me think that's not the case and that client-utils might indeed be a better target.

Also, we'll want a changeset for this PR.

That's a good point. I thought about adding events to client-utils but the README suggests it's a "dumping ground," so it’s best to avoid adding new functionality in there? Probably it's okay to have core-interfaces as a dependency on core-utils and core-utils not be fluid agnostic utility package?

@anthony-murphy
Copy link
Contributor

I haven't looked at the whole PR, but wondering if client-utils a better fit to move eventing to (core-utils says it's for fluid-agnostic utilities). If the whole set of features we're moving don't have dependencies on Fluid-specific things, then core-utils might be fine, but the fact that core-utils now requires a new dependency on core-interfaces (which contains Fluid-specific types) makes me think that's not the case and that client-utils might indeed be a better target.
Also, we'll want a changeset for this PR.

That's a good point. I thought about adding events to client-utils but the README suggests it's a "dumping ground," so it’s best to avoid adding new functionality in there? Probably it's okay to have core-interfaces as a dependency on core-utils and core-utils not be fluid agnostic utility package?

client-utils is better, but it is fluid-internal :( , so we shouldn't put non-internal things there

@alexvy86
Copy link
Contributor

Probably it's okay to have core-interfaces as a dependency on core-utils and core-utils not be fluid agnostic utility package?

I don't feel too strongly against this, but it seems to me like a good office hours topic. I'm also not sure what I think about client-utils own README stating "In most cases, the code would be better placed in a
package with a clear identity (e.g. an "events" package for shared event infrastructure)
". That sounds like it could lead to even more packages, which we also want to avoid. Well-defined modules within client-utils seems like a better approach to me. But again, probably worth bringing up in office hours.

@alexvy86
Copy link
Contributor

client-utils is better, but it is fluid-internal :( , so we shouldn't put non-internal things there

Yeah, that's probably one of the strongest arguments against it. I think technically nothing prevents us from exposing APIs there as @public and re-exporting them from the appropriate public-facing packages, but that sounds like asking for trouble or complicated rules about how to deal with those APIs. So maybe rebranding core-utils as not necessarily being dependency-free is the way to go.

@jason-ha
Copy link
Contributor

-- Tangent from the client-utils discussion thread --

I haven't looked at the whole PR, but wondering if client-utils a better fit to move eventing to (core-utils says it's for fluid-agnostic utilities). If the whole set of features we're moving don't have dependencies on Fluid-specific things, then core-utils might be fine, but the fact that core-utils now requires a new dependency on core-interfaces (which contains Fluid-specific types) makes me think that's not the case and that client-utils might indeed be a better target.

Also, we'll want a changeset for this PR.

Eventing is fluid agnostic, and I hope remains fluid agnostic. So, I agree we should not mix with fluid dependencies. We also already have eventing support in core-utils. This is part of the transition to replace that.

So, this is perhaps an argument against the suggestion to put the interfaces in core-interfaces.
Either we let the types remain in core-utils (my preference) OR we create a core-utils-interfaces.

@anthony-murphy
Copy link
Contributor

-- Tangent from the client-utils discussion thread --

I haven't looked at the whole PR, but wondering if client-utils a better fit to move eventing to (core-utils says it's for fluid-agnostic utilities). If the whole set of features we're moving don't have dependencies on Fluid-specific things, then core-utils might be fine, but the fact that core-utils now requires a new dependency on core-interfaces (which contains Fluid-specific types) makes me think that's not the case and that client-utils might indeed be a better target.
Also, we'll want a changeset for this PR.

Eventing is fluid agnostic, and I hope remains fluid agnostic. So, I agree we should not mix with fluid dependencies. We also already have eventing support in core-utils. This is part of the transition to replace that.

So, this is perhaps an argument against the suggestion to put the interfaces in core-interfaces. Either we let the types remain in core-utils (my preference) OR we create a core-utils-interfaces.

i don't think we want or should be in the business of creating reusable libraries which are external to fluid, as it's not a support burden we should take on. For the existing eventing it is split between core-interfaces and client-utils, so maybe we just ignore the odd scoping, and go with client-utils anyway.

@jason-ha
Copy link
Contributor

i don't think we want or should be in the business of creating reusable libraries which are external to fluid, as it's not a support burden we should take on. For the existing eventing it is split between core-interfaces and client-utils, so maybe we just ignore the odd scoping, and go with client-utils anyway.

Seems very funny that eventing has types in core-interfaces but core-utils that provides implementation doesn't reference core-interfaces. .... well that is because core-utils doesn't provide implementation (I made bad assumption above). client-utils is providing it. I don't see reason why the implementation shouldn't be in client-utils.

Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> [email protected] ci:linkcheck /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test ci:start 1313 linkcheck:full

1: starting server using command "npm run ci:start"
and when url "[ 'http://127.0.0.1:1313' ]" is responding with HTTP status code 200
running tests using command "npm run linkcheck:full"


> [email protected] ci:start
> http-server ./public --port 1313 --silent


> [email protected] linkcheck:full
> npm run linkcheck:fast -- --external


> [email protected] linkcheck:fast
> linkcheck http://localhost:1313 --skip-file skipped-urls.txt --external

Crawling...

Stats:
  444350 links
    3418 destination URLs
       2 URLs ignored
       0 warnings
       0 errors


@sonalideshpandemsft
Copy link
Contributor Author

I’ve opened a new PR that addresses most of the feedback from this one: #23141

@sonalideshpandemsft sonalideshpandemsft deleted the mv-events-library branch November 21, 2024 09:39
sonalideshpandemsft added a commit that referenced this pull request Nov 22, 2024
This change relocates event library from SharedTree to client-utils and
core-interfaces.

Old PR: #23037


[ADO#6595](https://dev.azure.com/fluidframework/internal/_workitems/edit/6595)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds: tree area: dds Issues related to distributed data structures area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch dependencies Pull requests that update a dependency file public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants