@pikku/queue-bullmq 0.12.4 → 0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,46 @@
1
+ ## 0.12.6
2
+
3
+ ### Patch Changes
4
+
5
+ - 6794681: Publish the ecosystem surface as per-area sub-barrels under `@pikku/core/ecosystem/*`, and point generated code, the CLI, the inspector and the runtime adapters at them.
6
+
7
+ 348 names that only generated code, the toolchain or a runtime adapter ever imports now have a second home on `@pikku/core/ecosystem/<area>` — one sub-barrel per area, matching how core already publishes its entrypoints, so no single barrel grows without bound and a consumer only pulls in the area it uses.
8
+
9
+ This step is additive: every name is still exported from the entrypoint it was published from before, so nothing downstream breaks. Removing them from the app-facing barrels is a later change, and needs a release carrying `./ecosystem/*` first.
10
+
11
+ - Updated dependencies [7406bfe]
12
+ - Updated dependencies [6794681]
13
+ - @pikku/core@0.12.84
14
+
15
+ ## 0.12.5
16
+
17
+ ### Patch Changes
18
+
19
+ - e3d4454: Add job groups, so one shared queue can stay fair without splitting into one
20
+ queue per producer.
21
+
22
+ A job may now carry `group: { id, tier }`, and a worker may cap how many jobs
23
+ of any one group run at once via `groupConcurrency`. On pg-boss this maps to
24
+ `localGroupConcurrency`, which excludes at-capacity groups from the fetch query
25
+ itself, so a capped group costs nothing rather than being fetched and restored.
26
+ BullMQ declares it unsupported (groups are a BullMQ Pro feature) — being
27
+ push-based, it can simply use a queue per group at no polling cost.
28
+
29
+ Workflow services accept a `queueStrategy`. The default `'per-workflow'` is
30
+ unchanged: every workflow gets its own `wf-orchestrator-*` / `wf-step-*` queue,
31
+ which is also what lets serverless providers deploy one unit per workflow. The
32
+ new `'shared-groups'` routes every workflow through the shared
33
+ orchestrator/step-worker queues and isolates them by group instead, so a
34
+ monolith runs one set of pollers rather than one per workflow — on a
35
+ pull-based backend with dozens of workflows that is the difference between
36
+ hundreds of poll loops and twenty. It is for single-process runtimes only; a
37
+ per-unit serverless deploy still needs the per-workflow queues to route to its
38
+ units.
39
+
40
+ - Updated dependencies [24252b8]
41
+ - Updated dependencies [e3d4454]
42
+ - @pikku/core@0.12.69
43
+
1
44
  ## 0.12.4
2
45
 
3
46
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 - present Yasser Fadl and Pikku contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # @pikku/queue-bullmq
2
+
3
+ BullMQ queue, worker and scheduler services for Pikku. Backed by Redis, with
4
+ job results, retries and priorities.
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ npm install @pikku/queue-bullmq
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```typescript
15
+ import { BullQueueService, BullQueueWorkers } from '@pikku/queue-bullmq'
16
+
17
+ const queue = new BullQueueService({ host: 'localhost', port: 6379 })
18
+
19
+ const workers = new BullQueueWorkers({ host: 'localhost', port: 6379 })
20
+
21
+ await workers.registerQueues()
22
+ ```
23
+
24
+ Use `BullSchedulerService` for cron wirings. For a Postgres-backed alternative
25
+ see `@pikku/queue-pg-boss`.
26
+
27
+ ## Docs
28
+
29
+ https://pikku.dev/docs
@@ -1,6 +1,7 @@
1
1
  import type { ConnectionOptions, JobsOptions } from 'bullmq';
2
2
  import type Bull from 'bullmq';
3
- import type { QueueService, QueueJob, JobOptions } from '@pikku/core/queue';
3
+ import type { QueueService, QueueJob } from '@pikku/core/queue';
4
+ import type { JobOptions } from '@pikku/core/ecosystem/queue';
4
5
  export declare const mapPikkuJobToBull: (options?: JobOptions) => JobsOptions;
