use of org.ballerinalang.connector.api.ParamDetail in project ballerina by ballerina-lang.
the class ServerStreamingListener method invoke.
@Override
public void invoke(Message request, StreamObserver<Message> responseObserver) {
List<ParamDetail> paramDetails = resource.getParamDetails();
BValue[] signatureParams = new BValue[paramDetails.size()];
signatureParams[0] = getConnectionParameter(resource, responseObserver);
BValue requestParam = getRequestParameter(resource, request);
if (requestParam != null) {
signatureParams[1] = requestParam;
}
CallableUnitCallback callback = new GrpcCallableUnitCallBack(responseObserver, isEmptyResponse());
Executor.submit(resource, callback, null, null, signatureParams);
}
use of org.ballerinalang.connector.api.ParamDetail in project ballerina by ballerina-lang.
the class UnaryMethodListener method invoke.
@Override
public void invoke(Message request, StreamObserver<Message> responseObserver) {
List<ParamDetail> paramDetails = resource.getParamDetails();
BValue[] signatureParams = new BValue[paramDetails.size()];
signatureParams[0] = getConnectionParameter(resource, responseObserver);
BValue requestParam = getRequestParameter(resource, request);
if (requestParam != null) {
signatureParams[1] = requestParam;
}
CallableUnitCallback callback = new GrpcCallableUnitCallBack(responseObserver, isEmptyResponse());
Executor.submit(resource, callback, null, null, signatureParams);
}
use of org.ballerinalang.connector.api.ParamDetail in project ballerina by ballerina-lang.
the class DefaultStreamObserver method onCompleted.
@Override
public void onCompleted() {
Resource onCompleted = resourceMap.get(MessageConstants.ON_COMPLETE_RESOURCE);
if (onCompleted == null) {
String message = "Error in listener service definition. onCompleted resource does not exists";
LOG.error(message);
throw new RuntimeException(message);
}
List<ParamDetail> paramDetails = onCompleted.getParamDetails();
BValue[] signatureParams = new BValue[paramDetails.size()];
CallableUnitCallback callback = new GrpcCallableUnitCallBack(null);
Executor.submit(onCompleted, callback, null, null, signatureParams);
}
use of org.ballerinalang.connector.api.ParamDetail in project ballerina by ballerina-lang.
the class DefaultStreamObserver method onNext.
@Override
public void onNext(Message value) {
Resource resource = resourceMap.get(MessageConstants.ON_MESSAGE_RESOURCE);
if (resource == null) {
String message = "Error in listener service definition. onNext resource does not exists";
LOG.error(message);
throw new RuntimeException(message);
}
List<ParamDetail> paramDetails = resource.getParamDetails();
BValue[] signatureParams = new BValue[paramDetails.size()];
BValue requestParam = getRequestParameter(resource, value);
if (requestParam != null) {
signatureParams[0] = requestParam;
}
CallableUnitCallback callback = new GrpcCallableUnitCallBack(null);
Executor.submit(resource, callback, null, null, signatureParams);
}
use of org.ballerinalang.connector.api.ParamDetail in project ballerina by ballerina-lang.
the class DefaultStreamObserver method onError.
@Override
public void onError(Throwable t) {
Resource onError = resourceMap.get(MessageConstants.ON_ERROR_RESOURCE);
if (onError == null) {
String message = "Error in listener service definition. onError resource does not exists";
LOG.error(message);
throw new RuntimeException(message);
}
List<ParamDetail> paramDetails = onError.getParamDetails();
BValue[] signatureParams = new BValue[paramDetails.size()];
if (paramDetails.size() != 1) {
String message = "Error in onError resource definition. It must have only error params, but have " + paramDetails.size();
LOG.error(message);
throw new RuntimeException(message);
}
BType errorType = paramDetails.get(1).getVarType();
BStruct errorStruct = MessageUtils.getConnectorError((BStructType) errorType, t);
signatureParams[0] = errorStruct;
CallableUnitCallback callback = new GrpcCallableUnitCallBack(null);
Executor.submit(onError, callback, null, null, signatureParams);
}
Aggregations