OqronKitOqronKit

Adapters

Storage, Broker, and Lock adapter architecture — built-in and custom

Adapters

OqronKit's adapter system provides swappable persistence backends. The same job definitions work identically across in-memory, Redis, and PostgreSQL — zero code changes required. Need to use a different data store? Implement the interface, plug it in.

Backend Architecture

Every OqronKit deployment runs on a Backend, which exposes a unified set of robust capabilities:

CapabilityInterfaceResponsibility
Key-ValuekvCore storage for job records, schedule definitions, history, buffers, and metadata
BrokerqueueJob signaling, priority queues, push/claim semantics, and inter-process messaging
LockslockDistributed mutual exclusion, leader election, and crash-safety heartbeats
PubSubpubsubEvent distribution for live UI updates across the cluster
AtomicatomicHigh-speed, atomic transactional scripts for Rate Limiters and Cache stampede protection

Storage Modes

OqronKit discards complex manual adapter wiring in favor of three simple, compile-time checked modes defined in your configuration:

ModeDurable Store (Runs, Crons, Schedules)Hot Store (Broker queues, Locks, Cache, Rate Limits)Required Config Options
'memory'MemoryMemoryNone
'redis'RedisRedisredis
'redis-postgres'PostgreSQLRedisredis AND postgres

1. In-Memory Mode (memory)

Zero-dependency. ships built-in. Perfect for local development, rapid prototyping, and unit testing.

import { Oqron } from "oqronkit";

const oqron = new Oqron({
  mode: "memory",
});
await oqron.start();

2. Redis Mode (redis)

High-throughput deployment where all data (operational queues, locks, job history, and schedules) lives in Redis.

import { Oqron } from "oqronkit";

const oqron = new Oqron({
  mode: "redis",
  redis: "redis://localhost:6379", // Or RedisConfig object
});
await oqron.start();

3. Hybrid Mode (redis-postgres)

The recommended pattern for production workloads. PostgreSQL acts as the durable source of truth for job records, runs history, scheduler definitions, and the event log. Redis is used for high-velocity operational tasks (brokers, locks, cache, and rate-limiting).

import { Oqron } from "oqronkit";

const oqron = new Oqron({
  mode: "redis-postgres",
  redis: {
    url: "redis://localhost:6379",
    tls: false,
  },
  postgres: {
    connectionString: "postgresql://postgres:postgres@localhost:5432/oqron",
    tablePrefix: "oqron_", // Optional, prefix for created tables
    poolSize: 10, // Optional pool size
  },
});
await oqron.start();

Connection Configuration Schemas

Redis Connection Config

The redis property accepts either a connection string redis://... or a configuration object:

interface RedisConfig {
  url: string;
  tls?: boolean;
  password?: string;
}

PostgreSQL Connection Config

The postgres property accepts either a connection string postgresql://... or a configuration object:

interface PostgresConfig {
  connectionString: string;
  tablePrefix?: string;
  poolSize?: number;
}

Environment Isolation

All data namespaces are automatically partitioned by the project and environment configuration values to prevent data cross-contamination:

oqron:{project}:{environment}:{namespace}:{id}

This ensures that:

  • A "production" worker process cannot accidentally fetch and process "development" jobs.
  • Multiple separate projects sharing the same database/Redis instance are completely isolated from each other.
  • No prefix boilerplate is needed in your definition names.
index.ts
import { Oqron } from "oqronkit";

// Project A, production
const billingOqron = new Oqron({
  mode: "redis",
  redis: "redis://shared-redis:6379",
  project: "billing",
  environment: "production",
});

// Project B, staging — isolated on the same Redis instance
const notificationOqron = new Oqron({
  mode: "redis",
  redis: "redis://shared-redis:6379",
  project: "notifications",
  environment: "staging",
});

On this page