public CoordinatorResult<ShareGroupHeartbeatResponseData, CoordinatorRecord> shareGroupHeartbeat(
        RequestContext context,
        ShareGroupHeartbeatRequestData request
    ) throws ApiException {
        throwIfShareGroupHeartbeatRequestIsInvalid(request);

        if (request.memberEpoch() == ShareGroupHeartbeatRequest.LEAVE_GROUP_MEMBER_EPOCH) {
            // -1 means that the member wants to leave the group.
            return shareGroupLeave(
                request.groupId(),
                request.memberId(),
                request.memberEpoch());
        }
        // Otherwise, it is a regular heartbeat.
        return shareGroupHeartbeat(
            request.groupId(),
            request.memberId(),
            request.memberEpoch(),
            request.rackId(),
            context.clientId(),
            context.clientAddress.toString(),
            request.subscribedTopicNames());
    }
Handles a ShareGroupHeartbeat request.

@param context The request context.
@param request The actual ShareGroupHeartbeat request.

@return A Result containing the ShareGroupHeartbeat response and
        a list of records to update the state machine.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java