Skip to content

Instantly share code, notes, and snippets.

@curtisforrester
Created March 10, 2016 19:45
Show Gist options
  • Save curtisforrester/6177352a28191d0bb4c3 to your computer and use it in GitHub Desktop.
Save curtisforrester/6177352a28191d0bb4c3 to your computer and use it in GitHub Desktop.
# Condensed for readablity
@inc_redis_counter(key=RedisKeys.REPLICATION_TRAFFIC_KEY_PREFIX)
def handle_replication_message(message):
data = json.loads(message) if isinstance(message, six.string_types) else message
rep_data = data.get('lookout_rep') # Replication data
category = rep_data.get('type') # The category
payload = rep_data.get('data')
if category == 'metrics':
view_handlers.handle_metrics_put(customer_num=customer_num, data=payload)
elif category == 'portal':
import Portal.view_handlers as portal_view_handlers
func_name = rep_data.get('function_name', '')
if func_name == 'some_web_action':
enabled = int(rep_data.get('enabled', 0))
some_id = int(rep_data.get('some_id', 0))
portal_view_handlers.act_on_some_id(id_parm=some_id, enabled=enabled)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment