Browse Source

refactor: Rename pub-sub-plugin to job-queue-plugin

Michael Bromley 4 years ago
parent
commit
d90cb9f59b

+ 0 - 0
packages/pub-sub-plugin/.gitignore → packages/job-queue-plugin/.gitignore


+ 12 - 0
packages/job-queue-plugin/README.md

@@ -0,0 +1,12 @@
+# Vendure Job Queue Plugin
+
+This plugin is under development. It will house plugins that implement alternate JobQueueStrategies aimed at handling more demanding production loads than can be comfortably handled by the database-powered DefaultJobQueuePlugin which ships with Vendure core.
+
+Implemented: 
+
+* The `PubSubPlugin` uses Google Cloud Pub/Sub to power the Vendure job queue. 
+
+Planned:
+
+* Redis
+* RabbitMQ

+ 8 - 0
packages/job-queue-plugin/build.ts

@@ -0,0 +1,8 @@
+/* tslint:disable:no-console */
+import fs from 'fs-extra';
+import path from 'path';
+
+fs.copyFileSync(
+    path.join(__dirname, './src/pub-sub/package.json'),
+    path.join(__dirname, './lib/pub-sub/package.json'),
+);

+ 0 - 0
packages/pub-sub-plugin/jest.config.js → packages/job-queue-plugin/jest.config.js


+ 4 - 4
packages/pub-sub-plugin/package.json → packages/job-queue-plugin/package.json

@@ -9,7 +9,7 @@
   ],
   "scripts": {
     "watch": "tsc -p ./tsconfig.build.json --watch",
-    "build": "rimraf lib && tsc -p ./tsconfig.build.json",
+    "build": "rimraf lib && tsc -p ./tsconfig.build.json && yarn ts-node build.ts",
     "lint": "tslint --fix --project ./",
     "test": "jest --config ./jest.config.js",
     "ci": "yarn build"
@@ -17,12 +17,12 @@
   "publishConfig": {
     "access": "public"
   },
-  "dependencies": {
-    "@google-cloud/pubsub": "^2.8.0"
-  },
   "devDependencies": {
+    "@google-cloud/pubsub": "^2.8.0",
+    "@types/redis": "^2.8.28",
     "@vendure/common": "^0.18.1",
     "@vendure/core": "^0.18.2",
+    "redis": "^3.0.2",
     "rimraf": "^3.0.2",
     "typescript": "4.0.3"
   }

+ 4 - 0
packages/job-queue-plugin/src/index.ts

@@ -0,0 +1,4 @@
+/**
+ * This is a placeholder. Please import from one of the sub-packages, e.g `@vendure/job-queue-plugin/pub-sub`
+ */
+export const placeholder = 'Vendure Job Queue Plugin';

+ 0 - 0
packages/pub-sub-plugin/src/constants.ts → packages/job-queue-plugin/src/pub-sub/constants.ts


+ 2 - 0
packages/job-queue-plugin/src/pub-sub/index.ts

@@ -0,0 +1,2 @@
+export * from './plugin';
+export * from './options';

+ 0 - 0
packages/pub-sub-plugin/src/options.ts → packages/job-queue-plugin/src/pub-sub/options.ts


+ 5 - 0
packages/job-queue-plugin/src/pub-sub/package.json

@@ -0,0 +1,5 @@
+{
+  "main": "index.js",
+  "typings": "index.d.ts",
+  "name": "@vendure/job-queue-plugin/pub-sub"
+}

+ 2 - 2
packages/pub-sub-plugin/src/plugin.ts → packages/job-queue-plugin/src/pub-sub/plugin.ts

@@ -1,9 +1,9 @@
+import { PubSub } from '@google-cloud/pubsub';
 import { PluginCommonModule, Type, VendurePlugin } from '@vendure/core';
 
-import { PubSubOptions } from './options';
 import { PUB_SUB_OPTIONS } from './constants';
+import { PubSubOptions } from './options';
 import { PubSubJobQueueStrategy } from './pub-sub-job-queue-strategy';
-import { PubSub } from '@google-cloud/pubsub';
 
 @VendurePlugin({
     imports: [PluginCommonModule],

+ 1 - 2
packages/pub-sub-plugin/src/pub-sub-job-queue-strategy.spec.ts → packages/job-queue-plugin/src/pub-sub/pub-sub-job-queue-strategy.spec.ts

@@ -3,9 +3,8 @@ import { ModuleRef } from '@nestjs/core';
 import { Test } from '@nestjs/testing';
 import { Injector, Job } from '@vendure/core';
 
-import { PubSubOptions } from '../lib';
-
 import { PUB_SUB_OPTIONS } from './constants';
+import { PubSubOptions } from './options';
 import { PubSubJobQueueStrategy } from './pub-sub-job-queue-strategy';
 
 describe('PubSubJobQueueStrategy', () => {

+ 0 - 0
packages/pub-sub-plugin/src/pub-sub-job-queue-strategy.ts → packages/job-queue-plugin/src/pub-sub/pub-sub-job-queue-strategy.ts


+ 2 - 2
packages/pub-sub-plugin/tsconfig.build.json → packages/job-queue-plugin/tsconfig.build.json

@@ -3,7 +3,7 @@
   "compilerOptions": {
     "outDir": "./lib"
   },
-  "files": [
-    "./index.ts"
+  "include": [
+    "./src/**/index.ts"
   ]
 }

+ 0 - 0
packages/pub-sub-plugin/tsconfig.json → packages/job-queue-plugin/tsconfig.json


+ 0 - 7
packages/pub-sub-plugin/README.md

@@ -1,7 +0,0 @@
-# Vendure Pub/Sub Plugin
-
-The `PubSubPlugin` uses Google Cloud Pub/Sub to power the Vendure job queue. 
-
-`npm install @vendure/pub-sub-plugin`
-
-For documentation, see [www.vendure.io/docs/typescript-api/pub-sub-plugin/](https://www.vendure.io/docs/typescript-api/pub-sub-plugin/)

+ 0 - 2
packages/pub-sub-plugin/index.ts

@@ -1,2 +0,0 @@
-export * from './src/plugin';
-export * from './src/options';