Exemplo n.º 1
0
    UpdateRequest,
    MoveTaskRequest,
    MoveTaskResponse,
    TaskRequest,
    QueueRequest,
    GetMetricsRequest,
    GetMetricsResponse,
    QueueMetrics,
)
from bll.queue import QueueBLL
from bll.util import extract_properties_to_lists
from bll.workers import WorkerBLL
from service_repo import APICall, endpoint
from services.utils import conform_tag_fields, conform_output_tags, conform_tags

worker_bll = WorkerBLL()
queue_bll = QueueBLL(worker_bll)


@endpoint("queues.get_by_id",
          min_version="2.4",
          request_data_model=QueueRequest)
def get_by_id(call: APICall, company_id, req_model: QueueRequest):
    queue = queue_bll.get_by_id(company_id, req_model.queue)
    queue_dict = queue.to_proper_dict()
    conform_output_tags(call, queue_dict)
    call.result.data = {"queue": queue_dict}


@endpoint("queues.get_default",
          min_version="2.4",
Exemplo n.º 2
0
 def __init__(self, worker_bll: WorkerBLL = None, es: Elasticsearch = None):
     self.worker_bll = worker_bll or WorkerBLL()
     self.es = es or es_factory.connect("workers")
     self._metrics = QueueMetrics(self.es)