Kind: global class
Expose an action/function triggerable via PM2 or PM2.io
Kind: static method of TX2
| Param | Type | Description |
|---|---|---|
| action_name | string |
Name of the action |
| [opts] | object |
Optional parameter |
| fn | function |
Function to be called |
Example (Action without arguments)
tx2.action('run_query', (cb) => {
cb({ success: true })
})
Example (Action with arguments)
tx2.action('run_query', arg1, (cb) => {
cb({ success: arg1 })
})
Sends an Event
Kind: static method of TX2
| Param | Type | Description |
|---|---|---|
| name | string |
Name of the event |
| data | object |
Metadata attached to the event |
Example
tx2.event('event-name', { multi: 'data' })
Sends an Issue
Kind: static method of TX2
| Param | Type | Description |
|---|---|---|
| err | string | Error |
Error object or string to notify |
Example
tx2.issue(new Error('bad error')
MetricExpose a Metric
Kind: static method of TX2
Returns: Metric - A metrics object
| Param | Type | Description |
|---|---|---|
| name | string |
Name of the metric |
| [function] | function |
Optional function to trigger every second to retrieve updated value |
Example
tx2.metric('metric_name', () => obj.value)
Example
tx2.metric('metric_name', 'unit', () => obj.value)
Example
let mn = tx2.metric('metric_name')
mn.set(20)
CounterExpose a Metric of type: Counter. By calling .inc() or .dec() you update that value
Kind: static method of TX2
| Param | Type | Description |
|---|---|---|
| name | string |
Name of the Metric |
ObjectKind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| val | function |
Return the current value |
| set | function |
Set value |
objectExpose a metric of type: Counter.
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| inc | function |
Increment value |
| dev | function |
Decrement value |