Rewrite schemas during transition period

This commit is contained in:
Jonathan Harris 2017-07-03 12:58:44 +01:00
parent a959390ff7
commit 04a8f91b8c

View File

@ -37,6 +37,11 @@ statsCollector = StatsCollector()
statsCollector.start()
# Migration from schemas.elite-markets.net to eddn.edcd.io - Remove after transition complete!
import re
TRANSITION_RE = re.compile('^https://eddn.edcd.io/schemas/(.+)')
def configure():
# Get the list of transports to bind from settings. This allows us to PUB
# messages to multiple announcers over a variety of socket types
@ -145,6 +150,11 @@ def parse_and_error_handle(data):
if validationResults.severity <= ValidationSeverity.WARN:
parsed_message['header']['gatewayTimestamp'] = datetime.utcnow().isoformat() + 'Z'
# Migration from schemas.elite-markets.net to eddn.edcd.io - Remove after transition complete!
match = TRANSITION_RE.match(parsed_message['$schemaRef'])
if match and match.group(1):
parsed_message['$schemaRef'] = 'http://schemas.elite-markets.net/eddn/%s' % match.group(1)
ip_hash_salt = Settings.GATEWAY_IP_KEY_SALT
if ip_hash_salt:
# If an IP hash is set, salt+hash the uploader's IP address and set