예제 #1
0
def wrap_grpc_packet(json_body,
                     http_method,
                     url,
                     src_party_id,
                     dst_party_id,
                     job_id=None,
                     overall_timeout=DEFAULT_GRPC_OVERALL_TIMEOUT):
    _src_end_point = basic_meta_pb2.Endpoint(ip=IP, port=GRPC_PORT)
    _src = proxy_pb2.Topic(name=job_id,
                           partyId="{}".format(src_party_id),
                           role=FATEFLOW_SERVICE_NAME,
                           callback=_src_end_point)
    _dst = proxy_pb2.Topic(name=job_id,
                           partyId="{}".format(dst_party_id),
                           role=FATEFLOW_SERVICE_NAME,
                           callback=None)
    _task = proxy_pb2.Task(taskId=job_id)
    _command = proxy_pb2.Command(name=FATEFLOW_SERVICE_NAME)
    _conf = proxy_pb2.Conf(overallTimeout=overall_timeout)
    _meta = proxy_pb2.Metadata(src=_src,
                               dst=_dst,
                               task=_task,
                               command=_command,
                               operator=http_method,
                               conf=_conf)
    _data = proxy_pb2.Data(key=url,
                           value=bytes(json.dumps(json_body), 'utf-8'))
    return proxy_pb2.Packet(header=_meta, body=_data)
예제 #2
0
def wrap_grpc_packet(json_body,
                     http_method,
                     url,
                     src_party_id,
                     dst_party_id,
                     job_id=None,
                     overall_timeout=None):
    overall_timeout = JobDefaultConfig.remote_request_timeout if overall_timeout is None else overall_timeout
    _src_end_point = basic_meta_pb2.Endpoint(ip=HOST, port=GRPC_PORT)
    _src = proxy_pb2.Topic(name=job_id,
                           partyId="{}".format(src_party_id),
                           role=FATE_FLOW_SERVICE_NAME,
                           callback=_src_end_point)
    _dst = proxy_pb2.Topic(name=job_id,
                           partyId="{}".format(dst_party_id),
                           role=FATE_FLOW_SERVICE_NAME,
                           callback=None)
    _task = proxy_pb2.Task(taskId=job_id)
    _command = proxy_pb2.Command(name=FATE_FLOW_SERVICE_NAME)
    _conf = proxy_pb2.Conf(overallTimeout=overall_timeout)
    _meta = proxy_pb2.Metadata(src=_src,
                               dst=_dst,
                               task=_task,
                               command=_command,
                               operator=http_method,
                               conf=_conf)
    _data = proxy_pb2.Data(key=url,
                           value=bytes(json_dumps(json_body), 'utf-8'))
    return proxy_pb2.Packet(header=_meta, body=_data)