public class ServiceFacility extends Object
| Constructor and Description |
|---|
ServiceFacility() |
| Modifier and Type | Method and Description |
|---|---|
static Result |
call(Protocol protocol,
Map<String,String> extraHeaders,
Param param,
HttpMethod method,
long receiveTimeout)
Call the network to do a single-in, single-out request.
|
static Result |
callAndWait(Map<String,String> extraHeaders,
Param param,
HttpMethod method,
long receiveTimeout)
Call the network to do async task submitting and queries.
|
static boolean |
isFailedEvent(String msg) |
static boolean |
isFinishEvent(String msg) |
static boolean |
isStartEvent(String msg) |
static Map<String,String> |
prepareHeaders(Protocol protocol,
Param param)
Prepare common headers.
|
static Request |
prepareRequest(Protocol protocol,
Param param,
WebSocketEventType eventType)
Build the message body by the protocol.
|
static Result |
prepareResult(Protocol protocol,
Param param,
Response res)
Prepare the Result by the response and the input param.
|
static String |
prepareUrl(Protocol protocol,
Param param)
Prepare the connecting url.
|
static com.alibaba.dashscope.protocol.ServiceFacility.WsParam |
prepareWsParams(io.reactivex.Flowable<Param> params)
Add start-task and finish-task to the input stream.
|
static io.reactivex.Flowable<Result> |
streamCall(Map<String,String> extraHeaders,
io.reactivex.Flowable<Param> params,
long receiveTimeout)
Call the network to do a stream-in, stream-out request.
|
static void |
streamCall(Map<String,String> extraHeaders,
io.reactivex.Flowable<Param> params,
ResultCallback<Result> resultCallback)
Call the network to do a single-in, stream-out request via a callback.
|
static io.reactivex.Flowable<Result> |
streamCall(Protocol protocol,
Map<String,String> extraHeaders,
Param param,
long receiveTimeout)
Call the network to do a single-in, stream-out request.
|
static io.reactivex.Flowable<Response> |
streamingInAndDuplex(String url,
Map<String,String> headers,
io.reactivex.Flowable<Request> requests,
long receiveTimeout)
Call rpc on stream-in mode, only support websocket.
|
static void |
streamingInAndDuplexWithCallback(String url,
Map<String,String> headers,
io.reactivex.Flowable<Request> requests,
ResultCallback<Response> callback)
Call rpc with a callback on stream-in mode, only support websocket.
|
static Response |
streamingNone(Protocol protocol,
String url,
Map<String,String> headers,
Request request,
HttpMethod httpMethod,
long receiveTimeout)
Call rpc on single-in, single-out mode
|
static io.reactivex.Flowable<Response> |
streamingOut(Protocol protocol,
String url,
Map<String,String> headers,
Request request,
HttpMethod httpMethod,
StreamingMode mode,
long receiveTimeout)
Call rpc on single-in, stream-out mode
|
static void |
streamingOutWithCallback(Protocol protocol,
String url,
Map<String,String> headers,
Request request,
HttpMethod httpMethod,
StreamingMode mode,
ResultCallback<Response> callback)
Call rpc on single-in mode with a callback.
|
static Result |
wait(SubmitParam submitParam,
Class<? extends Result> clazz,
long receiveTimeout)
Wait for an async task to finish, check every 5 seconds.
|
public static Result callAndWait(Map<String,String> extraHeaders, Param param, HttpMethod method, long receiveTimeout)
extraHeaders - Extra headers to pass, basic headers will be built inside this function.param - The input param to submit the task.method - The http method.receiveTimeout - The reception timeout of a single message.public static Result wait(SubmitParam submitParam, Class<? extends Result> clazz, long receiveTimeout)
submitParam - The `SubmitParam` used to query the task.clazz - The result class.receiveTimeout - The reception timeout.public static io.reactivex.Flowable<Result> streamCall(Map<String,String> extraHeaders, io.reactivex.Flowable<Param> params, long receiveTimeout)
You can use this function to send binary(binaries).
extraHeaders - Extra headers to pass, basic headers will be built inside this function.params - The input param containing the necessary payload information.receiveTimeout - The reception timeout of a single message.public static void streamCall(Map<String,String> extraHeaders, io.reactivex.Flowable<Param> params, ResultCallback<Result> resultCallback)
You can use this function to send binary(binaries).
extraHeaders - Extra headers to pass, basic headers will be built inside this function.params - The input param containing the necessary payload information.resultCallback - The callback to receive messages.public static io.reactivex.Flowable<Result> streamCall(Protocol protocol, Map<String,String> extraHeaders, Param param, long receiveTimeout)
This function does not support binary.
protocol - The protocol.extraHeaders - Extra headers to pass, basic headers will be built inside this function.param - The input param containing the necessary payload information.receiveTimeout - The reception timeout.ApiException - when error occurs.public static Result call(Protocol protocol, Map<String,String> extraHeaders, Param param, HttpMethod method, long receiveTimeout) throws ApiException
This function does not support binary.
protocol - The protocol.extraHeaders - Extra headers to pass, basic headers will be built inside this function.param - The input param containing the necessary payload information.method - The http method.receiveTimeout - The reception timeout.ApiException - when error occurs.public static String prepareUrl(Protocol protocol, Param param) throws ApiException
protocol - The protocol.param - The input param.ApiException - when the protocol is not supported.public static Map<String,String> prepareHeaders(Protocol protocol, Param param)
protocol - The protocol.param - The input param.public static Request prepareRequest(Protocol protocol, Param param, WebSocketEventType eventType)
protocol - The protocol, can be 'http' or 'websocket'.param - The input parameventType - The WebSocketEventType to built into the RequestApiException - if the input is invalid.public static com.alibaba.dashscope.protocol.ServiceFacility.WsParam prepareWsParams(io.reactivex.Flowable<Param> params)
params - The params needed to send.public static Result prepareResult(Protocol protocol, Param param, Response res)
protocol - The protocol.param - The input param to call `returnType`res - The response.public static io.reactivex.Flowable<Response> streamingOut(Protocol protocol, String url, Map<String,String> headers, Request request, HttpMethod httpMethod, StreamingMode mode, long receiveTimeout) throws ApiException
protocol - The protocol.url - The url.headers - The headers.request - The input request.receiveTimeout - The timeout of receiving single message.httpMethod - The `HttpMethod` to use if the protocol is http.mode - The streaming mode.ApiExceptionpublic static Response streamingNone(Protocol protocol, String url, Map<String,String> headers, Request request, HttpMethod httpMethod, long receiveTimeout) throws ApiException
protocol - The protocol.url - The url.headers - The headers.request - The input request.receiveTimeout - The timeout of receiving single message.httpMethod - The `HttpMethod` to use if the protocol is http.ApiExceptionpublic static void streamingOutWithCallback(Protocol protocol, String url, Map<String,String> headers, Request request, HttpMethod httpMethod, StreamingMode mode, ResultCallback<Response> callback)
protocol - The protocol.url - The url.headers - The headers.request - The input request.mode - The streaming mode.httpMethod - The `HttpMethod` to use if the protocol is http.callback - The custom callback to use.public static void streamingInAndDuplexWithCallback(String url, Map<String,String> headers, io.reactivex.Flowable<Request> requests, ResultCallback<Response> callback)
url - The url.headers - The headers.requests - The iterable input request.callback - The custom callback to use.public static io.reactivex.Flowable<Response> streamingInAndDuplex(String url, Map<String,String> headers, io.reactivex.Flowable<Request> requests, long receiveTimeout)
url - The url.headers - The headers.requests - The iterable input request.receiveTimeout - The message timeout.public static boolean isFinishEvent(String msg)
public static boolean isStartEvent(String msg)
public static boolean isFailedEvent(String msg)
Copyright © 2023. All rights reserved.