private boolean sendOutRequest()

in tchannel-core/src/main/java/com/uber/tchannel/api/SubChannel.java [268:321]


    private boolean sendOutRequest(
        @NotNull OutRequest<?> outRequest,
        @Nullable Connection connection
    ) {
        Request request = outRequest.getRequest();

        try {
            // the (successfully created) tracing span is finish()'ed via callback on outRequest.getFuture()
            Tracing.startOutboundSpan(outRequest, topChannel.getTracer(), topChannel.getTracingContext());
        } catch (RuntimeException e) {
            outRequest.setLastError(ErrorType.BadRequest, e);
            outRequest.setFuture();
            return false;
        }

        // Validate if the ArgScheme is set correctly
        if (request.getArgScheme() == null) {
            request.setArgScheme(ArgScheme.RAW);
            outRequest.setLastError(ErrorType.BadRequest, "Expect call request to have Arg Scheme specified");
            outRequest.setFuture();
            return false;
        }

        // Set the default retry flag if it is not set
        if (request.getRetryFlags() == null) {
            request.setRetryFlags("c");
        }

        long initTimeout = this.initTimeout;
        if (initTimeout <= 0) {
            initTimeout = request.getTimeout();
        }

        if (connection == null) {
            outRequest.setLastError(ErrorType.BadRequest, new TChannelNoPeerAvailable());
            outRequest.setFuture();
            return false;
        } else if (!connection.waitForIdentified(initTimeout)) {
            connection.clean();
            if (connection.lastError() != null) {
                outRequest.setLastError(ErrorType.NetworkError, connection.lastError());
            } else {
                // TODO - extract the formatting and reuse all over
                String logMessage =  String.format("%s/%s::%s", connection.getPeer().remoteAddress,
                        request.getService(), request.getEndpoint());
                outRequest.setLastError(ErrorType.NetworkError, new TChannelConnectionTimeout(logMessage));
            }
            return false;
        }

        // Get a response router for our outbound channel
        ResponseRouter router = connection.channel().pipeline().get(ResponseRouter.class);
        return router.expectResponse(outRequest);
    }