Skip to content

Commit

Permalink
minor changes in clickhouse
Browse files Browse the repository at this point in the history
  • Loading branch information
mosajjal committed Jan 28, 2023
1 parent f3bff1e commit 6ba1a24
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ docker-compose.yml
.TODO.md

dist/
cmd/dnsmonster/dnsmonster
Binary file removed cmd/dnsmonster/dnsmonster
Binary file not shown.
6 changes: 1 addition & 5 deletions internal/output/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ func (chConfig clickhouseConfig) clickhouseOutputWorker(ctx context.Context) err

c := uint(0)

now := time.Now()

ticker := time.NewTicker(time.Second * 5)
div := 0

Expand Down Expand Up @@ -199,7 +197,7 @@ func (chConfig clickhouseConfig) clickhouseOutputWorker(ctx context.Context) err
}
err := batch.Append(
data.Timestamp,
now,
time.Now(),
util.GeneralFlags.ServerName,
data.IPVersion,
data.SrcIP.To16(),
Expand All @@ -221,7 +219,6 @@ func (chConfig clickhouseConfig) clickhouseOutputWorker(ctx context.Context) err
clickhouseFailed.Inc(1)
}
if int(c%chConfig.ClickhouseBatchSize) == div {
now = time.Now()
err = batch.Send()
if err != nil {
log.Warnf("Error while executing batch: %v", err)
Expand All @@ -232,7 +229,6 @@ func (chConfig clickhouseConfig) clickhouseOutputWorker(ctx context.Context) err
}
}
case <-ticker.C:
now = time.Now()
err := batch.Send()
if err != nil {
log.Warnf("Error while executing batch: %v", err)
Expand Down

0 comments on commit 6ba1a24

Please sign in to comment.