All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.java.ServiceGrpcServer.template Maven / Gradle / Ivy

package @java_package@;


import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.util.List;
import java.util.ArrayList;

import io.grpc.Server;
import io.grpc.ServerBuilder;
import io.grpc.stub.StreamObserver;

import farm.nurture.infra.metrics.IMetricSummary;
import farm.nurture.infra.util.FileReaderUtil;
import farm.nurture.infra.util.Logger;
import farm.nurture.infra.util.LoggerFactory;
import farm.nurture.infra.util.StringUtils;

import farm.nurture.laminar.core.sql.dao.PoolFactory;
import farm.nurture.laminar.core.sql.dao.WriteBase;
import farm.nurture.laminar.core.util.CoreUtil;
import farm.nurture.laminar.core.util.JsonUtil;
import farm.nurture.laminar.core.util.Metrics;

import @[email protected].*;
import @[email protected].*;


public class GRpcServer extends @microservice_name@Grpc.@microservice_name@ImplBase implements ServiceMethods {

    private final static Logger LOG = LoggerFactory.getLogger(GRpcServer.class);
    private static final boolean INFO_ENABLED = LOG.isInfoEnabled();
    private static final boolean DEBUG_ENABLED = LOG.isDebugEnabled();
    private static final Status OK = Status.newBuilder().setStatus(StatusCode.SUCCESS).build();

    public GRpcServer()  {
        super();
    }

    @insertservice@

    @selectservice@

    @Override
    public void execute(MultiRequests request, StreamObserver responseObserver) {

        MultiResponses.Builder replyB = executeInternal(request);

        responseObserver.onNext(replyB.build());
        responseObserver.onCompleted();
    }

    @Override
    public MultiResponses.Builder executeInternal(MultiRequests request) {

        int totalReqs = request.getRequestCount();
        MultiResponses.Builder replyB = MultiResponses.newBuilder();
        WriteBase writer = null;
        ServiceContext context = new ServiceContext();
        List> prevSteps = new ArrayList();

        List pipelines = BackendControllerFactory.getInstance().pipelines;

        try {
            //LOG.info("Initializing database Transaction : " + request.getOnTxn() );
            LOG.info( "Initializing database Transaction : {} and count is: {}" , request.getOnTxn(), totalReqs);
            if ( request.getOnTxn() ) {
                writer = new WriteBase();
                writer.beginTransaction();
            }

            for ( int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy