Skip to content

Commit

Permalink
refactor(worker): rename maxConcurrency to maxConcurrent
Browse files Browse the repository at this point in the history
Update Worker configuration parameter name across multiple files to improve naming consistency.
This includes changes in Worker.ts, index.ts, and README.md to reflect the new parameter name.

Fixes naming inconsistency in worker configuration
  • Loading branch information
jumski committed Jan 9, 2025
1 parent 767db00 commit dd71b92
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pkgs/supaworker/src/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface WorkerConfig {
maxPollSeconds?: number;
pollIntervalMs?: number;
maxPgConnections?: number;
maxConcurrency?: number;
maxConcurrent?: number;
}

export class Worker<MessagePayload extends Json> {
Expand All @@ -47,7 +47,7 @@ export class Worker<MessagePayload extends Json> {
maxPollSeconds: config.maxPollSeconds ?? 5,
pollIntervalMs: config.pollIntervalMs ?? 100,
maxPgConnections: config.maxPgConnections ?? 4,
maxConcurrency: config.maxConcurrency ?? 50,
maxConcurrent: config.maxConcurrency ?? 50,
};

this.sql = postgres(this.config.connectionString, {
Expand All @@ -59,7 +59,7 @@ export class Worker<MessagePayload extends Json> {
this.executionController = new ExecutionController(
this.queue,
this.mainController.signal,
this.config.maxConcurrency
this.config.maxConcurrent
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { delay } from 'jsr:@std/async';

const sleep1s = () => delay(1000);

Supaworker.start(sleep1s, { maxConcurrency: 1 });
Supaworker.start(sleep1s, { maxConcurrent: 1 });
6 changes: 3 additions & 3 deletions pkgs/supaworker/tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ functions/
- [x] Worker picks messages from queue
- [ ] Worker calls handler function with each message
- [x] Worker can process big amounts of messages (restarts itself when CPU clock limit hits)
- Different worker functions can pull from different queues
- [ ] Drent worker functions can pull from the same queue
- [ ] Different worker functions can pull from different queues
- [ ] Different worker functions can pull from the same queue

✅ Worker Lifecycle

Expand All @@ -59,4 +59,4 @@ functions/

✅ Concurrency

- [ ] Worker respects maxConcurrency (does not read new messages if there are no empty slots, reads max empty-slots-count of messages)
- [ ] Worker respects maxConcurrent (does not read new messages if there are no empty slots, reads max empty-slots-count of messages)

0 comments on commit dd71b92

Please sign in to comment.