From 7fd31be04927047e8347f4e32a4523fbabee1d37 Mon Sep 17 00:00:00 2001 From: pfi79 Date: Tue, 13 Feb 2024 23:59:34 +0300 Subject: [PATCH] Refactor check config of consensus (#572) Signed-off-by: Fedor Partanskiy --- pkg/types/config.go | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/pkg/types/config.go b/pkg/types/config.go index c97f7c36..5438653b 100644 --- a/pkg/types/config.go +++ b/pkg/types/config.go @@ -114,50 +114,49 @@ var DefaultConfig = Configuration{ } func (c Configuration) Validate() error { - if !(c.SelfID > 0) { + if c.SelfID == 0 { return errors.Errorf("SelfID is lower than or equal to zero") } - - if !(c.RequestBatchMaxCount > 0) { + if c.RequestBatchMaxCount == 0 { return errors.Errorf("RequestBatchMaxCount should be greater than zero") } - if !(c.RequestBatchMaxBytes > 0) { + if c.RequestBatchMaxBytes == 0 { return errors.Errorf("RequestBatchMaxBytes should be greater than zero") } - if !(c.RequestBatchMaxInterval > 0) { + if c.RequestBatchMaxInterval <= 0 { return errors.Errorf("RequestBatchMaxInterval should be greater than zero") } - if !(c.IncomingMessageBufferSize > 0) { + if c.IncomingMessageBufferSize == 0 { return errors.Errorf("IncomingMessageBufferSize should be greater than zero") } - if !(c.RequestPoolSize > 0) { + if c.RequestPoolSize == 0 { return errors.Errorf("RequestPoolSize should be greater than zero") } - if !(c.RequestForwardTimeout > 0) { + if c.RequestForwardTimeout <= 0 { return errors.Errorf("RequestForwardTimeout should be greater than zero") } - if !(c.RequestComplainTimeout > 0) { + if c.RequestComplainTimeout <= 0 { return errors.Errorf("RequestComplainTimeout should be greater than zero") } - if !(c.RequestAutoRemoveTimeout > 0) { + if c.RequestAutoRemoveTimeout <= 0 { return errors.Errorf("RequestAutoRemoveTimeout should be greater than zero") } - if !(c.ViewChangeResendInterval > 0) { + if c.ViewChangeResendInterval <= 0 { return errors.Errorf("ViewChangeResendInterval should be greater than zero") } - if !(c.ViewChangeTimeout > 0) { + if c.ViewChangeTimeout <= 0 { return errors.Errorf("ViewChangeTimeout should be greater than zero") } - if !(c.LeaderHeartbeatTimeout > 0) { + if c.LeaderHeartbeatTimeout <= 0 { return errors.Errorf("LeaderHeartbeatTimeout should be greater than zero") } - if !(c.LeaderHeartbeatCount > 0) { + if c.LeaderHeartbeatCount == 0 { return errors.Errorf("LeaderHeartbeatCount should be greater than zero") } - if !(c.NumOfTicksBehindBeforeSyncing > 0) { + if c.NumOfTicksBehindBeforeSyncing == 0 { return errors.Errorf("NumOfTicksBehindBeforeSyncing should be greater than zero") } - if !(c.CollectTimeout > 0) { + if c.CollectTimeout <= 0 { return errors.Errorf("CollectTimeout should be greater than zero") } if c.RequestBatchMaxCount > c.RequestBatchMaxBytes { @@ -176,11 +175,11 @@ func (c Configuration) Validate() error { return errors.Errorf("DecisionsPerLeader should be greater than zero when leader rotation is active") } - if !(c.RequestMaxBytes > 0) { + if c.RequestMaxBytes == 0 { return errors.Errorf("RequestMaxBytes should be greater than zero") } - if !(c.RequestPoolSubmitTimeout > 0) { + if c.RequestPoolSubmitTimeout <= 0 { return errors.Errorf("RequestPoolSubmitTimeout should be greater than zero") }