Skip to content

Commit

Permalink
chore: rename service-provider-server and CliServiceProvider (#2232)
Browse files Browse the repository at this point in the history
`ServiceProvider` is our abstraction for how mongosh interacts with the database.
The two notable implementations of that that are actually being used are based on
the Node.js driver and the Java driver, respectively.

Neither `CliServiceProvider` (has no inherent connection with CLI usage) nor
`service-provider-server` (connects to the same servers as any other service
provider would) are great names and only reflect the historical architecture for
mongosh at this point.

So, let's rename this to something that accurately reflects what this service
provider implementation is and what distinguishes it from others!
addaleax authored Oct 23, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 80f8b19 commit c18016a
Showing 44 changed files with 569 additions and 484 deletions.
668 changes: 334 additions & 334 deletions .evergreen.yml

Large diffs are not rendered by default.

55 changes: 44 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@
"packages/logging",
"packages/service-provider-core",
"packages/arg-parser",
"packages/service-provider-server",
"packages/service-provider-node-driver",
"packages/shell-api",
"packages/autocomplete",
"packages/shell-evaluator",
2 changes: 1 addition & 1 deletion packages/browser-runtime-electron/package.json
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
"@mongodb-js/prettier-config-devtools": "^1.0.1",
"@mongodb-js/tsconfig-mongosh": "^1.0.0",
"@mongosh/service-provider-server": "0.0.0-dev.0",
"@mongosh/service-provider-node-driver": "0.0.0-dev.0",
"@types/sinon": "^7.5.1",
"@types/sinon-chai": "^3.2.4",
"depcheck": "^1.4.7",
Original file line number Diff line number Diff line change
@@ -5,20 +5,20 @@ import sinonChai from 'sinon-chai';
chai.use(sinonChai);
const { expect } = chai;

import { CliServiceProvider } from '@mongosh/service-provider-server';
import { NodeDriverServiceProvider } from '@mongosh/service-provider-node-driver';
import { bson } from '@mongosh/service-provider-core';
import { ElectronRuntime } from './electron-runtime';
import { EventEmitter } from 'events';
import type { RuntimeEvaluationListener } from '@mongosh/browser-runtime-core';

describe('Electron runtime', function () {
let serviceProvider: SinonStubbedInstance<CliServiceProvider>;
let serviceProvider: SinonStubbedInstance<NodeDriverServiceProvider>;
let messageBus: SinonStubbedInstance<EventEmitter>;
let evaluationListener: SinonStubbedInstance<RuntimeEvaluationListener>;
let electronRuntime: ElectronRuntime;

beforeEach(function () {
serviceProvider = sinon.createStubInstance(CliServiceProvider);
serviceProvider = sinon.createStubInstance(NodeDriverServiceProvider);
serviceProvider.bsonLibrary = bson;
serviceProvider.getConnectionInfo.resolves({
extraInfo: { uri: '' },
13 changes: 8 additions & 5 deletions packages/build/src/compile/signable-compiler.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import { compileJSFileAsBinary } from 'boxednode';
async function preCompileHook(nodeSourceTree: string) {
const fleAddonVersion = require(path.join(
await findModulePath(
'service-provider-server',
'service-provider-node-driver',
'mongodb-client-encryption'
),
'package.json'
@@ -108,17 +108,20 @@ export class SignableCompiler {
async compile(): Promise<void> {
const fleAddon = {
path: await findModulePath(
'service-provider-server',
'service-provider-node-driver',
'mongodb-client-encryption'
),
requireRegexp: /\bmongocrypt\.node$/,
};
const kerberosAddon = {
path: await findModulePath('service-provider-server', 'kerberos'),
path: await findModulePath('service-provider-node-driver', 'kerberos'),
requireRegexp: /\bkerberos\.node$/,
};
const osDnsAddon = {
path: await findModulePath('service-provider-server', 'os-dns-native'),
path: await findModulePath(
'service-provider-node-driver',
'os-dns-native'
),
requireRegexp: /\bos_dns_native\.node$/,
};
const cryptLibraryVersionAddon = {
@@ -130,7 +133,7 @@ export class SignableCompiler {
requireRegexp: /\bglibc_version\.node$/,
};
// Warning! Until https://jira.mongodb.org/browse/MONGOSH-990,
// packages/service-provider-server *also* has a copy of these.
// packages/service-provider-node-driver *also* has a copy of these.
// We use the versions included in packages/cli-repl here, so these
// should be kept in sync!
const winCAAddon =
2 changes: 1 addition & 1 deletion packages/cli-repl/package.json
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@
"@mongosh/js-multiline-to-singleline": "0.0.0-dev.0",
"@mongosh/logging": "0.0.0-dev.0",
"@mongosh/service-provider-core": "0.0.0-dev.0",
"@mongosh/service-provider-server": "0.0.0-dev.0",
"@mongosh/service-provider-node-driver": "0.0.0-dev.0",
"@mongosh/shell-api": "0.0.0-dev.0",
"@mongosh/shell-evaluator": "0.0.0-dev.0",
"@mongosh/snippet-manager": "0.0.0-dev.0",
6 changes: 3 additions & 3 deletions packages/cli-repl/src/build-info.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os from 'os';
import { CliServiceProvider } from '@mongosh/service-provider-server';
import { NodeDriverServiceProvider } from '@mongosh/service-provider-node-driver';

export interface BuildInfo {
version: string;
@@ -16,7 +16,7 @@ export interface BuildInfo {
sharedOpenssl: boolean;
segmentApiKey?: string;
runtimeGlibcVersion: string;
deps: ReturnType<typeof CliServiceProvider.getVersionInformation>;
deps: ReturnType<typeof NodeDriverServiceProvider.getVersionInformation>;
}

function getSystemArch(): (typeof process)['arch'] {
@@ -79,7 +79,7 @@ export async function buildInfo({
withSegmentApiKey?: boolean;
} = {}): Promise<BuildInfo> {
const dependencyVersionInfo: BuildInfo['deps'] = {
...CliServiceProvider.getVersionInformation(),
...NodeDriverServiceProvider.getVersionInformation(),
};

const buildInfo = { ...baseBuildInfo(), deps: { ...dependencyVersionInfo } };
2 changes: 1 addition & 1 deletion packages/cli-repl/src/cli-repl.spec.ts
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ import ConnectionString from 'mongodb-connection-string-url';
import type { CliReplOptions } from './cli-repl';
import { CliRepl } from './cli-repl';
import { CliReplErrors } from './error-codes';
import type { DevtoolsConnectOptions } from '@mongosh/service-provider-server';
import type { DevtoolsConnectOptions } from '@mongosh/service-provider-node-driver';
import type { AddressInfo } from 'net';
const { EJSON } = bson;

6 changes: 3 additions & 3 deletions packages/cli-repl/src/cli-repl.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import { redactURICredentials } from '@mongosh/history';
import i18n from '@mongosh/i18n';
import type { AutoEncryptionOptions } from '@mongosh/service-provider-core';
import { bson } from '@mongosh/service-provider-core';
import { CliServiceProvider } from '@mongosh/service-provider-server';
import { NodeDriverServiceProvider } from '@mongosh/service-provider-node-driver';
import type { CliOptions, DevtoolsConnectOptions } from '@mongosh/arg-parser';
import { SnippetManager } from '@mongosh/snippet-manager';
import { Editor } from '@mongosh/editor';
@@ -829,7 +829,7 @@ export class CliRepl implements MongoshIOProvider {
async connect(
driverUri: string,
driverOptions: DevtoolsConnectOptions
): Promise<CliServiceProvider> {
): Promise<NodeDriverServiceProvider> {
const { quiet } = CliRepl.getFileAndEvalInfo(this.cliOptions);
if (!this.cliOptions.nodb && !quiet) {
this.output.write(
@@ -839,7 +839,7 @@ export class CliRepl implements MongoshIOProvider {
'\n'
);
}
return await CliServiceProvider.connect(
return await NodeDriverServiceProvider.connect(
driverUri,
driverOptions,
this.cliOptions,
2 changes: 1 addition & 1 deletion packages/i18n/src/locales/en_US.ts
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ const translations: Catalog = {
},
'service-provider-browser': {},
'service-provider-core': {},
'service-provider-server': {},
'service-provider-node-driver': {},
'shell-api': {
classes: {
ShellApi: {
2 changes: 1 addition & 1 deletion packages/node-runtime-worker-thread/package.json
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
"@mongosh/browser-runtime-core": "0.0.0-dev.0",
"@mongosh/browser-runtime-electron": "0.0.0-dev.0",
"@mongosh/service-provider-core": "0.0.0-dev.0",
"@mongosh/service-provider-server": "0.0.0-dev.0",
"@mongosh/service-provider-node-driver": "0.0.0-dev.0",
"@mongosh/types": "0.0.0-dev.0",
"bson": "^6.8.0",
"depcheck": "^1.4.7",
2 changes: 1 addition & 1 deletion packages/node-runtime-worker-thread/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import type { MongoshBus } from '@mongosh/types';
import { startSharedTestServer } from '../../../testing/integration-testing-hooks';
import { WorkerRuntime } from '../dist/index';

import type { DevtoolsConnectOptions } from '@mongosh/service-provider-server';
import type { DevtoolsConnectOptions } from '@mongosh/service-provider-node-driver';

export const dummyOptions: DevtoolsConnectOptions = Object.freeze({
productName: 'Test Product',
2 changes: 1 addition & 1 deletion packages/node-runtime-worker-thread/src/index.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ import {
deserializeEvaluationResult,
serializeConnectOptions,
} from './serializer';
import type { CompassServiceProvider } from '@mongosh/service-provider-server';
import type { CompassServiceProvider } from '@mongosh/service-provider-node-driver';
import type { InterruptHandle } from 'interruptor';
import { interrupt as nativeInterrupt } from 'interruptor';
import { WorkerThreadEvaluationListener } from './worker-thread-evaluation-listener';
2 changes: 1 addition & 1 deletion packages/node-runtime-worker-thread/src/serializer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DevtoolsConnectOptions } from '@mongosh/service-provider-server/lib/cli-service-provider';
import type { DevtoolsConnectOptions } from '@mongosh/service-provider-node-driver';
import { expect } from 'chai';
import { UUID, Long } from 'bson';
import {
2 changes: 1 addition & 1 deletion packages/node-runtime-worker-thread/src/serializer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { inspect } from 'util';
import { EJSON } from 'bson';
import type { RuntimeEvaluationResult } from '@mongosh/browser-runtime-core';
import type { DevtoolsConnectOptions } from '@mongosh/service-provider-server';
import type { DevtoolsConnectOptions } from '@mongosh/service-provider-node-driver';

function isPrimitive(
val: any
2 changes: 1 addition & 1 deletion packages/node-runtime-worker-thread/src/worker-runtime.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import type {
} from '@mongosh/browser-runtime-core';
import { ElectronRuntime } from '@mongosh/browser-runtime-electron';
import type { ServiceProvider } from '@mongosh/service-provider-core';
import { CompassServiceProvider } from '@mongosh/service-provider-server';
import { CompassServiceProvider } from '@mongosh/service-provider-node-driver';
import { exposeAll, createCaller } from './rpc';
import {
serializeEvaluationResult,
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@mongosh/service-provider-server",
"name": "@mongosh/service-provider-node-driver",
"version": "0.0.0-dev.0",
"description": "MongoDB Shell Server Service Provider Package",
"main": "lib/index.js",
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DevtoolsConnectOptions } from '../cli-service-provider';
import CliServiceProvider from '../cli-service-provider';
import type { DevtoolsConnectOptions } from '../node-driver-service-provider';
import { NodeDriverServiceProvider } from '../node-driver-service-provider';
import type { MongoClient } from 'mongodb';
import type { ReplPlatform } from '@mongosh/service-provider-core';
import type ConnectionString from 'mongodb-connection-string-url';
@@ -8,7 +8,7 @@ import type { EventEmitter } from 'events';
/**
* A service provider that is meant to be used in compass.
*/
class CompassServiceProvider extends CliServiceProvider {
export class CompassServiceProvider extends NodeDriverServiceProvider {
public readonly platform: ReplPlatform;
/**
* Instantiate a new CompassServiceProvider with the data-service's connected
@@ -28,5 +28,3 @@ class CompassServiceProvider extends CliServiceProvider {
this.platform = 'Compass';
}
}

export default CompassServiceProvider;
4 changes: 4 additions & 0 deletions packages/service-provider-node-driver/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { NodeDriverServiceProvider } from './node-driver-service-provider';
import { CompassServiceProvider } from './compass/compass-service-provider';
export type { DevtoolsConnectOptions } from '@mongodb-js/devtools-connect';
export { NodeDriverServiceProvider, CompassServiceProvider };
Loading

0 comments on commit c18016a

Please sign in to comment.