@@ -0,0 +1,1104 @@
+%22%22%22%0AA collection of handy functions for making python microservices work in the real world%0A%22%22%22%0A%0Afrom os import getpid, getenv%0Afrom socket import getfqdn,  gethostbyname%0A#import logging%0Aimport urllib2%0Aimport json%0A%0A%0Adef send_request_to_bus(input_dict,host,port,topic):%0A    %22%22%22 this is intended for publishing via http to a messaging bus %22%22%22%0A    encoded_args = json.dumps(input_dict)%0A    url = 'http://' + host + ':' + port + '//put?topic=' + topic%0A    urllib2.urlopen(url, encoded_args).read()%0A    return True    %0A%0A%0Adef describe_service():%0A    %22%22%22 this gets the essential datapoints required for monitoring a python script running as a service%22%22%22%0A    service_description = %7B%7D%0A    service_description%5B'hostname'%5D = getfqdn()%0A    service_description%5B'ip_address'%5D = gethostbyname(getfqdn())%0A    service_description%5B'process_id'%5D = getpid()%0A    service_description%5B'script_name'%5D = __file__%0A    service_description%5B'description'%5D = __doc__ # this takes the docstring from the top of the file, so fill it in!%0A#    send_request_to_bus(service_description,'service_registry')%0A    return service_description%0A    %0A

Create microservice_functions.py