Skip to main content

Flow Control

Control how many notifications can be pending at once:
const connection = await Threadify.connect('your-api-key', 'my-service', {
  maxInFlight: 50  // Default: 10, Max: 100
});
Notifications are HPA-safe - each delivered to exactly one pod in your cluster.

Event Patterns

PatternTriggers On
thread.cancelledThread cancelled
thread.completedThread completed
step.successStep succeeded
step.failedStep failed
rule.violatedContract violation
rule.passedContract validation passed
step.*Any step event (wildcard)
rule.*Any validation (wildcard)

Subscribing

// Thread events (2 parameters)
connection.on('thread.completed', (notification) => {
  console.log('Thread completed');
  notification.ack();
});

// Step events (3 parameters: event, stepName, handler)
connection.on('step.failed', 'payment_processed', (notification) => {
  console.error('Payment failed:', notification.message);
  notification.ack();
});

// Contract-specific (use @ syntax)
connection.on('rule.violated', 'product_delivery@order_placed', (notification) => {
  console.error('Contract violation:', notification.message);
  notification.ack();
});

Notification Properties

PropertyTypeDescription
notificationIdstringUnique notification ID
threadIdstringThread ID
stepNamestringStep name
stepStatusstringsuccess or failed
statusstringpassed or violated
severitystringinfo, warning, critical
messagestringHuman-readable message
timestampstringISO timestamp
ack()methodAcknowledge notification

Next Steps