Beispiel #1
0
def module_run(txn):
    print "py module run"

    # Increase counters
    mod_metrics = Metrics.module()
    mod_metrics.request.inc(1)

    mod_dymetrics = Metrics.transaction('test')
    mod_dymetrics.request.inc(1)

    # Assemble api request
    http_query = service_http_query_req_pto.query_req()
    http_query.isHttps = False
    http_query.method = 'GET'
    http_query.host = '216.58.194.196'  # google's ip
    http_query.port = 80
    http_query.uri = '/'
    http_query.header.add(name='Host', value='google.com')
    http_query.timeout = 1000

    # invoke iocall to s1 service
    ret = txn.iocall('http', 'query', http_query, 0, _api_cb)
    print "iocall ret: {}".format(ret)

    return True
Beispiel #2
0
def module_run(txn):
    print "py module run"

    # Increase counters
    mod_metrics = Metrics.module()
    mod_metrics.request.inc(1)

    mod_dymetrics = Metrics.transaction('test')
    mod_dymetrics.request.inc(1)
    return True
Beispiel #3
0
def module_pack(txn, txndata):
    mod_metrics = Metrics.module()
    mod_metrics.response.inc(1)

    mod_dymetrics = Metrics.transaction('test')
    mod_dymetrics.response.inc(1)

    if txn.status() != Txn.Txn.TXN_OK:
        txndata.append('error')
        Logger.error('6', 'module_pack error', 'no solution')
    else:
        example_msg = txn.data()
        print "pack data: %s" % example_msg.data
        Logger.info('7', 'module_pack: data sz: {}'.format(len(example_msg.data)))

        txndata.append(example_msg.data)
Beispiel #4
0
def module_run(txn):
    print "module_run"
    mod_metrics = Metrics.module()
    mod_metrics.request.inc(1)

    mod_dymetrics = Metrics.transaction('test')
    mod_dymetrics.request.inc(1)

    # Assemble api request
    get_req_msg = service_s1_get_req_pto.get_req()
    get_req_msg.name = "hello"

    # invoke iocall to s1 service
    ret = txn.iocall('s1', 'get', get_req_msg, api_cb=_api_cb)
    print "iocall ret: {}".format(ret)
    return True
Beispiel #5
0
def module_pack(txn, txndata):
    print "py module pack"

    # Increase counters
    mod_metrics = Metrics.module()
    mod_metrics.response.inc(1)

    mod_dymetrics = Metrics.transaction('test')
    mod_dymetrics.response.inc(1)

    # Assemble response
    example_msg = txn.data()
    print "pack data: %s" % example_msg.data

    if txn.status() != Txn.Txn.TXN_OK:
        txndata.append('error')
    else:
        txndata.append(example_msg.data)
Beispiel #6
0
def module_pack(txn, txndata):
    print "py module pack"

    # Increase counters
    mod_metrics = Metrics.module()
    mod_metrics.response.inc(1)

    mod_dymetrics = Metrics.transaction('test')
    mod_dymetrics.response.inc(1)

    # Assemble response
    if txn.status() != Txn.Txn.TXN_OK:
        txndata.append('error')
    else:
        example_msg = txn.data()
        print "pack data: %s" % example_msg.data
        Logger.info('7',
                    'module_pack: data sz: {}'.format(len(example_msg.data)))

        txndata.append(example_msg.data)
Beispiel #7
0
def module_pack(txn, txndata):
    print "py module pack"

    # Increase counters
    mod_metrics = Metrics.module()
    mod_metrics.response.inc(1)

    mod_dymetrics = Metrics.transaction('test')
    mod_dymetrics.response.inc(1)

    # Assemble response
    if txn.status() != Txn.Txn.TXN_OK:
        txndata.append('error')
    else:
        responseHandler = http.Response()
        response = responseHandler.response

        response.status = 200
        response.headerlist = [('Content-type', 'text/html')]
        response.body = 'test'

        res_str = responseHandler.getFullContent()
        txndata.append(res_str)