From c0d4f4c8b01dadf3ad1f3fe396087fc9667a5de4 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Fri, 19 Jun 2015 22:23:20 +0200 Subject: [PATCH] Add outdated schema functionnality. Also added shipyard to release. --- contrib/monitor/index.html | 6 ++++++ contrib/monitor/js/eddn.js | 9 +++++++-- ...{shipyard-v1.0-draft.json => shipyard-v1.0.json} | 0 src/eddn/Gateway.py | 6 ++++++ src/eddn/conf/Settings.py | 13 +++++++++---- src/eddn/conf/Version.py | 2 +- 6 files changed, 29 insertions(+), 7 deletions(-) rename schemas/{shipyard-v1.0-draft.json => shipyard-v1.0.json} (100%) diff --git a/contrib/monitor/index.html b/contrib/monitor/index.html index be45c70..753a421 100644 --- a/contrib/monitor/index.html +++ b/contrib/monitor/index.html @@ -100,6 +100,12 @@ - - + + Outdated messages + - + - + - + Messages passed to relay - diff --git a/contrib/monitor/js/eddn.js b/contrib/monitor/js/eddn.js index 3a76909..b502f67 100644 --- a/contrib/monitor/js/eddn.js +++ b/contrib/monitor/js/eddn.js @@ -451,6 +451,10 @@ var showStats = function(type, currentItem){ el.find(".invalid_1min").html((currentItemStats["invalid"] || {})['1min'] || 0); el.find(".invalid_5min").html((currentItemStats["invalid"] || {})['5min'] || 0); el.find(".invalid_60min").html((currentItemStats["invalid"] || {})['60min'] || 0); + + el.find(".outdated_1min").html((currentItemStats["outdated"] || {})['1min'] || 0); + el.find(".outdated_5min").html((currentItemStats["outdated"] || {})['5min'] || 0); + el.find(".outdated_60min").html((currentItemStats["outdated"] || {})['60min'] || 0); } if(type == 'relays') @@ -525,8 +529,9 @@ var start = function(){ credits: { enabled: false }, exporting: { enabled: false }, series: [ - {id: 'inbound', data: [], name: 'Messages received', zIndex: 300}, - {id: 'invalid', data: [], name: 'Invalid messages', zIndex: 1}, + {id: 'inbound', data: [], name: 'Messages received', zIndex: 300}, + {id: 'invalid', data: [], name: 'Invalid messages', zIndex: 1}, + {id: 'outdated', data: [], name: 'Outdated messages', zIndex: 1}, {id: 'outbound', data: [], name: 'Messages passed to relay', zIndex: 200} ] }).hide(); diff --git a/schemas/shipyard-v1.0-draft.json b/schemas/shipyard-v1.0.json similarity index 100% rename from schemas/shipyard-v1.0-draft.json rename to schemas/shipyard-v1.0.json diff --git a/src/eddn/Gateway.py b/src/eddn/Gateway.py index fe0e39d..1656ce0 100644 --- a/src/eddn/Gateway.py +++ b/src/eddn/Gateway.py @@ -130,6 +130,12 @@ def parse_and_error_handle(data): logger.error("Error to %s: %s" % (get_remote_address(), exc.message)) return str(exc) + # Here we check if an outdated schema has been passed + if parsed_message["$schemaRef"] in Settings.GATEWAY_OUTDATED_SCHEMAS.keys(): + response.status = 426 + statsCollector.tally("outdated") + return "FAIL: The schema you have used need an upgrade. Update your software." + validationResults = validator.validate(parsed_message) if validationResults.severity <= ValidationSeverity.WARN: diff --git a/src/eddn/conf/Settings.py b/src/eddn/conf/Settings.py index 1d436c7..6e7f86e 100644 --- a/src/eddn/conf/Settings.py +++ b/src/eddn/conf/Settings.py @@ -38,11 +38,16 @@ class _Settings(object): GATEWAY_IP_KEY_SALT = None GATEWAY_JSON_SCHEMAS = { - "http://schemas.elite-markets.net/eddn/commodity/1": "schemas/commodity-v0.1.json", - "http://schemas.elite-markets.net/eddn/commodity/1/test": "schemas/commodity-v0.1.json", - "http://schemas.elite-markets.net/eddn/commodity/2": "schemas/commodity-v2.0.json", - "http://schemas.elite-markets.net/eddn/commodity/2/test": "schemas/commodity-v2.0.json" + "http://schemas.elite-markets.net/eddn/commodity/2/test": "schemas/commodity-v2.0.json", + + "http://schemas.elite-markets.net/eddn/shipyard/1": "schemas/shipyard-v1.0.json", + "http://schemas.elite-markets.net/eddn/shipyard/1/test": "schemas/shipyard-v1.0.json" + } + + GATEWAY_OUTDATED_SCHEMAS = { + "http://schemas.elite-markets.net/eddn/commodity/1": "schemas/commodity-v0.1.json", + "http://schemas.elite-markets.net/eddn/commodity/1/test": "schemas/commodity-v0.1.json" } ############################################################################### diff --git a/src/eddn/conf/Version.py b/src/eddn/conf/Version.py index 5b67b06..576116a 100644 --- a/src/eddn/conf/Version.py +++ b/src/eddn/conf/Version.py @@ -1,3 +1,3 @@ # coding: utf8 -__version__ = "0.4" +__version__ = "0.5 BETA"