Skip to content

ManagementMonque

Defined in: surface/types.ts:58

Scheduler API required by @monque/management.

Pass a Monque instance directly for full support, or provide a facade that implements only the methods you want exposed. Missing mutation methods make the matching endpoints return 403 Unsupported action.

getQueueViewSummaries: () => Promise<readonly QueueViewSummary[]>;

Defined in: surface/types.ts:60

Get operator-facing Queue View summaries grouped by Job Name.

Includes every Job Name with persisted Jobs, every locally registered Worker, per-name Job statistics, and local Worker capacity snapshots. Results are sorted by Job Name.

Promise<readonly QueueViewSummary[]>

Promise resolving to immutable Queue View summaries

const summaries = await monque.getQueueViewSummaries();

for (const summary of summaries) {
  console.log(summary.name, summary.stats.total, summary.worker?.activeCount ?? 0);
}

JobQueryService.getQueueViewSummaries


isHealthy: () => boolean;

Defined in: surface/types.ts:59

Check if the scheduler is healthy (running and connected).

Returns true when the scheduler is started, initialized, and has an active MongoDB collection reference. Useful for health check endpoints and monitoring.

A healthy scheduler:

  • Has called initialize() successfully
  • Has called start() and is actively polling
  • Has a valid MongoDB collection reference

boolean

true if scheduler is running and connected, false otherwise

app.get('/health', (req, res) => {
  const healthy = monque.isHealthy();
  res.status(healthy ? 200 : 503).json({
    status: healthy ? 'ok' : 'unavailable',
    scheduler: healthy,
    timestamp: new Date().toISOString()
  });
});
app.get('/readyz', (req, res) => {
  if (monque.isHealthy() && dbConnected) {
    res.status(200).send('ready');
  } else {
    res.status(503).send('not ready');
  }
});
setInterval(() => {
  if (!monque.isHealthy()) {
    logger.error('Scheduler unhealthy');
    metrics.increment('scheduler.unhealthy');
  }
}, 60000); // Check every minute
optional cancelJob(id): Promise<PersistedJob | null>;

Defined in: surface/types.ts:64

ParameterType
idstring

Promise<PersistedJob | null>


optional cancelJobs(selector): Promise<BulkOperationResult>;

Defined in: surface/types.ts:68

ParameterType
selectorJobSelector

Promise<BulkOperationResult>


optional deleteJob(id): Promise<boolean>;

Defined in: surface/types.ts:67

ParameterType
idstring

Promise<boolean>


optional deleteJobs(selector): Promise<BulkOperationResult>;

Defined in: surface/types.ts:70

ParameterType
selectorJobSelector

Promise<BulkOperationResult>


getJob(id): Promise<PersistedJob | null>;

Defined in: surface/types.ts:62

ParameterType
idstring

Promise<PersistedJob | null>


getJobsWithCursor(options?): Promise<CursorPage<unknown>>;

Defined in: surface/types.ts:61

ParameterType
options?CursorOptions

Promise<CursorPage<unknown>>


getQueueStats(filter?): Promise<QueueStats>;

Defined in: surface/types.ts:63

ParameterType
filter?{ name?: string; }
filter.name?string

Promise<QueueStats>


optional rescheduleJob(id, runAt): Promise<PersistedJob | null>;

Defined in: surface/types.ts:66

ParameterType
idstring
runAtDate

Promise<PersistedJob | null>


optional retryJob(id): Promise<PersistedJob | null>;

Defined in: surface/types.ts:65

ParameterType
idstring

Promise<PersistedJob | null>


optional retryJobs(selector): Promise<BulkOperationResult>;

Defined in: surface/types.ts:69

ParameterType
selectorJobSelector

Promise<BulkOperationResult>