示例#1
0
 def setUp(self):
     super().setUp()
     self.sas_url = 'https://fake.sas.url'
     self.rc_ingest_url = 'https://fake.rc.url'
     self.router = RequestRouter(
         sas_url=self.sas_url,
         rc_ingest_url=self.rc_ingest_url,
         cert_path='fake/cert/path',
         ssl_key_path='fake/key/path',
         request_mapping=request_mapping,
         ssl_verify=False,
     )
示例#2
0
 def setUp(self) -> None:
     super().setUp()
     self.sas_url = 'https://fake.sas.url'
     self.rc_ingest_url = 'https://fake.rc.url'
     self.crl_validator_mock = mock.MagicMock(spec=CRLValidator)
     self.router = RequestRouter(
         sas_url=self.sas_url,
         rc_ingest_url=self.rc_ingest_url,
         cert_path='fake/cert/path',
         ssl_key_path='fake/key/path',
         request_mapping=request_mapping,
         ssl_verify=False,
         crl_validator=self.crl_validator_mock,
     )
示例#3
0
def run():
    """
    Top-level function for configuration controller
    """
    config = get_config()
    scheduler = BackgroundScheduler()
    db_engine = create_engine(
        url=config.SQLALCHEMY_DB_URI,
        encoding=config.SQLALCHEMY_DB_ENCODING,
        echo=config.SQLALCHEMY_ECHO,
        future=config.SQLALCHEMY_FUTURE,
        pool_size=config.SQLALCHEMY_ENGINE_POOL_SIZE,
        max_overflow=config.SQLALCHEMY_ENGINE_MAX_OVERFLOW,
    )
    session_manager = SessionManager(db_engine=db_engine)
    router = RequestRouter(
        sas_url=config.SAS_URL,
        rc_ingest_url=config.RC_INGEST_URL,
        cert_path=config.CC_CERT_PATH,
        ssl_key_path=config.CC_SSL_KEY_PATH,
        request_mapping=request_mapping,
        ssl_verify=config.SAS_CERT_PATH,
    )
    fluentd_client = FluentdClient()
    for request_type in RequestTypes:
        req_type = request_type.value
        response_type = request_response[req_type]
        consumer = RequestDBConsumer(
            request_type=req_type,
            request_processing_limit=config.REQUEST_PROCESSING_LIMIT,
        )
        processor = ResponseDBProcessor(
            response_type=response_type,
            process_responses_func=processor_strategies[req_type]["process_responses"],
            fluentd_client=fluentd_client,
        )

        scheduler.add_job(
            process_requests,
            args=[consumer, processor, router, session_manager, fluentd_client],
            trigger=IntervalTrigger(
                seconds=config.REQUEST_PROCESSING_INTERVAL_SEC,
            ),
            max_instances=1,
            name=f"{req_type}_job",
        )
    scheduler.start()

    while True:
        time.sleep(1)