arvo-event-handler
Version:
Type-safe event handler system with versioning, telemetry, and contract validation for distributed Arvo event-driven architectures, featuring routing and multi-handler support.
85 lines (84 loc) • 3.72 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExecutionViolation = exports.ConfigViolation = exports.ContractViolation = void 0;
var arvo_core_1 = require("arvo-core");
/**
* ContractViolation indicates a critical mismatch between services where event data
* violates the receiving handler's contract. This represents a serious system issue
* where services are out of sync with their contracts. Common causes include:
* - Upstream services sending malformed data
* - Breaking changes in contracts without proper version management
* - Implicit assumptions in handlers not covered by contracts
*
* Requires explicit handling as it signals potential system-wide contract violations.
*/
var ContractViolation = /** @class */ (function (_super) {
__extends(ContractViolation, _super);
function ContractViolation(message, metadata) {
return _super.call(this, {
type: 'Contract',
message: message,
metadata: metadata,
}) || this;
}
return ContractViolation;
}(arvo_core_1.ViolationError));
exports.ContractViolation = ContractViolation;
/**
* ConfigViolation indicates system configuration or routing issues where events
* are mismatched with their handlers. This occurs separately from contract
* violations and represents problems with the system topology itself, such as:
* - Events sent to handlers not configured to process them
* - Mismatched event types not covered by handler contracts
* - Configuration conflicts between services
*
* Requires explicit resolution as it indicates fundamental routing or setup issues.
*/
var ConfigViolation = /** @class */ (function (_super) {
__extends(ConfigViolation, _super);
function ConfigViolation(message, metadata) {
return _super.call(this, {
type: 'Config',
message: message,
metadata: metadata,
}) || this;
}
return ConfigViolation;
}(arvo_core_1.ViolationError));
exports.ConfigViolation = ConfigViolation;
/**
* ExecutionViolation represents runtime failures requiring explicit intervention
* outside normal error flow. Unlike regular errors that convert to system error
* events, these violations demand special handling at the handler's .execute level.
*
* Use sparingly - most runtime errors should flow through standard system error
* events. Reserve ExecutionViolation for cases requiring custom error handling
* logic that can't be managed through normal event patterns.
*/
var ExecutionViolation = /** @class */ (function (_super) {
__extends(ExecutionViolation, _super);
function ExecutionViolation(message, metadata) {
return _super.call(this, {
type: 'Execution',
message: message,
metadata: metadata,
}) || this;
}
return ExecutionViolation;
}(arvo_core_1.ViolationError));
exports.ExecutionViolation = ExecutionViolation;