From 5060857c90e84a0d0849ab90a7e35e9f816b99cd Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Mon, 23 Jun 2014 09:46:01 -0500 Subject: [PATCH] moved cass batch window settings to config file --- index/storage_cass.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/index/storage_cass.go b/index/storage_cass.go index 6733fe832..9ceeb6c7b 100644 --- a/index/storage_cass.go +++ b/index/storage_cass.go @@ -13,11 +13,13 @@ import ( ) type CassandraStorage struct { - db *gocql.Session - batch *gocql.Batch - stmt string - batch_time time.Time - batch_counter int + db *gocql.Session + batch *gocql.Batch + stmt string + batch_time time.Time + batch_counter int + cass_time_window_secs float64 + cass_flush_size int } var cluster *gocql.ClusterConfig @@ -53,6 +55,8 @@ func NewCassStorage() Storage { obj.batch = nil obj.batch_time = time.Now() obj.batch_counter = 0 + obj.cass_time_window_secs = float64(config.GetIntDefault("cassandra_time_window_secs", 15)) + obj.cass_flush_size = config.GetIntDefault("cassandra_max_size_batch", 300) return obj } @@ -120,9 +124,9 @@ func (self *CassandraStorage) EndBatch() { start := time.Now() if self.batch != nil { last := time.Since(self.batch_time) - if last.Seconds() > 15 { + if last.Seconds() > self.cass_time_window_secs { self.FlushBatch() - } else if self.batch_counter > 300 { + } else if self.batch_counter > self.cass_flush_size { self.FlushBatch() } } else {