From 64a32730a203919621aa4dc3a72f1767f8f13e60 Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 15 Mar 2024 20:34:39 -0700 Subject: [PATCH] add size() --- weed/mq/topic/local_partition_publishers.go | 7 +++++++ weed/mq/topic/local_partition_subscribers.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/weed/mq/topic/local_partition_publishers.go b/weed/mq/topic/local_partition_publishers.go index 367ccce5f..c12f66336 100644 --- a/weed/mq/topic/local_partition_publishers.go +++ b/weed/mq/topic/local_partition_publishers.go @@ -50,3 +50,10 @@ func (p *LocalPartitionPublishers) IsEmpty() bool { return len(p.publishers) == 0 } + +func (p *LocalPartitionPublishers) Size() int { + p.publishersLock.RLock() + defer p.publishersLock.RUnlock() + + return len(p.publishers) +} diff --git a/weed/mq/topic/local_partition_subscribers.go b/weed/mq/topic/local_partition_subscribers.go index caadff278..d3b989d72 100644 --- a/weed/mq/topic/local_partition_subscribers.go +++ b/weed/mq/topic/local_partition_subscribers.go @@ -54,3 +54,10 @@ func (p *LocalPartitionSubscribers) IsEmpty() bool { return len(p.Subscribers) == 0 } + +func (p *LocalPartitionSubscribers) Size() int { + p.SubscribersLock.RLock() + defer p.SubscribersLock.RUnlock() + + return len(p.Subscribers) +}