示例#1
0
 def test_messagedriven_service_wrapper(self, mock_service_class):
     services = ['service 1', 'service 2']
     name = 'some name'
     params = {'param1': 'value1'}
     messagedriven_service.messagedriven_service(services, name, params)
     mock_service_class.assert_called_with(services, name, params)
     mock_service_class.return_value.start.assert_called_once()
示例#2
0
def run_message_thread():
    try:
        messagedriven_service(SERVICEDEFINITION, "Export")
    except Exception as e:
        print(
            "ERROR: no connection with GOB message broker, application is stopped"
        )
        print(e)
    os._exit(os.EX_UNAVAILABLE)
示例#3
0
def run_message_thread():
    try:
        # First create queues with bindings if not exists yet
        create_queue_with_binding(exchange=MESSAGE_EXCHANGE,
                                  queue=KVK_MESSAGE_QUEUE,
                                  key=KVK_MESSAGE_KEY)
        create_queue_with_binding(exchange=MESSAGE_EXCHANGE,
                                  queue=UPDATE_OBJECT_COMPLETE_QUEUE,
                                  key=UPDATE_OBJECT_COMPLETE_KEY)

        messagedriven_service(SERVICEDEFINITION, "Message")
    except:  # noqa: E722 do not use bare 'except'
        pass
    print(
        "ERROR: no connection with GOB message broker, application is stopped")
    os._exit(os.EX_UNAVAILABLE)
示例#4
0
def run_message_thread():
    """
    The connection with GOB is run in a separate service

    If the connection cannot be initialized or breaks during operation
    the application is killed using os._exit with an exit code that signals unavailability

    :return: None
    """
    try:
        messagedriven_service(SERVICEDEFINITION, "StUF")
    except:  # noqa: E722 do not use bare 'except'
        pass
    print(
        "ERROR: no connection with GOB message broker, application is stopped")
    os._exit(os.EX_UNAVAILABLE)
示例#5
0
    def test_messagedriven_service(self, mocked_connection, mocked_init, mocked_send, mocked_heartbeat):

        global return_method
        return_method = fixtures.random_string()

        service_definition = fixtures.get_service_fixture(handler)
        single_service = [v for v in service_definition.values()][0]

        expected_key = single_service['key']
        expected_queue = single_service['queue']
        expected_exchange = single_service['exchange']

        messagedriven_service.keep_running = False
        messagedriven_service.messagedriven_service(service_definition, "Any name")

        mocked_init.assert_called_with()
        mocked_connection.assert_called_with(CONNECTION_PARAMS, {})
        mocked_connection.return_value.__enter__.return_value.subscribe\
            .assert_called_with([{'exchange': expected_exchange,
                                  'name': expected_queue,
                                  'key': expected_key}], mock.ANY)  # Inner function

        mocked_heartbeat.asssert_not_called()
        mocked_send.assert_not_called()
示例#6
0
def init():
    if __name__ == "__main__":
        messagedriven_service(SERVICEDEFINITION, "Distribute")
示例#7
0
        'queue': PROGRESS_QUEUE,
        'handler': on_workflow_progress
    },
    'start_tasks': {
        'queue': TASK_QUEUE,
        'handler': task_queue.on_start_tasks,
    },
    'task_completed': {
        'queue': TASK_RESULT_QUEUE,
        'handler': task_queue.on_task_result
    },
}

parser = argparse.ArgumentParser(prog="python -m gobworkflow",
                                 description="GOB Workflow manager")

parser.add_argument('--migrate',
                    action='store_true',
                    default=False,
                    help='migrate the management database')
args = parser.parse_args()

if args.migrate:
    print("Storage migration forced")
    connect(force_migrate=True)
else:
    connect()

    params = {"prefetch_count": 1, "load_message": False}
    messagedriven_service(SERVICEDEFINITION, "Workflow", params)
示例#8
0
def init():
    if __name__ == "__main__":
        messagedriven_service(SERVICEDEFINITION, "Import")
示例#9
0
def init():
    if __name__ == "__main__":
        messagedriven_service(SERVICEDEFINITION, "Test",
                              {"thread_per_service": True})