def create_low_level_request(request_type):
    return Request(body="Request".encode('UTF-8'),
                   metadata="MyMetadata",
                   cache_key="",
                   cache_ttl=0,
                   channel="MyTestChannelName",
                   client_id="CommandQueryInitiator",
                   timeout=111000,
                   request_type=request_type,
                   tags=[
                       ('key', 'value'),
                       ('key2', 'value2'),
                   ])
Ejemplo n.º 2
0
def send_query_request(channel_name, client_id, kube_add):
    request = Request(body="Request".encode('UTF-8'),
                      metadata="MyMetadata",
                      cache_key="",
                      cache_ttl=0,
                      channel=channel_name,
                      client_id="QueryInitiator",
                      timeout=1000,
                      request_type=RequestType.Query,
                      tags=[
                          ('key', 'value'),
                          ('key2', 'value2'),
                      ])
    initiator = Initiator(kube_add)
    response = initiator.send_request(request)
# SOFTWARE.

import jwt

from kubemq.commandquery.lowlevel.initiator import Initiator
from kubemq.commandquery.lowlevel.request import Request
from kubemq.commandquery.request_type import RequestType

if __name__ == "__main__":

    initiator = Initiator("localhost:50000",
                          encryptionHeader=jwt.encode({},
                                                      algorithm="HS256",
                                                      key="some-key"))
    request = Request(
        body="hello kubemq - sending a command, please reply'".encode('UTF-8'),
        metadata="",
        cache_key="",
        cache_ttl=0,
        channel="testing_Command_channel",
        client_id="hello-world-sender",
        timeout=10000,
        request_type=RequestType.Command,
    )
    try:
        response = initiator.send_request(request)
        print('Response Received:%s Executed at::%s' %
              (response.request_id, response.timestamp))
    except Exception as err:
        print('command error::%s' % (err))