-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Added Monitor Config Parser - #39"
This reverts commit 4c68abe.
- Loading branch information
Showing
2 changed files
with
4 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,4 @@ | ||
import compile from "string-template/compile.js" | ||
|
||
const URITemplate = compile("{0}:{1}"); | ||
const DefaultPublisherTemplate = { | ||
Origin: compile("app.{0}.com"), | ||
Description: compile("Logs Published by {0}") | ||
} | ||
const DefaultContextTemplate = { | ||
Origin: compile("app.{0}.com/{1}"), | ||
Description: compile("Log Published by {0} to context {1}"), | ||
Kind: { | ||
logs: [] | ||
} | ||
} | ||
|
||
function formatPublisherConfig(monitorConfig) { | ||
const publisherConfig = {} | ||
publisherConfig.publisher = monitorConfig.publisher || process.env.PUBLISHER | ||
publisherConfig.origin = monitorConfig.origin || DefaultPublisherTemplate.Origin(publisherConfig.publisher) | ||
publisherConfig.description = monitorConfig.description || DefaultPublisherTemplate.Description(publisherConfig.publisher) | ||
return publisherConfig | ||
} | ||
|
||
function formatCotextConfig(publisher, monitorConfig) { | ||
const contextConfig = {} | ||
contextConfig.context = monitorConfig.context || process.env.CONTEXT | ||
contextConfig.origin = monitorConfig.origin || DefaultContextTemplate.Origin(publisher, contextConfig.context) | ||
contextConfig.description = monitorConfig.description || DefaultPublisherTemplate.Description(publisher, contextConfig.context) | ||
contextConfig.kind = monitorConfig.kind || DefaultContextTemplate.Kind | ||
return contextConfig | ||
} | ||
|
||
export function getMonitorConfigs(config) { | ||
const monitorConfigs = {} | ||
monitorConfigs.monitorPort = config.MONITOR.port || process.env.MONITOR_PORT | ||
monitorConfigs.monitorURI = config.MONITOR.server || process.env.MONITOR_URI | ||
monitorConfigs.monitorListener = URITemplate(monitorConfigs.monitorURI, monitorConfigs.monitorPort) || process.env.LISTENER | ||
monitorConfigs.publisher = formatPublisherConfig(config.MONITOR.publisher) | ||
monitorConfigs.context = formatCotextConfig(monitorConfigs.publisher.publisher, config.MONITOR.context) | ||
return monitorConfigs | ||
} | ||
|
||
// can be used for test | ||
// console.log( | ||
// getMonitorConfigs({ | ||
// MONITOR: { | ||
// port: "8080", | ||
// server: "localhost", | ||
// publisher: { | ||
// publisher: "test" | ||
// }, | ||
// context: { | ||
// context: "testcon" | ||
// } | ||
// } | ||
// }) | ||
// ) | ||
export function getMonitorConfigs(params) { | ||
var monitorAddresses = [] | ||
|
||
} |