use of org.ballerinalang.net.grpc.proto.definition.File in project ballerina by ballerina-lang.
the class ServiceProtoBuilder method process.
@Override
public void process(ServiceNode serviceNode, List<AnnotationAttachmentNode> annotations) {
for (AnnotationAttachmentNode annotationNode : annotations) {
if (ANN_MESSAGE_LISTENER.equals(annotationNode.getAnnotationName().getValue())) {
return;
}
}
try {
File fileDefinition = ServiceProtoUtils.generateProtoDefinition(serviceNode);
ServiceConfiguration serviceConfig = ServiceProtoUtils.getServiceConfiguration(serviceNode);
ServiceProtoUtils.writeServiceFiles(fileDefinition, serviceNode.getName().getValue(), serviceConfig.isGenerateClientConnector());
} catch (GrpcServerException e) {
dlog.logDiagnostic(Diagnostic.Kind.WARNING, serviceNode.getPosition(), e.getMessage());
}
}
use of org.ballerinalang.net.grpc.proto.definition.File in project ballerina by ballerina-lang.
the class ServiceProtoUtils method generateProtoDefinition.
static File generateProtoDefinition(ServiceNode serviceNode) throws GrpcServerException {
// Protobuf file definition builder.
String packageName = serviceNode.getPosition().getSource().getPackageName();
File.Builder fileBuilder;
if (!".".equals(packageName)) {
fileBuilder = File.newBuilder(serviceNode.getName() + ServiceProtoConstants.PROTO_FILE_EXTENSION).setSyntax(ServiceProtoConstants.PROTOCOL_SYNTAX).setPackage(serviceNode.getPosition().getSource().getPackageName());
} else {
fileBuilder = File.newBuilder(serviceNode.getName() + ServiceProtoConstants.PROTO_FILE_EXTENSION).setSyntax(ServiceProtoConstants.PROTOCOL_SYNTAX);
}
ServiceConfiguration serviceConfig = getServiceConfiguration(serviceNode);
Service serviceDefinition;
if (serviceConfig.getRpcEndpoint() != null && (serviceConfig.isClientStreaming())) {
serviceDefinition = getStreamingServiceDefinition(serviceNode, serviceConfig, fileBuilder);
} else {
serviceDefinition = getUnaryServiceDefinition(serviceNode, fileBuilder);
}
fileBuilder.setService(serviceDefinition);
return fileBuilder.build();
}
Aggregations