protected synchronized long timeToNextHeartbeat(long now) {
        // if we have not joined the group or we are preparing rebalance,
        // we don't need to send heartbeats
        if (state.hasNotJoinedGroup())
            return Long.MAX_VALUE;
        if (heartbeatThread != null && heartbeatThread.hasFailed()) {
            // if an exception occurs in the heartbeat thread, raise it.
            throw heartbeatThread.failureCause();
        }
        return heartbeat.timeToNextHeartbeat(now);
    }
Check the status of the heartbeat thread (if it is active) and indicate the liveness
of the client. This must be called periodically after joining with {@link #ensureActiveGroup()}
to ensure that the member stays in the group. If an interval of time longer than the
provided rebalance timeout expires without calling this method, then the client will proactively
leave the group.

@param now current time in milliseconds
@throws RuntimeException for unexpected errors raised from the heartbeat thread
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java