Skip to content

@nhtio/kyoo ​

A unified SDK for interacting with multiple types of queue brokers

Classes ​

ClassDescription
AMQPErrorAn error, can be both AMQP level errors or socket errors
KyooAMQPChannelErrorReserved; not currently thrown by the library. It represents an AMQP channel error.
KyooBullMQNativeWorkerRanErrorReserved; not currently thrown by the library. It indicates that BullMQ's native processor ran a job instead of Kyoo's processor.
KyooCleanupFailedErrorEmitted as a process warning when connection cleanup leaves registered connections.
KyooConnectionThe main class for interacting with a Queue Broker.
KyooInvalidBrokerPayloadErrorThe error thrown when broker data cannot be coerced into an EnqueueableKyooJob.
KyooInvalidConfigurationErrorThe error thrown when the Kyoo connection configuration passed is not valid
KyooInvalidFetchCountErrorThe error thrown when "count" argument for the KyooQueue.jobs.fetch method is invalid
KyooNoackErrorThe error thrown when Kyoo fails to automatically disposition a job as acknowledged
KyooNotConnectedErrorRepresents an error thrown when a broker operation requires a connection that is not established.
KyooNothingToEnqueueErrorRepresents an error which is thrown when attempting to call the enqueue method without a job
KyooQueueProvides queue operations and worker creation through a configured broker adapter.
KyooSQLAdapterCannotAccessKnexInteralsToReconnectErrorThe error thrown when the SQL adapter cannot access Knex internals to reconnect.
KyooSQLAdapterLockAcquisitionErrorThe error thrown when the SQL adapter cannot acquire a lock in order to perform an operation on a specific queue
KyooSQLAdapterNeedsMigrationErrorThrown by the SQL adapter when the database schema needs to be migrated
KyooTerminatedWorkerErrorThe error thrown when an operation is attempted on a terminated worker.
KyooUnacceptableWorkerOptionsErrorRepresents an error which is thrown when attempting to create a worker with invalid options.
KyooUnenqueueableErrorThe error thrown when attempting to add a job with an invalid configuration
KyooWorkerThe class responsible for receiving and processing jobs from a queue. A worker can be created by using KyooQueue.worker.
SQLAdapterLockManagerManages Verrou-backed distributed locks for queue rows and queue lifecycle operations.
SQLAdapterMigratorA class that wraps Knex's migration API for use with Kyoo's SQL adapter, providing a consistent interface for running and managing migrations.

Interfaces ​

InterfaceDescription
AMQPAdapterConfigurationDescribes the shape of the object used to configure the AMQP adapter.
AMQPClientOptionsObjectDescribes the shape of an object used for connecting to an AMQP server.
BullMQAdapterConfigurationDescribes the overall shape of the configuration which should be passed to the BullMQ adapter.
BullMQRedisConnectionExtraOptionsDescribes additional options which are used to configure the BullMQ adapter.
KyooConfigurationKyooConfiguration is a generic type that represents the configuration for a specific queue adapter. It includes the adapter type and its corresponding configuration, as well as Kyoo-specific options.
KyooConfigurationOptionsOptions for Kyoo behavior which is not related to an adapter.
KyooConnectionEventsDescribes the events and their callbacks for a KyooConnection instance
KyooJobA job is a unit of work that can be processed by a worker. It contains a payload and optional metadata.
KyooJobAckShape of the job acknowledgment function.
KyooJobMessageDescribes the shape of the object that is passed to the job processor function.
KyooJobNackShape of the job negative acknowledgment function.
KyooJobProcessorDescribes the shape of a function which is used in the KyooWorker class to process jobs.
KyooJobToEnqueueDescribes the shape of a job which should be enqueued.
KyooQueueWorkerOptionsRepresents the options for the creation of a queue worker
KyooWorkableA workable job is a job that can be processed by a worker. It contains the job and methods for acknowledging or rejecting the job.
KyooWorkerControlsAn object containing the controls for the worker.
KyooWorkerDispositionersAn object containing the dispositioners for the job.
KyooWorkerEventsDescribes the events and their callbacks for a KyooWorker instance
PGBossAdapterConfigurationConfiguration for the PGBoss adapter.
PoolConfigDefines the settings for the database connection pool, controlling how many connections can be opened, reused, and managed concurrently. This type is a subset of the Knex PoolConfig type, excluding keys that are not relevant for the SQL Adapter.
PostgreSQLConnectionObjectA configuration object for connecting to a PostgreSQL database.
PostgreSQLDatabaseOptions-
PostgreSQLExpirationOptions-
PostgreSQLJobPollingOptions-
PostgreSQLMaintenanceOptions-
PostgreSQLQueueOptions-
PostgreSQLRetentionOptions-
PostgreSQLRetryOptions-
PostgreSQLSchedulingOptions-
SQLAdapterConfigurationConfiguration schema for the SQL Adapter.
SQLAdapterMigatorTypeA type representing the public migration methods available on a Knex Migrator, but with all methods as zero-argument functions returning the same type as the original. This omits the 'make' method, which is internal to Knex.
SQSAdapterConfigurationThe configuration interface of SQSClient class constructor that set the region, credentials and other options.

Type Aliases ​

Type AliasDescription
AMQPUrlA URL using either the "amqp" or "amqps" protocol.
ConnectionStatusA string literal type representing the connection status of the adapter. It can be one of the following values: - "connected": The adapter is connected and ready to use. - "disconnected": The adapter is not connected. - "connecting": The adapter is in the process of connecting.
KnexSQLClientThe KnexSQLClient type represents the Knex Client type, which is used to interact with SQL databases in a type-safe manner.
KyooClientKyooClient is a union type representing the supported queue adapters in the Kyoo library. The possible choices are amqp, bullmq, sqs, pgboss and sql.
KyooJobPriorityDefines the possible job priority values. The priority is a number between 1 and 255. The higher the number, the higher the priority.
KyooPrimitiveDefines the union of all serializable primitive types.
KyooSerializableDefines all the types which can be be serialized
KyooTypedArrayDefines a union for all the serializable typed arrays.
SQLClientThe SQL Adapter is a Kyoo adapter that uses SQL databases to store and manage jobs. See KnexSQLClient for more details on the shape of an SQL client class provided in the runtime.

Variables ​

VariableDescription
canSerializeChecks if a value is serializable
versionThe current version of the Kyoo library.

Functions ​

FunctionDescription
compressPayloadGzip a buffer and prepend the "gz:" prefix. Passthrough if disabled.
compressPayloadSyncCompresses bytes synchronously and prepends the gz: marker unless disabled.
decompressPayloadStrip "gz:" prefix and gunzip if present. Always auto-detects regardless of options.
decompressPayloadSyncDecompresses gzip-prefixed bytes synchronously, preserving plain bytes unchanged.
defineAdapterConfigurationValidates an adapter configuration while preserving its inferred adapter type.
getSqlAdapterLockManagerValidates configuration and returns a configured SQL lock manager.
getSqlAdapterMigratorValidates and constructs a SQLAdapterMigrator instance from a configuration object. Throws a KyooInvalidConfigurationError if the configuration is invalid.
isAKyooWorkerChecks if the given object is an instance of KyooWorker
isKyooQueueChecks if the given object is an instance of KyooQueue
sanitizeKnexConfigForKyooSanitizes a Knex configuration object for use with Kyoo.