From 843fcd27caec2b042bb7e613e67dc4480de4fe7a Mon Sep 17 00:00:00 2001 From: HuangJiaLuo <1820799930@qq.com> Date: Sat, 9 Oct 2021 22:05:39 +0800 Subject: [PATCH] feat(event): feat the function of getting the queue length --- pkg/event/define.go | 2 +- pkg/event/driver.go | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/event/define.go b/pkg/event/define.go index 3604c9c..8921901 100644 --- a/pkg/event/define.go +++ b/pkg/event/define.go @@ -18,7 +18,7 @@ type EventWorkFunc func() (interface{}, error) type DriverInterface interface { Get() *Event Put(event *Event) - GetLengthJudge() bool + GetLength() int } type ProduceInterface interface { diff --git a/pkg/event/driver.go b/pkg/event/driver.go index 78797ea..764ff22 100644 --- a/pkg/event/driver.go +++ b/pkg/event/driver.go @@ -137,12 +137,8 @@ func (d *Driver) Put(event *Event) { d.queue <- event } -func (d *Driver) GetLengthJudge() bool { - // 自动对当前的最大io数量进行判断 - if len(d.queue) > d.maxQueueSize * 1/2{ - return true - } - return false +func (d *Driver) GetLength() int { + return len(d.queue) } // NewDriver 新建 Driver