Improvements#69
Open
llambeau wants to merge 9 commits into
Open
Conversation
Fix a bug in JobRunner where RAW mode crashed because updateMetrics() was called without null checks in the promise resolution/rejection handlers of #doRun. Replace broken proxyquire usage in consumer, server, and REST API tests with direct imports and sinon stubs. Add tests for: runner RAW mode (7 tests), NodeJSRunner RAW mode (unskip), dispatcher invalidJobExchange path, dispatcher queue push failures, consumer stop() and multi-config, and server stop(). Test count goes from 219 passing + 1 failing to 251 passing + 0 failing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Round 2: AmqpQueue operations tested with mocked amqplib and fetch stubs using sinon sandboxes. Covers _connect (retry logic, event propagation), _push (serialization, exchanges, headers), _consume (ACK/NACK, invalid JSON, null messages), _disconnect, _requeue (shovel creation, errors), _getQueuesInfo (management API, error handling), and deriveManagementUrl. Round 3: New test files for ConsumerConfig and JobResult. Config edge cases (malformed YAML, config without schema files). Richer validator tests (optional fields, nested objects, type coercion). Binary runner stderr tests changed from skip to pending. Test count: 309 passing, 0 failing (up from 251). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All core components now accept explicit dependencies instead of reaching into the Arnavon singleton: - JobDispatcher: accepts optional registry and queue params - JobRunner/ensureMetrics: accepts optional registry param - createApi: accepts optional registry in options - Server: accepts optional registry and queue, passes to dispatcher/API - Consumer: accepts optional registry and queue, stores and uses them - REST API: accepts queue and config through options - NodeJSRunner: accepts cwd in config instead of using Arnavon.require() Every parameter defaults to Arnavon.* when not provided, so the CLI path and all existing tests work unchanged (309 passing, 0 test changes). Arnavon.cwd() and Arnavon.require() are marked @deprecated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Phase 2) ArnavonConfig.from(options) allows building config from plain TypeScript objects without YAML or Finitio. Defines TypeScript interfaces for JobDefinition, ConsumerDefinition, QueueDefinition, and ArnavonOptions. JobValidator now accepts either a Finitio.System or a plain validator function (data) => data, enabling Zod/Joi/custom validation. ConsumerConfig accepts a handler function as alternative to runner config. FunctionRunner wraps the handler with the same metrics/lifecycle as other runners. New exports: ValidatorFn, HandlerFn, ArnavonOptions, JobDefinition, ConsumerDefinition, QueueDefinition, RunnerDefinition. 321 passing tests (12 new), 0 failing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New ArnavonApp class provides an instance-based API for using Arnavon
as a library:
const app = new ArnavonApp({ queue: { driver: 'amqp', config: {...} } })
app.job('send-email', { validate: (d) => schema.parse(d) })
app.consumer('mailer', { queue: 'emails', handler: async (job) => {...} })
await app.startApi({ port: 3000 })
Features:
- Fluent API with .job() and .consumer() chaining
- .startApi(), .startConsumer(name), .startAllConsumers()
- .fromYaml(path) convenience for YAML-based config
- Own prometheus registry per instance (no singleton dependency)
- Exported as named export: import { ArnavonApp } from '@quadrabee/arnavon'
CLI commands rewritten to use ArnavonApp.fromYaml() internally, removing
all direct references to the Arnavon singleton from CLI code.
335 passing tests (14 new), 0 failing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…gistry When using ArnavonApp (which has its own registry and doesn't set the Arnavon singleton), Consumer._startConsuming() created runners via JobRunner.factor() without passing a registry. The runner constructor fell back to Arnavon.registry which was undefined, causing a crash. Now Consumer passes its registry through factor() → RunnersFactory → runner constructor. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
NodeJSRunner, BinaryRunner, and FunctionRunner constructors were not accepting or forwarding the registry parameter to the JobRunner base class. The factory passed (config, registry) but subclass constructors only accepted (config), so the registry was silently dropped. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ArnavonApp doesn't set Arnavon.config, so NodeJSRunner's fallback to Arnavon.cwd() crashed with 'Cannot read properties of undefined'. Consumer now accepts a cwd parameter and injects it into the runner config when factoring runners. ArnavonApp passes its cwd through. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fb1e75d to
e42330b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.