5
6
  /**
6
7
  * Bull/Redis queue service implementation
@@ -1,5 +1,5 @@
1
1
  import type { ConnectionOptions, WorkerOptions } from 'bullmq';
2
- import type { QueueWorkers, PikkuWorkerConfig, QueueConfigMapping, ConfigValidationResult } from '@pikku/core/queue';
2
+ import type { QueueWorkers, PikkuWorkerConfig, QueueConfigMapping, ConfigValidationResult } from '@pikku/core/ecosystem/queue';
3
3
  export declare const mapPikkuWorkerToBull: (workerConfig?: PikkuWorkerConfig) => Omit<WorkerOptions, "connection">;
4
4
  /**
5
5
  * Bull/Redis queue service implementation
@@ -1,6 +1,7 @@
1
1
  import { Worker } from 'bullmq';
2
- import { registerQueueWorkers, runQueueJob, QueueJobFailedError, QueueJobDiscardedError, } from '@pikku/core/queue';
3
- import { pikkuState } from '@pikku/core/internal';
2
+ import { runQueueJob } from '@pikku/core/queue';
3
+ import { registerQueueWorkers, QueueJobFailedError, QueueJobDiscardedError, } from '@pikku/core/ecosystem/queue';
4
+ import { pikkuState } from '@pikku/core/ecosystem';
4
5
  import { mapBullJobToQueueJob } from './utils.js';
5
6
  export const mapPikkuWorkerToBull = (workerConfig) => {
6
7
  const workerOptions = {};
@@ -82,6 +83,10 @@ export class BullQueueWorkers {
82
83
  },
83
84
  // Configurations that are not supported
84
85
  unsupported: {
86
+ groupConcurrency: {
87
+ reason: 'Job groups are a BullMQ Pro feature, not available in BullMQ',
88
+ explanation: 'Give each group its own queue instead — BullMQ is push-based, so extra queues cost no polling',
89
+ },
85
90
  visibilityTimeout: {
86
91
  reason: 'Bull does not use visibility timeout',
87
92
  explanation: 'BullMQ locks jobs during processing instead of using visibility timeouts',
@@ -1,5 +1,6 @@
1
1
  import type { ConnectionOptions } from 'bullmq';
2
- import type { ScheduledTaskInfo, ScheduledTaskSummary, CoreUserSession } from '@pikku/core';
2
+ import type { CoreUserSession } from '@pikku/core';
3
+ import type { ScheduledTaskInfo, ScheduledTaskSummary } from '@pikku/core/ecosystem/services';
3
4
  import { SchedulerService } from '@pikku/core';
4
5
  export declare class BullSchedulerService extends SchedulerService {
5
6
  private redisConnectionOptions;
@@ -1,7 +1,9 @@
1
1
  import { Queue, Worker } from 'bullmq';
2
- import { SchedulerService, parseDurationString } from '@pikku/core';
3
- import { pikkuState } from '@pikku/core/internal';
4
- import { runScheduledTask, getScheduledTasks } from '@pikku/core/scheduler';
2
+ import { SchedulerService } from '@pikku/core';
3
+ import { parseDurationString } from '@pikku/core/ecosystem/types';
4
+ import { pikkuState } from '@pikku/core/ecosystem';
5
+ import { runScheduledTask } from '@pikku/core/scheduler';
6
+ import { getScheduledTasks } from '@pikku/core/ecosystem/scheduler';
5
7
  const RECURRING_QUEUE_NAME = 'pikku-recurring-scheduled-task';
6
8
  export class BullSchedulerService extends SchedulerService {
7
9
  redisConnectionOptions;
package/dist/index.d.ts CHANGED
@@ -8,4 +8,5 @@ export { BullServiceFactory } from './bull-service-factory.js';
8
8
  export { BullQueueService } from './bull-queue-service.js';
9
9
  export { BullQueueWorkers } from './bull-queue-worker.js';
10
10
  export { BullSchedulerService } from './bull-scheduler-service.js';
11
- export type { QueueService, PikkuWorkerConfig, PikkuJobConfig, QueueJob, JobOptions, } from '@pikku/core/queue';
11
+ export type { QueueService, QueueJob } from '@pikku/core/queue';
12
+ export type { PikkuWorkerConfig, PikkuJobConfig, JobOptions, } from '@pikku/core/ecosystem/queue';
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@pikku/queue-bullmq",
3
- "version": "0.12.4",
3
+ "version": "0.12.6",
4
+ "description": "BullMQ queue, worker and scheduler services for Pikku",
4
5
  "author": "yasser.fadl@gmail.com",
5
6
  "license": "MIT",
6
7
  "module": "dist/index.js",
@@ -15,7 +16,7 @@
15
16
  "prepublishOnly": "yarn build"
16
17
  },
17
18
  "peerDependencies": {
18
- "@pikku/core": "^0.12.44"
19
+ "@pikku/core": "^0.12.84"
19
20
  },
20
21
  "dependencies": {
21
22
  "bullmq": "^5.70.1",
package/run-tests.sh CHANGED
@@ -1,5 +1,56 @@
1
1
  #!/bin/bash
2
- cd "$(dirname "$0")"
2
+
3
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4
+ cd "$script_dir"
5
+
6
+ # Enable nullglob to handle cases where no files match the pattern
7
+ shopt -s nullglob
8
+
9
+ # Initialize variables for options
10
+ watch_mode=false
11
+ coverage_mode=false
12
+
13
+ # Parse command-line options
14
+ while [[ $# -gt 0 ]]; do
15
+ case $1 in
16
+ --watch)
17
+ watch_mode=true
18
+ shift
19
+ ;;
20
+ --coverage)
21
+ coverage_mode=true
22
+ shift
23
+ ;;
24
+ *)
25
+ echo "Unknown option: $1"
26
+ exit 1
27
+ ;;
28
+ esac
29
+ done
30
+
31
+ # Define the pattern to match your test files
32
+ pattern="src/*.test.ts"
33
+
34
+ # Expand the pattern into an array of files
3
35
  files=($(find src -type f -name "*.test.ts"))
4
- if [ ${#files[@]} -eq 0 ]; then echo "No test files found"; exit 0; fi
5
- node --import tsx --test "$@" "${files[@]}"
36
+
37
+ # Check if any files matched the pattern
38
+ if [ ${#files[@]} -eq 0 ]; then
39
+ echo "No test files found matching pattern: $pattern"
40
+ exit 0
41
+ fi
42
+
43
+ # Construct the node command
44
+ node_cmd=(node --import tsx --test)
45
+
46
+ # Append options based on flags
47
+ if [ "$watch_mode" = true ]; then
48
+ node_cmd+=(--watch)
49
+ fi
50
+
51
+ if [ "$coverage_mode" = true ]; then
52
+ node_cmd+=(--test-coverage-include="src/**/*.{ts,js}" --test-coverage-exclude="**/dist/**" --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info)
53
+ fi
54
+
55
+ # Execute the node command with the expanded list of files
56
+ "${node_cmd[@]}" "${files[@]}"
@@ -1,7 +1,8 @@
1
1
  import type { ConnectionOptions, JobsOptions } from 'bullmq'
2
2
  import type Bull from 'bullmq'
3
3
  import { Queue, QueueEvents, RedisConnection } from 'bullmq'
4
- import type { QueueService, QueueJob, JobOptions } from '@pikku/core/queue'
4
+ import type { QueueService, QueueJob } from '@pikku/core/queue'
5
+ import type { JobOptions } from '@pikku/core/ecosystem/queue'
5
6
  import { mapBullJobToQueueJob } from './utils.js'
6
7
 
7
8
  export const mapPikkuJobToBull = (options?: JobOptions): JobsOptions => {
@@ -6,14 +6,14 @@ import type {
6
6
  PikkuWorkerConfig,
7
7
  QueueConfigMapping,
8
8
  ConfigValidationResult,
9
- } from '@pikku/core/queue'
9
+ } from '@pikku/core/ecosystem/queue'
10
+ import { runQueueJob } from '@pikku/core/queue'
10
11
  import {
11
12
  registerQueueWorkers,
12
- runQueueJob,
13
13
  QueueJobFailedError,
14
14
  QueueJobDiscardedError,
15
- } from '@pikku/core/queue'
16
- import { pikkuState } from '@pikku/core/internal'
15
+ } from '@pikku/core/ecosystem/queue'
16
+ import { pikkuState } from '@pikku/core/ecosystem'
17
17
  import { mapBullJobToQueueJob } from './utils.js'
18
18
 
19
19
  export const mapPikkuWorkerToBull = (
@@ -111,6 +111,11 @@ export class BullQueueWorkers implements QueueWorkers {
111
111
 
112
112
  // Configurations that are not supported
113
113
  unsupported: {
114
+ groupConcurrency: {
115
+ reason: 'Job groups are a BullMQ Pro feature, not available in BullMQ',
116
+ explanation:
117
+ 'Give each group its own queue instead — BullMQ is push-based, so extra queues cost no polling',
118
+ },
114
119
  visibilityTimeout: {
115
120
  reason: 'Bull does not use visibility timeout',
116
121
  explanation:
@@ -1,13 +1,15 @@
1
1
  import type { ConnectionOptions } from 'bullmq'
2
2
  import { Queue, Worker } from 'bullmq'
3
+ import type { CoreUserSession } from '@pikku/core'
3
4
  import type {
4
5
  ScheduledTaskInfo,
5
6
  ScheduledTaskSummary,
6
- CoreUserSession,
7
- } from '@pikku/core'
8
- import { SchedulerService, parseDurationString } from '@pikku/core'
9
- import { pikkuState } from '@pikku/core/internal'
10
- import { runScheduledTask, getScheduledTasks } from '@pikku/core/scheduler'
7
+ } from '@pikku/core/ecosystem/services'
8
+ import { SchedulerService } from '@pikku/core'
9
+ import { parseDurationString } from '@pikku/core/ecosystem/types'
10
+ import { pikkuState } from '@pikku/core/ecosystem'
11
+ import { runScheduledTask } from '@pikku/core/scheduler'
12
+ import { getScheduledTasks } from '@pikku/core/ecosystem/scheduler'
11
13
 
12
14
  /**
13
15
  * Data stored in scheduled job
package/src/index.ts CHANGED
@@ -11,10 +11,9 @@ export { BullQueueWorkers } from './bull-queue-worker.js'
11
11
  export { BullSchedulerService } from './bull-scheduler-service.js'
12
12
 
13
13
  // Re-export core queue types for convenience
14
+ export type { QueueService, QueueJob } from '@pikku/core/queue'
14
15
  export type {
15
- QueueService,
16
16
  PikkuWorkerConfig,
17
17
  PikkuJobConfig,
18
- QueueJob,
19
18
  JobOptions,
20
- } from '@pikku/core/queue'
19
+ } from '@pikku/core/ecosystem/queue'