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

Migrate four more shared objects to use SharedObjectKind #20985

Merged
merged 6 commits into from
May 9, 2024

Conversation

CraigMacomber
Copy link
Contributor

@CraigMacomber CraigMacomber commented May 4, 2024

Description

These are all internal or alpha, and still export the classes in case something actually needs them.

This continues the work in changes like #20939, moving away from depending the SharedObject subclasses directly as factories and using the common SharedObjectKind type to allow sharing of docs and implementations for the factory APIs.

Breaking Changes

Users of SharedNumberSequence, SharedObjectSequence, SparseMatrix or ConsensusQueue will need to update their code to use the *Class exports if they have a dependency on something static from class that's not on the shared object kind, like its constructor.

Reviewer Guidance

The review process is outlined on this wiki page.

@CraigMacomber CraigMacomber requested a review from a team as a code owner May 4, 2024 00:38
@github-actions github-actions bot added area: dds Issues related to distributed data structures area: tests Tests to add, test infrastructure improvements, etc public api change Changes to a public API base: main PRs targeted against main branch labels May 4, 2024
Copy link
Contributor

@jzaffiro jzaffiro left a comment

Choose a reason for hiding this comment

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

A few minor comments, but generally looks good to me.

@@ -14,6 +14,9 @@ import { IJSONRunSegment } from '@fluidframework/sequence/internal';
import { IJSONSegment } from '@fluidframework/merge-tree/internal';
import { ISegment } from '@fluidframework/merge-tree/internal';
import { ISharedObject } from '@fluidframework/shared-object-base';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectKind as ISharedObjectKind_2 } from '@fluidframework/shared-object-base';
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for both imports, especially with one being 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.

This is due to microsoft/rushstack#4654 interacting poorly with how we do our release tag scoping. Its possible to avoid it if you ensure all imports of something that are also exported use the same exact import path, across all our packages. I'll see if its easy to work around in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

imports match in are identical in this package, so this is a new case of this problem for me. Fortunately, it just impacts API extractor reports (but maybe also docs? But we don't currently do docs for alpha/internal, so this should not matter). Thus I see no way to fix this, and no significant cost to leaving it, so I think I'll leave it, though it would be nice to understand better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, it just seemed a bit odd to me but it seems fine to leave in then.

@@ -14,7 +14,12 @@ import {
MockStorage,
} from "@fluidframework/test-runtime-utils/internal";

import { SparseMatrix, SparseMatrixFactory, SparseMatrixItem } from "../sparsematrix.js";
import {
SparseMatrix,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed if we now have SparseMatrixClass?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SparseMatrixClass could be used instead as a type (currently they are the same since sparse matrix does not define an interface like most of our shared object, which is required for it to avoid leaking its class (and thus SharedObject) into the API. Since its only @internal that seems fine.

Anyway, looking at the test usage, migrating this to use SparseMatrixClass type would produce a larger diff for no real gain, but I did see it could use the newer factory pattern to create instance in the test via SparseMatrix.create, so I updated it to use that.

@msfluid-bot
Copy link
Collaborator

Could not find a usable baseline build with search starting at CI 158d988

Generated by 🚫 dangerJS against bf53366

@CraigMacomber CraigMacomber merged commit 2b183f4 into microsoft:main May 9, 2024
30 checks passed
@CraigMacomber CraigMacomber deleted the fact4 branch May 9, 2024 00:50
CraigMacomber added a commit that referenced this pull request May 13, 2024
These are all internal or alpha, and still export the classes in case
something actually needs them.

This continues the work in changes like
#20939 and
#20985 moving away from
depending the SharedObject subclasses directly as factories and using
the common SharedObjectKind type to allow sharing of docs and
implementations for the factory APIs.

## Breaking Changes

Users of PactMap, SharedSummaryBlock or TaskManager may need to adjust
their code if their use did not align with the intended patterns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds Issues related to distributed data structures area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants