Skip to content

ManagementMonque

Defined in: surface/types.ts:41

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.

optional getProcessingState?: (name?) => ProcessingState;

Defined in: surface/types.ts:42

Identify the local scheduler and inspect global or named-worker processing state.

ParameterType
name?string

ProcessingState


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

Defined in: surface/types.ts:46

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. An optional name filter limits aggregation to that Job Name.

ParameterTypeDescription
filter?Pick<JobSelector, "name">Optional exact Job Name filter

Promise<readonly QueueViewSummary[]>

Promise resolving to immutable Queue View summaries

Inspect Queue Views

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:45

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

Express health check endpoint

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()
  });
});

Kubernetes readiness probe

app.get('/readyz', (req, res) => {
  if (monque.isHealthy() && dbConnected) {
    res.status(200).send('ready');
  } else {
    res.status(503).send('not ready');
  }
});

Periodic health monitoring

setInterval(() => {
  if (!monque.isHealthy()) {
    logger.error('Scheduler unhealthy');
    metrics.increment('scheduler.unhealthy');
  }
}, 60000); // Check every minute

optional pause?: (name?) => void;

Defined in: surface/types.ts:43

Pause new executions locally, optionally for one job name. Running jobs continue.

ParameterType
name?string

void


optional resume?: (name?) => void;

Defined in: surface/types.ts:44

Resume local executions. Resuming the instance preserves individually paused workers.

ParameterType
name?string

void

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

Defined in: surface/types.ts:53

ParameterType
idstring

Promise<PersistedJob | null>


optional cancelJobs(selector): Promise<BulkOperationResult>;

Defined in: surface/types.ts:58

ParameterType
selectorJobSelector

Promise<BulkOperationResult>


optional deleteJob(id): Promise<boolean>;

Defined in: surface/types.ts:57

ParameterType
idstring

Promise<boolean>


optional deleteJobs(selector): Promise<BulkOperationResult>;

Defined in: surface/types.ts:60

ParameterType
selectorJobSelector

Promise<BulkOperationResult>


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

Defined in: surface/types.ts:51

ParameterType
idstring

Promise<PersistedJob | null>


optional getJobSummariesWithCursor(options?): Promise<Omit<CursorPage<unknown>, "jobs"> & object>;

Defined in: surface/types.ts:48

ParameterType
options?CursorOptions

Promise<Omit<CursorPage<unknown>, "jobs"> & object>


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

Defined in: surface/types.ts:47

ParameterType
options?CursorOptions

Promise<CursorPage<unknown>>


getQueueStats(filter?): Promise<QueueStats>;

Defined in: surface/types.ts:52

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

Promise<QueueStats>


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

Defined in: surface/types.ts:55

ParameterType
idstring
runAtDate

Promise<PersistedJob | null>


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

Defined in: surface/types.ts:54

ParameterType
idstring

Promise<PersistedJob | null>


optional retryJobs(selector): Promise<BulkOperationResult>;

Defined in: surface/types.ts:59

ParameterType
selectorJobSelector

Promise<BulkOperationResult>


optional setJobPriority(id, priority): Promise<PersistedJob | null>;

Defined in: surface/types.ts:56

ParameterType
idstring
prioritynumber

Promise<PersistedJob | null>