From 2d127ae3d0568aa5f44fa0218ebceb286518933d Mon Sep 17 00:00:00 2001 From: A_D Date: Mon, 19 Oct 2020 10:25:52 +0200 Subject: [PATCH] Added docs, fixed incorrect kill switch names --- docs/Killswitches.md | 53 ++++++++++++++++++++++++++++++++++++++++++++ plugins/eddn.py | 2 +- plugins/edsm.py | 2 +- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 docs/Killswitches.md diff --git a/docs/Killswitches.md b/docs/Killswitches.md new file mode 100644 index 00000000..c24197e1 --- /dev/null +++ b/docs/Killswitches.md @@ -0,0 +1,53 @@ +# Kill Switches + +EDMarketConnector implements a Kill Switch system that allows us to disable features based on a version mask. Meaning that we can stop major bugs from affecting the services we support, at the expense of disabling that support. + +## Format + +Killswitches are stored in a JSON file that is queried by EDMC on startup. The format is as follows: + +| Key | Type | Description | +| --------------: | :-----: | :------------------------------------------------------------ | +| `version` | integer | the version of the Kill Switch JSON file, always 1 | +| `last_updated` | string | When last the kill switches were updated (for human use only) | +| `kill_switches` | array | The kill switches this file contains (expanded below) | + +The `kill_switches` array contains kill switch objects. Each contains two fields: + +| Key | Type | Description | +| --------: | :----------------: | :---------------------------------------------------------------------- | +| `version` | `semantic version` | The version of EDMC these kill switches apply to (Must be valid semver) | +| `kills` | array of strings | The different keys to disable | +An example follows: + +```json +{ + "version": 1, + "last_updated": "19 October 2020", + "kill_switches": [ + { + "version": "1.0.0", + "kills": ["plugins.eddn.send"] + } + ] +} +``` + +### Versions + +Versions are checked using equality checks on `semantic_version.Version` instances. Meaning that **all** fields are checked (ie, Major, Minor, Patch, Prerelease, and Build). + +## Plugin support + +Plugins may use the killswitch system simply by hosting their own version of the killswitch file, and fetching it +using `killswitch.get_kill_switches(target='https://example.com/myplugin_killswitches.json')`. The returned object can +be used to query the kill switch set, see the docstrings for more information on specifying versions. + +## Currently supported killswitch strings + +The current recognised (to EDMC and its internal plugins) killswitch strings are as follows: +| Kill Switch | Description | +| :--------------------- | :---------------------------------------------------------------------------------------- | +| `plugins.eddn.send` | Disables all use of the send method on EDDN (effectively disables EDDN updates) | +| `plugins.edsm.worker` | Disables the send portion of the EDSM worker thread (effectively disables EDSM updates) | +| `plugins.inara.worker` | Disables the send portion of the INARA worker thread (effectively disables INARA updates) | diff --git a/plugins/eddn.py b/plugins/eddn.py index 06875fdb..e4813b88 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -127,7 +127,7 @@ class EDDN: :param cmdr: the CMDR to use as the uploader ID :param msg: the payload to send """ - if killswitch.is_disabled('plugins.eddn_send'): + if killswitch.is_disabled('plugins.eddn.send'): logger.warning("eddn.send has been disabled via killswitch. Returning") return diff --git a/plugins/edsm.py b/plugins/edsm.py index 1fb6704e..d6e0f706 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -509,7 +509,7 @@ def worker() -> None: logger.debug('Empty queue message, setting closing = True') closing = True # Try to send any unsent events before we close - if killswitch.is_disabled("plugins.eddn.worker"): + if killswitch.is_disabled("plugins.edsm.worker"): logger.warning('EDSM worker has been disabled via kill switch. Not uploading data.') continue