예제 #1
0
 def ready(self):
     self.mdk = start()
     timeout = getattr(settings, "MDK_DEFAULT_TIMEOUT", None)
     if timeout is not None:
         self.mdk.setDefaultDeadline(timeout)
     atexit.register(self.mdk.stop)
     self.mdk_ready(self.mdk)
예제 #2
0
def main():
    url = sys.argv[1]
    mdk = start()
    session = mdk.session()
    session.setDeadline(1.0)
    mdk.stop()
    req_ssn = requests_session(session)
    try:
        req_ssn.get(url).content
    except Timeout:
        sys.exit(123)
        return
예제 #3
0
def main():
    url = sys.argv[1]
    mdk = start()
    session = mdk.session()
    session.setDeadline(1.0)
    mdk.stop()
    req_ssn = requests_session(session)
    try:
        req_ssn.get(url).content
    except Timeout:
        sys.exit(123)
        return
예제 #4
0
파일: flask.py 프로젝트: jai2033shankar/mdk
def mdk_setup(app, timeout=None, mdk=None):
    """
    Setup MDK integration with Flask.

    :param app: A Flask application instance.
    :param timeout: Default timeout in seconds to set for the MDK session.
    :param mdk: An optional ``mdk.MDK`` instance to use instead of creating a
        new one. It will not be started or stopped.

    :return: The ``mdk.MDK`` instance.
    """
    if mdk is None:
        app.mdk = start()
        atexit.register(app.mdk.stop)
    else:
        app.mdk = mdk
    if timeout is not None:
        app.mdk.setDefaultDeadline(timeout)
    request_started.connect(_on_request_started, app)
    got_request_exception.connect(_on_request_exception, app)
    request_tearing_down.connect(_on_request_tearing_down, app)
    return app.mdk
예제 #5
0
파일: client.py 프로젝트: datawire/mdk-docs
def main(mdk, service, version):
    while True:
        # Start a new session:
        ssn = mdk.session()

        # Wait 10 seconds for result, if no service is available an exception is
        # raised:
        url = ssn.resolve(service, version).address

        ssn.info("client", "Connecting to {}".format(url))
        r = requests.get(url, headers={mdk.CONTEXT_HEADER: ssn.inject()})
        ssn.info("client", "Got response {} (code {})".format(r.text, r.status_code))
        print("%s => %d: %s" % (url, r.status_code, r.text))

        time.sleep(1)


if __name__ == '__main__':
    import sys

    if len(sys.argv) < 2:
        raise Exception("usage: client service_name");

    service_name = sys.argv[1]

    MDK = mdk.start()
    try:
        main(MDK, service_name, "1.0.0")
    finally:
        MDK.stop()
예제 #6
0
"""Write some logs to the given tracing session."""

import sys
import time

from mdk import start
mdk = start()


def main():
    context = sys.argv[1]
    session = mdk.join(context)
    session.info("process1", "hello")
    time.sleep(5)  # make sure it's written
    sys.stdout.write(session.inject())
    sys.stdout.flush()
    mdk.stop()


if __name__ == '__main__':
    main()
예제 #7
0
파일: client.py 프로젝트: forkkit/mdk-docs
    while True:
        # Start a new session:
        ssn = mdk.session()

        # Wait 10 seconds for result, if no service is available an exception is
        # raised:
        url = ssn.resolve(service, version).address

        ssn.info("client", "Connecting to {}".format(url))
        r = requests.get(url, headers={mdk.CONTEXT_HEADER: ssn.inject()})
        ssn.info("client",
                 "Got response {} (code {})".format(r.text, r.status_code))
        print("%s => %d: %s" % (url, r.status_code, r.text))

        time.sleep(1)


if __name__ == '__main__':
    import sys

    if len(sys.argv) < 2:
        raise Exception("usage: client service_name")

    service_name = sys.argv[1]

    MDK = mdk.start()
    try:
        main(MDK, service_name, "1.0.0")
    finally:
        MDK.stop()
예제 #8
0
파일: client.py 프로젝트: datawire/demo
import mdk, time, requests

m = mdk.start()
ssn = m.session()

while True:
  print requests.get(ssn.resolve("hello", "1.0").address).text
  time.sleep(1.0)
예제 #9
0
파일: read_logs.py 프로젝트: datawire/mdk
def main():
    mdk = start()
    context = sys.argv[1]
    expected = set([tuple(l) for l in loads(sys.argv[2])])
    Retriever(context, expected, mdk).read_logs()
예제 #10
0
def main():
    mdk = start()
    context = sys.argv[1]
    expected = set([tuple(l) for l in loads(sys.argv[2])])
    Retriever(context, expected, mdk).read_logs()