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

refactor(server): Remove dependency on common-utils #23998

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9e6eec4
Copy Deferred to server-services-core
alexvy86 Mar 6, 2025
3d5e648
Remove common-utils from server-services-core
alexvy86 Mar 6, 2025
0cc0179
Remove common-utils from server-lambdas
alexvy86 Mar 6, 2025
f6d3793
Remove common-utils from server-memory-orderer
alexvy86 Mar 6, 2025
ea50fd7
Remove common-utils from server-routerlicious-base
alexvy86 Mar 6, 2025
dac8602
Remove common-utils from server-services
alexvy86 Mar 6, 2025
a0041bb
Remove common-utils from server-services-shared
alexvy86 Mar 6, 2025
8d42abc
Remove common-utils from server-services-telemetry
alexvy86 Mar 6, 2025
11f9146
Remove common-utils from tinylicious
alexvy86 Mar 6, 2025
647b54e
Remove common-utils from server-test-utils
alexvy86 Mar 6, 2025
a1c251c
Move to new server-common-utils
alexvy86 Mar 6, 2025
fb6d9f2
Move protocol-base to server-common-utils
alexvy86 Mar 6, 2025
c9bf24a
Move some things to the single packages that use them
alexvy86 Mar 6, 2025
3fbb74b
Remove commented code
alexvy86 Mar 6, 2025
800b0e0
Remove some deprecated tags
alexvy86 Mar 6, 2025
cc345b6
Formatting
alexvy86 Mar 6, 2025
b3ee169
Use assert from server-common-utils
alexvy86 Mar 6, 2025
7c83341
Formatting
alexvy86 Mar 6, 2025
a883e05
Remove more unneded lint disable comments
alexvy86 Mar 6, 2025
01001de
Fix docs
alexvy86 Mar 6, 2025
abc1360
Undo assert changes
alexvy86 Mar 6, 2025
545804d
Cleanup and fix build of server-common-utils
alexvy86 Mar 6, 2025
5ae6f21
Cleanup tests; remove jest
alexvy86 Mar 6, 2025
d8e488d
Move assert to server-services-client
alexvy86 Mar 6, 2025
186ef46
Move Deferred to services-core
alexvy86 Mar 6, 2025
2d60abf
Move delay to services-core
alexvy86 Mar 6, 2025
d533b2b
Move unreachable to the packages that use it
alexvy86 Mar 6, 2025
02eb780
Move TypedEventEmitter
alexvy86 Mar 6, 2025
838bc6f
Move node+browser utils to services-client
alexvy86 Mar 6, 2025
10730f8
Remove server-common-utils
alexvy86 Mar 7, 2025
3b0fe6d
Cleanup
alexvy86 Mar 7, 2025
10f6549
Add puppeteer devDep
alexvy86 Mar 7, 2025
c479fa7
Fix protocol-base use of events/events_pkg
alexvy86 Mar 7, 2025
fe43244
Try adding missing jest-environment-puppeteer
alexvy86 Mar 7, 2025
e8981f0
Change how we run jest tests in CI
alexvy86 Mar 7, 2025
1e25cd4
Dep for jest tests in Dockerfile
alexvy86 Mar 7, 2025
617ea8a
More deps for jest tests
alexvy86 Mar 7, 2025
fe22d79
More deps
alexvy86 Mar 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion fluidBuild.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,10 @@ module.exports = {
// TODO: AB#7630 uses lint only ts projects for coverage which don't have representative tsc scripts
"^packages/tools/fluid-runner/package.json",
],
"fluid-build-tasks-tsc": [],
"fluid-build-tasks-tsc": [
// Not seeing the dependencies it wants even when I add them
"^server/routerlicious/packages/services-client/package.json",
],
"html-copyright-file-header": [
// Tests generate HTML "snapshot" artifacts
"tools/api-markdown-documenter/src/test/snapshots/.*",
Expand Down
6 changes: 6 additions & 0 deletions server/routerlicious/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ RUN apt-get update && apt-get install -y \
libssl-dev \
ca-certificates

# dependencies to run jest tests
RUN apt-get update && apt-get install -y \
libglib2.0-0 \
libnss3 \
libdbus-1-3

# Add Tini
ENV TINI_VERSION=v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
Expand Down
2 changes: 1 addition & 1 deletion server/routerlicious/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"test:copyresults": "copyfiles --exclude \"**/node_modules/**\" \"packages/**/nyc/**\" nyc",
"test:coverage": "c8 npm run test:report",
"test:fromroot": "mocha \"packages/**/dist/test/**/*.spec.*js\" --exit",
"test:report": "pnpm run -r --no-sort --stream --no-bail test -- -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
"test:report": "pnpm run -r --no-sort --stream --no-bail test -- -- --reporter xunit --reporter-option output=nyc/junit-report.xml && pnpm run -r --no-sort --stream --no-bail test:jest",
"tsc": "pnpm run -r --stream tsc",
"typetests:gen": "pnpm -r typetests:gen",
"typetests:prepare": "flub typetests -g server --reset --normalize",
Expand Down
1 change: 0 additions & 1 deletion server/routerlicious/packages/lambdas-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"temp-directory": "nyc/.nyc_output"
},
"dependencies": {
"@fluidframework/common-utils": "^3.1.0",
"@fluidframework/server-services-client": "workspace:~",
"@fluidframework/server-services-core": "workspace:~",
"@fluidframework/server-services-telemetry": "workspace:~",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
*/

import assert from "assert";
import { Deferred } from "@fluidframework/common-utils";
import { IConsumer, IQueuedMessage } from "@fluidframework/server-services-core";
import { Deferred, IConsumer, IQueuedMessage } from "@fluidframework/server-services-core";
import { Lumberjack } from "@fluidframework/server-services-telemetry";

export class CheckpointManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import { inspect } from "util";
import { serializeError } from "serialize-error";
import { Deferred } from "@fluidframework/common-utils";
import { promiseTimeout } from "@fluidframework/server-services-client";
import {
Deferred,
IConsumer,
IContextErrorData,
ILogger,
Expand Down
1 change: 0 additions & 1 deletion server/routerlicious/packages/lambdas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"temp-directory": "nyc/.nyc_output"
},
"dependencies": {
"@fluidframework/common-utils": "^3.1.0",
"@fluidframework/gitresources": "workspace:~",
"@fluidframework/protocol-base": "workspace:~",
"@fluidframework/protocol-definitions": "^3.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import { Heap, IComparer, IHeapNode } from "@fluidframework/common-utils";
import { Heap, IComparer, IHeapNode } from "./heap";
import { IClientSequenceNumber } from "@fluidframework/server-services-core";

const SequenceNumberComparer: IComparer<IClientSequenceNumber> = {
Expand Down
158 changes: 158 additions & 0 deletions server/routerlicious/packages/lambdas/src/deli/heap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/

/**
* Interface for a comparer.
*/
export interface IComparer<T> {
/**
* The minimum value of type T.
*/
min: T;

/**
* Compare the two value
*
* @returns 0 if the value is equal, negative number if a is smaller then b, positive number otherwise
*/
compare(a: T, b: T): number;
}

/**
* Interface to a node in {@link Heap}.
*/
export interface IHeapNode<T> {
value: T;
position: number;
}

/**
* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
*/
export class Heap<T> {
private L: IHeapNode<T>[];

/**
* Creates an instance of `Heap` with comparer.
* @param comp - A comparer that specify how elements are ordered.
*/
constructor(public comp: IComparer<T>) {
this.L = [{ value: comp.min, position: 0 }];
}

/**
* Return the smallest element in the heap as determined by the order of the comparer
*
* @returns Heap node containing the smallest element
*/
public peek(): IHeapNode<T> {
return this.L[1];
}

/**
* Get and remove the smallest element in the heap as determined by the order of the comparer
*
* @returns The smallest value in the heap
*/
public get(): T {
this.swap(1, this.count());
const x = this.L.pop();
this.fixdown(1);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return x!.value;
}

/**
* Add a value to the heap
*
* @param x - value to add
* @returns The heap node that contains the value
*/
public add(x: T): IHeapNode<T> {
const node = { value: x, position: this.L.length };
this.L.push(node);
this.fixup(this.count());

return node;
}

/**
* Allows for the Heap to be updated after a node's value changes.
*/
public update(node: IHeapNode<T>): void {
const k = node.position;
if (this.isGreaterThanParent(k)) {
this.fixup(k);
} else {
this.fixdown(k);
}
}

/**
* Removes the given node from the heap.
*
* @param node - The node to remove from the heap.
*/
public remove(node: IHeapNode<T>): void {
// Move the node we want to remove to the end of the array
const position = node.position;
this.swap(node.position, this.L.length - 1);
this.L.splice(-1);

// Update the swapped node assuming we didn't remove the end of the list
if (position !== this.L.length) {
this.update(this.L[position]);
}
}

/**
* Get the number of elements in the Heap.
*
* @returns The number of elements in the Heap.
*/
public count(): number {
return this.L.length - 1;
}

private fixup(pos: number): void {
let k = pos;
while (this.isGreaterThanParent(k)) {
// eslint-disable-next-line no-bitwise
const parent = k >> 1;
this.swap(k, parent);
k = parent;
}
}

private isGreaterThanParent(k: number): boolean {
// eslint-disable-next-line no-bitwise
return k > 1 && this.comp.compare(this.L[k >> 1].value, this.L[k].value) > 0;
}

private fixdown(pos: number): void {
let k = pos;
// eslint-disable-next-line no-bitwise
while (k << 1 <= this.count()) {
// eslint-disable-next-line no-bitwise
let j = k << 1;
if (j < this.count() && this.comp.compare(this.L[j].value, this.L[j + 1].value) > 0) {
j++;
}
if (this.comp.compare(this.L[k].value, this.L[j].value) <= 0) {
break;
}
this.swap(k, j);
k = j;
}
}

private swap(k: number, j: number): void {
const tmp = this.L[k];
this.L[k] = this.L[j];
this.L[k].position = k;
this.L[j] = tmp;
this.L[j].position = j;
}
}
2 changes: 1 addition & 1 deletion server/routerlicious/packages/lambdas/src/deli/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
ISequencedSignalClient,
IClientManager,
ICheckpointService,
TypedEventEmitter,
} from "@fluidframework/server-services-core";
import {
CommonProperties,
Expand All @@ -64,7 +65,6 @@ import {
Lumberjack,
} from "@fluidframework/server-services-telemetry";
import { DocumentContext } from "@fluidframework/server-lambdas-driver";
import { TypedEventEmitter } from "@fluidframework/common-utils";
import { IEvent } from "../events";
import {
logCommonSessionEndMetrics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import { EventEmitter } from "events";
import { inspect } from "util";
import { toUtf8 } from "@fluidframework/common-utils";
import {
ICheckpointService,
IClientManager,
Expand All @@ -25,7 +24,7 @@ import {
MongoManager,
requestWithRetry,
} from "@fluidframework/server-services-core";
import { defaultHash, IGitManager } from "@fluidframework/server-services-client";
import { defaultHash, IGitManager, toUtf8 } from "@fluidframework/server-services-client";
import {
Lumber,
LumberEventName,
Expand Down
3 changes: 1 addition & 2 deletions server/routerlicious/packages/lambdas/src/nexus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License.
*/

import { TypedEventEmitter } from "@fluidframework/common-utils";
import {
IClient,
IConnect,
Expand Down Expand Up @@ -112,7 +111,7 @@ export function configureWebSocketServices(
verifyMaxMessageSize?: boolean,
socketTracker?: core.IWebSocketTracker,
revokedTokenChecker?: core.IRevokedTokenChecker,
collaborationSessionEventEmitter?: TypedEventEmitter<ICollaborationSessionEvents>,
collaborationSessionEventEmitter?: core.TypedEventEmitter<ICollaborationSessionEvents>,
clusterDrainingChecker?: core.IClusterDrainingChecker,
collaborationSessionTracker?: core.ICollaborationSessionTracker,
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License.
*/

import type { TypedEventEmitter } from "@fluidframework/common-utils";
import type { IClient, IConnected } from "@fluidframework/protocol-definitions";
import type {
IClientManager,
Expand All @@ -17,6 +16,7 @@ import type {
IThrottleAndUsageStorageManager,
IThrottler,
IWebSocketTracker,
TypedEventEmitter,
} from "@fluidframework/server-services-core";
import { IEvent } from "../events";
import type { IRuntimeSignalEnvelope } from "../utils";
Expand Down
1 change: 0 additions & 1 deletion server/routerlicious/packages/lambdas/src/nexus/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License.
*/

import { performance } from "@fluidframework/common-utils";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Server code only runs in node, it can use the native performance.now() directly, no need to try to proxy through an isomorphic performance object (which incidentally was already removed in main for the client release group).

import type { IDocumentMessage } from "@fluidframework/protocol-definitions";
import { getRandomInt } from "@fluidframework/server-services-client";
import { DefaultServiceConfiguration } from "@fluidframework/server-services-core";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License.
*/

import { delay } from "@fluidframework/common-utils";
import {
delay,
ICollection,
IContext,
isRetryEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License.
*/

import { bufferToString, toUtf8 } from "@fluidframework/common-utils";
import {
IDocumentAttributes,
ISequencedDocumentMessage,
Expand All @@ -13,6 +12,8 @@ import {
IGitManager,
IWholeFlatSummary,
LatestSummaryId,
bufferToString,
toUtf8,
} from "@fluidframework/server-services-client";
import {
IDeliState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License.
*/

import { fromBase64ToUtf8 } from "@fluidframework/common-utils";
import { ICreateCommitParams, ICreateTreeEntry } from "@fluidframework/gitresources";
import {
ISequencedDocumentMessage,
Expand All @@ -17,6 +16,7 @@ import {
} from "@fluidframework/protocol-definitions";
import {
buildTreePath,
fromBase64ToUtf8,
IGitManager,
ISummaryTree,
NetworkError,
Expand Down
1 change: 0 additions & 1 deletion server/routerlicious/packages/local-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"temp-directory": "nyc/.nyc_output"
},
"dependencies": {
"@fluidframework/common-utils": "^3.1.0",
"@fluidframework/protocol-definitions": "^3.2.0",
"@fluidframework/server-lambdas": "workspace:~",
"@fluidframework/server-memory-orderer": "workspace:~",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { strict as assert } from "assert";
import { Deferred } from "@fluidframework/common-utils";
import {
ConnectionMode,
IClient,
Expand All @@ -17,7 +16,7 @@ import {
MessageType,
ScopeType,
} from "@fluidframework/protocol-definitions";
import { IWebSocket } from "@fluidframework/server-services-core";
import { Deferred, IWebSocket } from "@fluidframework/server-services-core";
import { KJUR as jsrsasign } from "jsrsasign";
import { TestNotImplementedDocumentRepository } from "@fluidframework/server-test-utils";
import Sinon from "sinon";
Expand Down
1 change: 0 additions & 1 deletion server/routerlicious/packages/memory-orderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"temp-directory": "nyc/.nyc_output"
},
"dependencies": {
"@fluidframework/common-utils": "^3.1.0",
"@fluidframework/protocol-base": "workspace:~",
"@fluidframework/protocol-definitions": "^3.2.0",
"@fluidframework/server-lambdas": "workspace:~",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License.
*/

import { performance } from "@fluidframework/common-utils";
import {
IClient,
IClientJoin,
Expand Down
Loading
Loading