Search in sources :

Example 21 with CallableUnitCallback

use of org.ballerinalang.bre.bvm.CallableUnitCallback in project ballerina by ballerina-lang.

the class ReadCharacters method readCharactersResponse.

/*
     * Callback method of the read characters response.
     *
     * @param result the result returned as the response.
     * @return the processed event result.
     */
private static EventResult readCharactersResponse(EventResult<String, EventContext> result) {
    BStruct errorStruct = null;
    EventContext eventContext = result.getContext();
    Context context = eventContext.getContext();
    CallableUnitCallback callback = eventContext.getCallback();
    String readChars = result.getResponse();
    Throwable error = eventContext.getError();
    if (null != error) {
        errorStruct = IOUtils.createError(context, error.getMessage());
        context.setReturnValues(errorStruct);
    } else {
        context.setReturnValues(new BString(readChars));
    }
    callback.notifySuccess();
    return result;
}
Also used : EventContext(org.ballerinalang.nativeimpl.io.events.EventContext) Context(org.ballerinalang.bre.Context) EventContext(org.ballerinalang.nativeimpl.io.events.EventContext) BStruct(org.ballerinalang.model.values.BStruct) BString(org.ballerinalang.model.values.BString) BString(org.ballerinalang.model.values.BString) CallableUnitCallback(org.ballerinalang.bre.bvm.CallableUnitCallback)

Aggregations

CallableUnitCallback (org.ballerinalang.bre.bvm.CallableUnitCallback)21 BStruct (org.ballerinalang.model.values.BStruct)15 Context (org.ballerinalang.bre.Context)12 EventContext (org.ballerinalang.nativeimpl.io.events.EventContext)11 BValue (org.ballerinalang.model.values.BValue)9 ParamDetail (org.ballerinalang.connector.api.ParamDetail)8 GrpcCallableUnitCallBack (org.ballerinalang.net.grpc.GrpcCallableUnitCallBack)7 Resource (org.ballerinalang.connector.api.Resource)6 BString (org.ballerinalang.model.values.BString)5 BType (org.ballerinalang.model.types.BType)4 BInteger (org.ballerinalang.model.values.BInteger)3 StreamObserver (io.grpc.stub.StreamObserver)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 BLangConnectorSPIUtil (org.ballerinalang.connector.api.BLangConnectorSPIUtil)2 BallerinaConnectorException (org.ballerinalang.connector.api.BallerinaConnectorException)2 Executor (org.ballerinalang.connector.api.Executor)2 Message (org.ballerinalang.net.grpc.Message)2 PROTOCOL_PACKAGE_HTTP (org.ballerinalang.net.http.HttpConstants.PROTOCOL_PACKAGE_HTTP)2