예제 #1
0
파일: api.py 프로젝트: bedreamer/plane-ui
def flow_run(prj_id, flow_id):
    """
    运行流程
    给flowd发送一条运行流程的指令
    :param prj_id: 项目ID
    :param flow_id: 流程id
    :return:
        成功 OK, dict, 'no error'
        失败 ERROR, None, reason
    """
    status, project, reason = project_get_current()
    if status != OK:
        return return_error_payload(reason)

    if project.id != prj_id:
        return return_error_payload('不允许未执行的项目启动流程,当前执行的项目ID={}'.format(
            project.id))

    payload = {
        'prj_id': prj_id,
        'flow_id': flow_id,
    }
    flow_control_path = profile.get_flow_control_path()
    request = Request('run', flow_control_path, payload=payload)
    response = request.publish().wait_response()

    return response.pairs()
예제 #2
0
파일: api.py 프로젝트: bedreamer/plane-ui
def flow_get_control_command_length():
    """
    获取控制命令列表长度
    :return:
        成功 OK, int, 'no error'
        失败 ERROR, None, reason
    """
    flow_control_path = profile.get_flow_control_path()
    return llen(flow_control_path)
예제 #3
0
파일: api.py 프로젝트: bedreamer/plane-ui
def flow_stop():
    """
    停止流程
    给flowd发送一条停止运行流程的指令
    :return:
        成功 OK, dict, 'no error'
        失败 ERROR, None, reason
    """
    flow_control_path = profile.get_flow_control_path()
    request = Request('stop', flow_control_path, payload={})
    response = request.publish().wait_response()

    return response.pairs()
예제 #4
0
파일: api.py 프로젝트: bedreamer/plane-ui
def flow_get_status_from_root():
    """
    给flowd发送一条获取状态的指令
    通过向flowd进程发送status指令获取精准的流程运行状态,这个接口的数据传输、等待成本较高,
    若对状态的精准性要求不高可以调用接口:@flow_get_status_from_cache,直接从缓存获取。
    :return:
        成功 OK, dict, 'no error'
        失败 ERROR, None, reason
    """
    flow_control_path = profile.get_flow_control_path()
    request = Request('status', flow_control_path, payload={})
    response = request.publish().wait_response()

    return response.pairs()
예제 #5
0
파일: api.py 프로젝트: bedreamer/plane-ui
def flow_get_control_command():
    """
    获取流程控制命令
    一般用于flowd从redis缓存中获取其他进程对流程运行的控制指令,
    例如,开始(run),停止(stop),状态(status)等
    ::return
        成功 OK, command, 'no error'
        失败 ERROR, None, reason
    """
    flow_control_path = profile.get_flow_control_path()
    status, command_json, reason = lpop(flow_control_path)
    if status != OK:
        return return_error_payload(reason)

    if command_json is None:
        return return_warning_payload(reason)

    try:
        command = Request.load_request_from_json(command_json)
    except KeyError as e:
        return return_error_payload(E_KEY_ERROR, msg=str(e))

    return return_ok_payload(command)
예제 #6
0
파일: flowd.py 프로젝트: bedreamer/plane-ui
 def make_subscriber(self):
     self.pubsub = profile.alloc_subscriber()
     self.pubsub.psubscribe(profile.get_flow_control_path())
     self.pubsub.psubscribe(profile.get_flow_status_path())