Skip to content

Commit

Permalink
feature: allow schema name to be configured (#1290)
Browse files Browse the repository at this point in the history
* add schema name config

* add docs
  • Loading branch information
jenbutongit authored Sep 18, 2024
1 parent 95b1d6d commit 54496fc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
21 changes: 11 additions & 10 deletions docs/runner/submission-queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ support that is required.

#### PGBOSS Prerequisites

- PostgreSQL database >=v11
- PostgreSQL database >=v13
- A worker process which can connect to the PostgreSQL database, via PgBoss. Your implementation should look something like this

```ts
Expand Down Expand Up @@ -80,15 +80,16 @@ When using pgboss, it is important that successful work returns `{ reference }`

### Environment variables

| Variable name | Definition | Default | Example |
| ------------------------------ | ---------------------------------------------------------------------------------------- | ------- | ------------------------------------------- |
| ENABLE_QUEUE_SERVICE | Whether the queue service is enabled or not | `false` | |
| QUEUE_DATABASE_TYPE | PGBOSS or MYSQL | | |
| QUEUE_DATABASE_URL | Used for configuring the endpoint of the database instance | | mysql://username:password@endpoint/database |
| QUEUE_DATABASE_USERNAME | Used for configuring the user being used to access the database | | root |
| QUEUE_DATABASE_PASSWORD | Used for configuring the password used for accessing the database | | password |
| QUEUE_SERVICE_POLLING_INTERVAL | The amount of time, in milliseconds, between poll requests for updates from the database | 500 | |
| QUEUE_SERVICE_POLLING_TIMEOUT | The total amount of time, in milliseconds, to poll requests for from the database | 2000 | |
| Variable name | Definition | Default | Example |
| ------------------------------ | ---------------------------------------------------------------------------------------- | -------- | ------------------------------------------- |
| ENABLE_QUEUE_SERVICE | Whether the queue service is enabled or not | `false` | |
| QUEUE_DATABASE_TYPE | PGBOSS or MYSQL | | |
| QUEUE_DATABASE_URL | Used for configuring the endpoint of the database instance | | mysql://username:password@endpoint/database |
| QUEUE_DATABASE_USERNAME | Used for configuring the user being used to access the database | | root |
| QUEUE_DATABASE_PASSWORD | Used for configuring the password used for accessing the database | | password |
| QUEUE_DATABASE_SCHEMA_NAME | Used for configuring the schema name that pgboss should use | `pgboss` | |
| QUEUE_SERVICE_POLLING_INTERVAL | The amount of time, in milliseconds, between poll requests for updates from the database | 500 | |
| QUEUE_SERVICE_POLLING_TIMEOUT | The total amount of time, in milliseconds, to poll requests for from the database | 2000 | |

Webhooks can be configured so that the submitter only attempts to post to the webhook URL once.

Expand Down
1 change: 1 addition & 0 deletions runner/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"queueDatabaseUrl": "QUEUE_DATABASE_URL",
"queueDatabaseUsername": "QUEUE_DATABASE_USERNAME",
"queueDatabasePassword": "QUEUE_DATABASE_PASSWORD",
"queueDatabaseSchemaName": "QUEUE_DATABASE_SCHEMA_NAME",
"queueServicePollingInterval": "QUEUE_SERVICE_POLLING_INTERVAL",
"queueServicePollingTimeout": "QUEUE_SERVICE_POLLING_TIMEOUT",
"allowUserTemplates": "ALLOW_USER_TEMPLATES",
Expand Down
10 changes: 6 additions & 4 deletions runner/src/server/services/pgBossQueueService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export class PgBossQueueService extends QueueService {
this.pollingInterval = parseInt(config.queueServicePollingInterval);
this.pollingTimeout = parseInt(config.queueServicePollingTimeout);

const boss = new PgBoss(config.queueDatabaseUrl);
const schema = config.queueDatabaseSchemaName;
const boss = new PgBoss({
connectionString: config.queueDatabaseUrl,
schema,
});
this.queue = boss;
boss.on("error", this.logger.error);
boss.start().catch((e) => {
Expand All @@ -37,9 +41,7 @@ export class PgBossQueueService extends QueueService {
}

/**
* Fetches a reference number from `this.queueReferenceApiUrl/{jobId}`.
* If a reference number for `jobId` exists, the response body must be {@link QueueReferenceApiResponse}.
* This request will happen once, and timeout in 2s.
* Fetches a reference number from the database.
*/
async getReturnRef(
jobId: string
Expand Down
1 change: 1 addition & 0 deletions runner/src/server/utils/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export const configSchema = Joi.object({
then: Joi.number().required(),
otherwise: Joi.optional(),
}),
queueDatabaseSchemaName: Joi.string().optional(),
allowUserTemplates: Joi.boolean().optional(),
maxClientFileSize: Joi.number().default("5242880"), // 5MB
maxFileSizeStringInMb: Joi.string().default("5"),
Expand Down

0 comments on commit 54496fc

Please sign in to comment.