-
Notifications
You must be signed in to change notification settings - Fork 8k
/
collector.js
27 lines (24 loc) · 1 KB
/
collector.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { getCollectorLogger } from '../lib';
export class Collector {
/*
* @param {Object} server - server object
* @param {String} properties.type - property name as the key for the data
* @param {Function} properties.init (optional) - initialization function
* @param {Function} properties.fetch - function to query data
* @param {Function} properties.cleanup (optional) - cleanup function
* @param {Boolean} properties.fetchAfterInit (optional) - if collector should fetch immediately after init
*/
constructor(server, { type, init, fetch, cleanup, fetchAfterInit }) {
this.type = type;
this.init = init;
this.fetch = fetch;
this.cleanup = cleanup;
this.fetchAfterInit = fetchAfterInit;
this.log = getCollectorLogger(server);
}
}