Skip to content

v0.1.8

Choose a tag to compare

@anesask anesask released this 15 Feb 18:44
· 40 commits to main since this release
  • Queue Disciplines for Resources: Flexible queue management with FIFO, LIFO, and Priority disciplines

    • queueDiscipline option for Resource constructor: 'fifo' | 'lifo' | 'priority'
    • FIFO (First In First Out): Traditional queue, serves requests in arrival order (default)
    • LIFO (Last In First Out): Stack behavior, serves most recent request first
    • Priority: Serves requests by priority value (lower number = higher priority)
    • Configurable tie-breakers for priority queues: { type: 'priority', tieBreaker: 'fifo' | 'lifo' }
    • Binary search insertion (O(log n)) for efficient priority queue operations
    • Backward compatible: existing code continues to work with default FIFO behavior
    • Preemptive resources now default to priority discipline (was implicit, now explicit)
    • 17 comprehensive tests covering all queue discipline behaviors
  • Queue Disciplines for Buffer: Independent queue disciplines for put and get operations

    • putQueueDiscipline option: Controls ordering of waiting put requests
    • getQueueDiscipline option: Controls ordering of waiting get requests
    • Priority parameter added to put(amount, priority?) and get(amount, priority?) methods
    • Full support for FIFO, LIFO, and Priority disciplines on both queues
    • Enables advanced patterns like priority deliveries, rush orders, and preferential withdrawals
  • Type System for Queue Disciplines: New types in src/types/queue-discipline.ts

    • QueueDiscipline type: 'fifo' | 'lifo' | 'priority'
    • QueueDisciplineConfig interface: Extended configuration with tie-breaker support
    • validateQueueDiscipline(): Runtime validation with helpful error messages
    • getDefaultQueueConfig(): Default configuration factory

Full Changelog: v0.1.6...v0.1.8