This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use factory for poller in daemon to reduce dependency craze
- Loading branch information
1 parent
1bd6ec4
commit d9bff6f
Showing
4 changed files
with
75 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict' | ||
|
||
const Poller = require('./poller') | ||
|
||
class PollerFactory { | ||
/** | ||
* Create PollerFactory. | ||
* @param {Object} backends - Backends for fetching secret properties. | ||
* @param {Object} kubeClient - Client for interacting with kubernetes cluster. | ||
* @param {Object} metrics - Metrics client | ||
* @param {Object} customResourceManifest - CRD manifest | ||
* @param {Object} logger - Logger for logging stuff. | ||
* @param {number} pollerIntervalMilliseconds - Interval time in milliseconds for polling secret properties. | ||
*/ | ||
constructor ({ | ||
backends, | ||
kubeClient, | ||
metrics, | ||
pollerIntervalMilliseconds, | ||
customResourceManifest, | ||
logger | ||
}) { | ||
this._logger = logger | ||
this._metrics = metrics | ||
this._backends = backends | ||
this._kubeClient = kubeClient | ||
this._pollerIntervalMilliseconds = pollerIntervalMilliseconds | ||
this._customResourceManifest = customResourceManifest | ||
} | ||
|
||
/** | ||
* Create poller | ||
* @param {Object} externalSecret - External Secret custom resource oject | ||
*/ | ||
createPoller ({ externalSecret }) { | ||
const poller = new Poller({ | ||
backends: this._backends, | ||
intervalMilliseconds: this._pollerIntervalMilliseconds, | ||
kubeClient: this._kubeClient, | ||
logger: this._logger, | ||
metrics: this._metrics, | ||
customResourceManifest: this._customResourceManifest, | ||
externalSecret | ||
}) | ||
|
||
return poller | ||
} | ||
} | ||
|
||
module.exports = PollerFactory |