able to read chan and write chan
This commit is contained in:
@@ -16,6 +16,13 @@ type TopicPartition struct {
|
||||
Topic string
|
||||
Partition int32
|
||||
}
|
||||
const (
|
||||
TopicPartitionFmt = "%s/%s_%2d"
|
||||
)
|
||||
func (tp *TopicPartition) String() string {
|
||||
return fmt.Sprintf(TopicPartitionFmt, tp.Namespace, tp.Topic, tp.Partition)
|
||||
}
|
||||
|
||||
type TopicLock struct {
|
||||
sync.Mutex
|
||||
cond *sync.Cond
|
||||
@@ -101,3 +108,13 @@ func (tl *TopicLocks) ReleaseLock(partition TopicPartition, isPublisher bool) {
|
||||
delete(tl.locks, partition)
|
||||
}
|
||||
}
|
||||
|
||||
func (tl *TopicLocks) ListTopicPartitions() (tps []TopicPartition) {
|
||||
tl.Lock()
|
||||
defer tl.Unlock()
|
||||
|
||||
for k := range tl.locks {
|
||||
tps = append(tps, k)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user