Skip to content

Instantly share code, notes, and snippets.

@dsuch
dsuch / gist:214be28f1eaa8b964161
Created May 13, 2014 09:07
gevent-based service scheduling
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# gevent
from gevent import spawn_later
# Zato
from zato.server.service import Service
@dsuch
dsuch / schedule1.py
Created May 13, 2014 09:07
gevent-based service scheduling
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# gevent
from gevent import spawn_later
# Zato
from zato.server.service import Service
@dsuch
dsuch / gist:1899b8d9f6b2dbe7ea6d
Created June 11, 2014 23:46
invoke_async logs
2014-06-12 01:45:09,015 - INFO - 14823:Dummy-13 - test-random-log.ws:22 - 11 TEST_LOG: Entering test-random-log.ws
2014-06-12 01:45:09,016 - INFO - 14823:Dummy-13 - test-random-log.ws:22 - 11 TEST_LOG: test-random-log.ws handle
2014-06-12 01:45:09,019 - INFO - 14822:Dummy-18 - test-random-log.first-step:22 - 22 TEST_LOG: Entering test-random-log.first-step
2014-06-12 01:45:09,019 - INFO - 14822:Dummy-18 - test-random-log.first-step:22 - 22 TEST_LOG: test-random-log.first-step handle
2014-06-12 01:45:09,020 - INFO - 14823:Dummy-13 - test-random-log.ws:22 - 11 TEST_LOG: test-random-log.ws took 2 ms
2014-06-12 01:45:09,022 - INFO - 14822:Dummy-19 - test-random-log.second-step:22 - 33 TEST_LOG: Entering test-random-log.second-step
2014-06-12 01:45:09,022 - INFO - 14822:Dummy-19 - test-random-log.second-step:22 - 33 TEST_LOG: test-random-log.second-step handle
2014-06-12 01:45:09,023 - INFO - 14822:Dummy-19 - test-random-log.second-step:22 - 33 TEST_LOG: test-random-log.second-step took 0 ms
2014-06-12 01:45:09,02
@dsuch
dsuch / service1.py
Created June 11, 2014 23:47
invoke_async service
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# Zato
from zato.server.service import Service
class WS(Service):
def before_handle(self):
self.logger.info('11 TEST_LOG: Entering {}'.format(self.name))
@dsuch
dsuch / set-pip-certs.sh
Last active August 29, 2015 14:02
Dealing with Error: Download error for https://launchpad.net .. routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
root# mkdir /root/.pip
root# cd /root/.pip
root# wget -c http://curl.haxx.se/ca/cacert.pem
root# cat /root/.pip/pip.conf
[global]
cert = /root/.pip/cacert.pem
root#
root# ls
@dsuch
dsuch / xml_json_transform.py
Created November 11, 2014 13:02
XML/JSON transformations
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# hutools
from huTools.structured import dict2xml
# xmltodict
from xmltodict import parse as parse_xml
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
from zato.common.broker_message import SERVICE
from zato.common.util import new_cid
from zato.server.service import Service
class MyPub(Service):
def handle(self):
2014-11-19 14:08:09,304 - INFO - 6575:Dummy-55 - zato.helpers.input-logger:703 - {u'impl_name': u'zato.server.service.internal.helpers.InputLogger', u'name': u'zato.helpers.input-logger', u'cid': u'K07FHXNC1FN316X6SQ990MCQ80Q6', u'invocation_time': datetime.datetime(2014, 11, 19, 13, 8, 9, 302547), u'job_type': None, u'data_format': None, u'slow_threshold': 99999, u'request.payload': u'{"hello":"how are you?"}', u'wsgi_environ': {u'zato.request_ctx.async_msg': Bunch(action=u'101802', cid=u'K07FHXNC1FN316X6SQ990MCQ80Q6', msg_type=u'0001', payload=u'{"hello":"how are you?"}', service=u'zato.helpers.input-logger')}, u'environ': {}, u'usage': 10921, u'channel': u'invoke-async'}
@dsuch
dsuch / dicts1.py
Created February 4, 2015 20:37
Using KVDB get-key-list and get-value-list
from zato.server.service import Service
class Dicts(Service):
def handle(self):
service = 'zato.kvdb.data-dict.dictionary.get-key-list'
request = {'system':'System'}
response = self.invoke(service, request)
@dsuch
dsuch / orders.py
Last active August 29, 2015 14:15
How to use async callbacks
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# Zato
from zato.server.service import Service
ORDER_CACHE_PREFIX = 'order.{}'
class AcceptOrder(Service):