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