Skip to content

Service Options

The createService / Service constructor accepts either a version string or an options object as the first argument:

import { createService } from '@requence/service'
createService(
{
version: '1.0.0',
prefetch: 10,
connectionTimeout: 30000,
silent: false,
},
async (ctx) => {
return 'processed'
},
)

Controls how many messages the service processes concurrently. Defaults to 1.

Set this higher if your service can safely handle parallel work (e.g., stateless HTTP calls or CPU-bound transformations with available cores).

createService(
{ version: '1.0.0', prefetch: 5 },
async (ctx) => {
// Up to 5 messages processed in parallel
},
)

Time in milliseconds to wait for the connection before throwing. Useful in environments where the message broker takes time to become available.

When true, suppresses connection and lifecycle logs.

For amqps:// connections, TLS settings can be overridden with environment variables. This is useful for supplying a private CA or relaxing verification in a specific deployment without changing code.

Variable Effect
CA Inline PEM certificate(s) to trust as the CA.
CA_FILE Path to a PEM file to trust as the CA (CA wins when both are set).
REJECT_UNAUTHORIZED Set to false/0/no to disable certificate verification.

These variables are a fallback: a matching value supplied in code always takes precedence — connectionOptions (ca, rejectUnauthorized) in TypeScript, or ssl_context in Python.

Terminal window
CA_FILE=/etc/ssl/my-ca.pem REJECT_UNAUTHORIZED=false bun run index.ts