Skip to content

Commit

Permalink
update file trigger and resolve licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
Assassin718 committed Oct 25, 2024
1 parent 9403887 commit 333d24f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
10 changes: 10 additions & 0 deletions licenses/LICENSE_OF_ILOGTAIL_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ When distributed in a binary form, iLogtail may contain portions of the followin
- [github.com/golang/groupcache](https://pkg.go.dev/github.com/golang/groupcache?tab=licenses)
- [sigs.k8s.io/controller-runtime](https://pkg.go.dev/sigs.k8s.io/controller-runtime?tab=licenses)
- [github.com/iLogtail/VictoriaMetrics fork from github.com/VictoriaMetrics/VictoriaMetrics](http://github.com/iLogtail/VictoriaMetrics) based on Apache-2.0
- [cloud.google.com/go/compute/metadata](https://pkg.go.dev/cloud.google.com/go/compute/metadata?tab=licenses)
- [github.com/VictoriaMetrics/metricsql](https://pkg.go.dev/github.com/VictoriaMetrics/metricsql?tab=licenses)

## BSD licenses

Expand Down Expand Up @@ -229,6 +231,13 @@ When distributed in a binary form, iLogtail may contain portions of the followin
- [github.com/stretchr/testify](https://pkg.go.dev/github.com/stretchr/testify?tab=licenses)
- [go.uber.org/goleak](https://pkg.go.dev/go.uber.org/goleak?tab=licenses)
- [github.com/influxdata/telegraf](https://pkg.go.dev/github.com/influxdata/telegraf?tab=licenses)
- [github.com/valyala/fastjson](https://pkg.go.dev/github.com/valyala/fastjson?tab=licenses)
- [github.com/valyala/fastrand](https://pkg.go.dev/github.com/valyala/fastrand?tab=licenses)
- [github.com/valyala/fasttemplate](https://pkg.go.dev/github.com/valyala/fasttemplate?tab=licenses)
- [github.com/valyala/gozstd](https://pkg.go.dev/github.com/valyala/gozstd?tab=licenses)
- [github.com/valyala/histogram](https://pkg.go.dev/github.com/valyala/histogram?tab=licenses)
- [github.com/valyala/quicktemplate](https://pkg.go.dev/github.com/valyala/quicktemplate?tab=licenses)
- [github.com/VictoriaMetrics/fasthttp](https://pkg.go.dev/github.com/VictoriaMetrics/fasthttp?tab=licenses)

## ISC licenses

Expand All @@ -254,3 +263,4 @@ When distributed in a binary form, iLogtail may contain portions of the followin
- [github.com/iLogtail/pyroscope-lib fork from github.com/pyroscope-io/pyroscope](http://github.com/iLogtail/pyroscope-lib) based on Apache-2.0
- [github.com/iLogtail/gonvml fork from github.com/mindprince/gonvml](https://github.com/iLogtail/gonvml) based on Apache-2.0
- [github.com/iLogtail/handy fork from github.com/streadway/handy](http://github.com/iLogtail/handy) based on BSD-2-Clause
- [github.com/iLogtail/metrics fork from github.com/VictoriaMetrics/metrics](http://github.com/iLogtail/metrics) based on MIT
19 changes: 8 additions & 11 deletions test/engine/trigger/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"path/filepath"
"time"

"golang.org/x/time/rate"

"github.com/alibaba/ilogtail/test/config"
)

Expand All @@ -24,30 +22,29 @@ func GenerateRandomNginxLogToFile(ctx context.Context, speed, totalTime int, pat
file, _ := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600) // #nosec G304

rand.Seed(time.Now().UnixNano())
maxLogLen := 1024
nginxLog := genNginxLog()

limiter := rate.NewLimiter(rate.Limit(speed*1024*1024), maxLogLen)

timeout := time.After(time.Minute * time.Duration(totalTime))

timePre := time.Now()
var bytes int64 = 0

for {
select {
// context is done
case <-ctx.Done():
// clear file
_ = file.Close()
return ctx, nil
// all time is done
case <-timeout:
// clear file
_ = file.Close()
return ctx, nil
default:
if limiter.AllowN(time.Now(), len(nginxLog)) {
timeNow := time.Now()
bytes += int64(timeNow.Sub(timePre).Microseconds() * int64(speed))
for bytes > int64(len(nginxLog)) {
_, _ = file.WriteString(nginxLog + "\n") // #nosec G307
bytes -= int64(len(nginxLog))
nginxLog = genNginxLog()
}
timePre = timeNow
}
}
}
Expand Down

0 comments on commit 333d24f

Please sign in to comment.