func (p *PartitionClaim) Claimed() bool {
	return p.claimed(0)
}
Claimed returns whether or not the PartitionClaim indicates a valid (as of this
invocation) claim.
package marshal
import (
	"sync"
	"time"
)
type topicState struct {
	claimPartition int
	lock       *sync.RWMutex
	partitions []PartitionClaim
}
func (ts *topicState) PrintState() {
	ts.lock.RLock()
	defer ts.lock.RUnlock()
	now := time.Now().Unix()
	for partID, claim := range ts.partitions {
		state := "CLMD"
		if !claim.claimed(now) {
			state = "----"
		}
		log.Infof("      * %2d [%s]: GPID %s | CLID %s | LHB %d (%d) | LOF %d | PCL %d",
			partID, state, claim.GroupID, claim.ClientID, claim.LastHeartbeat,
			now-claim.LastHeartbeat, claim.CurrentOffset, len(claim.pendingClaims))
	}
}
type PartitionOffsets struct {
	Current   int64
	Earliest  int64
	Latest    int64
	Committed int64
}
type PartitionClaim struct {
	InstanceID    string
	ClientID      string
	GroupID       string
	LastRelease   int64
	LastHeartbeat int64
	CurrentOffset int64
	pendingClaims []chan struct{}
}
func (p *PartitionClaim) checkOwnership(msg message, checkInstanceID bool) bool {
	iid, cid, gid := msg.Ownership()
	if p.ClientID != cid || p.GroupID != gid {
		return false
	}
	return !checkInstanceID || p.InstanceID == iid
}
func (p *PartitionClaim) claimed(ts int64) bool {
	if p.LastHeartbeat == 0 {
		return false
	}
	now := ts
	if ts == 0 {
		now = time.Now().Unix()
	}
	delta := now - p.LastHeartbeat
	switch {
	case 0 <= delta && delta <= HeartbeatInterval:
		return true
	case HeartbeatInterval < delta && delta < 2*HeartbeatInterval:
		return true
	default:
		return false
	}
}