Example #1
0
    def create_low_level_request(self, request, override_params=None):
        request = LowLevelRequest(request_type=self.request_type,
                                  channel=self.channel_name,
                                  client_id=self.client_id,
                                  timeout=self.timeout,
                                  cache_key=self.cache_key,
                                  cache_ttl=self.cache_ttl,
                                  request_id=request.request_id,
                                  body=request.body,
                                  metadata=request.metadata,
                                  tags=request.tags)

        if override_params:
            if override_params.timeout:
                request.timeout = override_params.timeout
            if override_params.cache_key:
                request.cache_key = override_params.cache_key
            if override_params.cache_ttl:
                request.cache_ttl = override_params.cache_ttl

        return request
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'),
                   ])
Example #3
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))