mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-21 04:57:18 +02:00
core/config: refactor file watcher (#4702)
* core/config: refactor file watcher * add comments * updates * only use the polling watcher * fix test * fix test * try to fix test again * remove batching * dont rely on file modification timestamp * remove benchmark * try fix again
This commit is contained in:
parent
77bb203276
commit
2771a5ae87
6 changed files with 170 additions and 139 deletions
|
@ -16,12 +16,12 @@ func TestFileWatcherSource(t *testing.T) {
|
|||
|
||||
tmpdir := t.TempDir()
|
||||
|
||||
err := os.WriteFile(filepath.Join(tmpdir, "example.txt"), []byte{1, 2, 3, 4}, 0o600)
|
||||
err := os.WriteFile(filepath.Join(tmpdir, "example.txt"), []byte{1}, 0o600)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
err = os.WriteFile(filepath.Join(tmpdir, "kubernetes-example.txt"), []byte{1, 2, 3, 4}, 0o600)
|
||||
err = os.WriteFile(filepath.Join(tmpdir, "kubernetes-example.txt"), []byte{2}, 0o600)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ func TestFileWatcherSource(t *testing.T) {
|
|||
},
|
||||
})
|
||||
|
||||
src := NewFileWatcherSource(ssrc)
|
||||
src := NewFileWatcherSource(ctx, ssrc)
|
||||
var closeOnce sync.Once
|
||||
ch := make(chan struct{})
|
||||
src.OnConfigChange(context.Background(), func(ctx context.Context, cfg *Config) {
|
||||
|
@ -44,7 +44,7 @@ func TestFileWatcherSource(t *testing.T) {
|
|||
})
|
||||
})
|
||||
|
||||
err = os.WriteFile(filepath.Join(tmpdir, "example.txt"), []byte{5, 6, 7, 8}, 0o600)
|
||||
err = os.WriteFile(filepath.Join(tmpdir, "example.txt"), []byte{1, 2}, 0o600)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ func TestFileWatcherSource(t *testing.T) {
|
|||
t.Error("expected OnConfigChange to be fired after modifying a file")
|
||||
}
|
||||
|
||||
err = os.WriteFile(filepath.Join(tmpdir, "kubernetes-example.txt"), []byte{5, 6, 7, 8}, 0o600)
|
||||
err = os.WriteFile(filepath.Join(tmpdir, "kubernetes-example.txt"), []byte{2, 3}, 0o600)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue