Ejemplo n.º 1
0
 def update_workflow_state(self, workflow_id: str, workflow_state: WorkflowState):
     self.session.query(WorkflowTable).filter_by(id=workflow_id).update({
         WorkflowTable.source_state: obj_to_json(workflow_state.source_state),
         WorkflowTable.sink_state: obj_to_json(workflow_state.sink_state),
         WorkflowTable.analyzer_state: obj_to_json(workflow_state.analyzer_state)
     }, synchronize_session=False)
     self._commit_transaction()
Ejemplo n.º 2
0
 def update_workflow(self, workflow: Workflow):
     self.session.query(WorkflowTable).filter_by(id=workflow.id).update({
         WorkflowTable.config: obj_to_json(workflow.config),
         WorkflowTable.source_state: obj_to_json(workflow.states.source_state),
         WorkflowTable.sink_state: obj_to_json(workflow.states.sink_state),
         WorkflowTable.analyzer_state: obj_to_json(workflow.states.analyzer_state)
     }, synchronize_session=False)
     self._commit_transaction()
Ejemplo n.º 3
0
 def add_workflow(self, workflow: Workflow):
     self._session.add(
         WorkflowTable(
             id=workflow.id,
             config=obj_to_json(workflow.config),
             source_state=obj_to_json(workflow.states.source_state),
             sink_state=obj_to_json(workflow.states.sink_state),
             analyzer_state=obj_to_json(workflow.states.analyzer_state),
         ))
     self._commit_transaction()
Ejemplo n.º 4
0
    def send_data(  # type: ignore[override]
            self, analyzer_responses: List[TextPayload],
            config: HttpSinkConfig, **kwargs):

        headers = config.headers or DEFAULT_HEADERS

        payloads = []
        responses = []
        for analyzer_response in analyzer_responses:
            payloads.append(
                self.convertor.convert(
                    analyzer_response=analyzer_response,
                    base_payload=dict() if config.base_payload is None else
                    deepcopy(config.base_payload),
                ))

        for payload in payloads:
            req = Request(config.url,
                          data=obj_to_json(payload),
                          headers=headers)
            response = urlopen(req)
            responses.append(response)

        return responses
Ejemplo n.º 5
0
 def update_analyzer_state(self, workflow_id: str, state: Dict[str, Any]):
     self._session.query(WorkflowTable).filter_by(id=workflow_id).update(
         {WorkflowTable.analyzer_state: obj_to_json(state)},
         synchronize_session=False,
     )
     self._commit_transaction()
Ejemplo n.º 6
0
 def log_object(message, result):
     logger.debug(message + str(obj_to_json(result)))