new EventQueue(config)
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| config | Object | Properties
 | 
Properties:
| Name | Type | Argument | Default | Description | 
|---|---|---|---|---|
| collection | Collection | This is where the queue stores active events. | ||
| delay | Number | Array.<Number> | function | <optional> | Delay until the event will fire again if not checked off. If an array is provided the nth retry will be delayed for this.delay[n-1] milliseconds. If a function is provided the nth attempt will be delayed for this.delay(n) milliseconds. Defaults to: (attempts => Math.pow(10, attempts)*1000) | |
| maxRetries | Number | <optional> | 3 | Number of retries until the event will be marked as failed. if this.delay is an array, this value defaults to this.delay.length. | 
| spread | Number | <optional> | 1000 | Milliseconds. If multiple events are due to retrial, they wont fire all at once but will be spread with a fixed delay between each of them. | 
| processInterval | Number | Milliseconds. Time until the queue checks again for due events. | ||
| timeout | Timeout | The Timeout object returned by setInterval for the periodical check. | 
Classes
Methods
- 
    _getDelay(attempts)
- 
    
    Returns the delay for the nth retry. The 0th retry is considered the first attempt and has no delay. Parameters:Name Type Description attemptsNumber Number of previous attempts. Returns:- Type
- Number | undefined
 
- 
    <async> add(event_name [, event])
- 
    
    Adds an event to the queue. For every added event the queue will immediately emit an module:docloop.EventQueue.event:attempt. Parameters:Name Type Argument Default Description event_nameString An event name eventObject <optional> 
 {} Data associated with the event Returns:- Type
- module:docloop.EventQueue~QueuedEvent
 
- 
    <async> clear()
- 
    
    Removes all events from the queue without further notice. 
- 
    <async> process()
- 
    
    Checks if events are due for retries or have failed. Every event that has more attempts than .maxRetries will be abandoned. Every event that is due will be attempted. Fires:
- 
    start()
- 
    
    Starts looking periodically for due or failed events. Returns:- Type
- this
 
- 
    stop()
- 
    
    Stops looking periodically for due or failed events. Returns:- Type
- this