Exemplo n.º 1
0
""" File to house a requester service """

from service_framework.utils.logging_utils import get_logger

LOG = get_logger()


def setup_config(config):
    """
    Make config arguments the proper type!
    """
    LOG.info('Setting up config!')
    config['num_req_to_send'] = int(config['num_req_to_send'])
    return config


def init_function(to_send, config):
    """
    Call this function prior to starting the service
    """
    LOG.info('Init Function was called!')

    for num in range(config['num_req_to_send']):
        payload = {'to_echo': 'Hello World - ' + str(num)}

        LOG.info('Sending payload: %s', payload)
        returned = to_send('request', payload)

        LOG.info('Got Response: %s', returned)

    LOG.info('GOT ALL RESPONSES')
""" File to house service utility functions """

import threading
import time
import uuid
import zmq
from service_framework.utils import (
    connection_utils,
    logging_utils,
    socket_utils,
    utils,
    validation_utils
)

LOG = logging_utils.get_logger()
RUN_FLAG = True


def entrance_point(
        service_definition,
        config,
        addresses,
        logger_args_dict,
        is_main=False,
        min_wait_time_s=0):
    """
    service_path::obj Either a string -> to then import the service file or an object itself.
    addresses = {
        'in': {
            'connection_name': {
                'socket_name': str