Skip to content

Commit

Permalink
rename config option
Browse files Browse the repository at this point in the history
  • Loading branch information
wildum committed May 7, 2024
1 parent 585bf5b commit ddd8332
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions internal/component/loki/source/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ func (c *Component) getManagerOptions(args Arguments) (*options, error) {
}

return &options{
client: client,
handler: loki.NewEntryHandler(c.handler.Chan(), func() {}),
positions: c.posFile,
taskRestartInterval: 5 * time.Second,
client: client,
handler: loki.NewEntryHandler(c.handler.Chan(), func() {}),
positions: c.posFile,
targetRestartInterval: 5 * time.Second,
}, nil
}

Expand Down
10 changes: 5 additions & 5 deletions internal/component/loki/source/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/stretchr/testify/require"
)

const taskRestartInterval = 20 * time.Millisecond
const targetRestartInterval = 20 * time.Millisecond

func Test(t *testing.T) {
// Use host that works on all platforms (including Windows).
Expand Down Expand Up @@ -110,9 +110,9 @@ func TestRestart(t *testing.T) {

// Stops the container.
runningState = false
time.Sleep(taskRestartInterval + 10*time.Millisecond) // Sleep for a duration greater than taskRestartInterval to make sure it stops sending log lines.
time.Sleep(targetRestartInterval + 10*time.Millisecond) // Sleep for a duration greater than targetRestartInterval to make sure it stops sending log lines.
entryHandler.Clear()
time.Sleep(taskRestartInterval + 10*time.Millisecond)
time.Sleep(targetRestartInterval + 10*time.Millisecond)
assert.Empty(t, entryHandler.Received()) // No log lines because the container was not running.

// Restart the container and expect log lines.
Expand Down Expand Up @@ -149,8 +149,8 @@ func setupTailer(t *testing.T, client clientMock) (tailer *tailer, entryHandler
require.NoError(t, err)
tailerTask := &tailerTask{
options: &options{
client: client,
taskRestartInterval: taskRestartInterval,
client: client,
targetRestartInterval: targetRestartInterval,
},
target: tgt,
}
Expand Down
6 changes: 3 additions & 3 deletions internal/component/loki/source/docker/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ type options struct {
// positions interface so tailers can save/restore offsets in log files.
positions positions.Positions

// taskRestartInterval to restart task that has stopped running.
taskRestartInterval time.Duration
// targetRestartInterval to restart task that has stopped running.
targetRestartInterval time.Duration
}

// tailerTask is the payload used to create tailers. It implements runner.Task.
Expand Down Expand Up @@ -98,7 +98,7 @@ func newTailer(l log.Logger, task *tailerTask) *tailer {
}

func (t *tailer) Run(ctx context.Context) {
ticker := time.NewTicker(t.opts.taskRestartInterval)
ticker := time.NewTicker(t.opts.targetRestartInterval)
tickerC := ticker.C

for {
Expand Down

0 comments on commit ddd8332

Please sign in to comment.