mirror of
https://github.com/kemko/nomad.git
synced 2026-01-16 07:15:40 +03:00
refactor: context is first parameter
By convention, go functions take `context.Context` as the first argument.
This commit is contained in:
@@ -29,7 +29,7 @@ type VolumeUpdateBatcher struct {
|
||||
// NewVolumeUpdateBatcher returns an VolumeUpdateBatcher that uses the
|
||||
// passed raft endpoints to create the updates to volume claims, and
|
||||
// exits the batcher when the passed exit channel is closed.
|
||||
func NewVolumeUpdateBatcher(batchDuration time.Duration, raft VolumeRaftEndpoints, ctx context.Context) *VolumeUpdateBatcher {
|
||||
func NewVolumeUpdateBatcher(ctx context.Context, batchDuration time.Duration, raft VolumeRaftEndpoints) *VolumeUpdateBatcher {
|
||||
b := &VolumeUpdateBatcher{
|
||||
batchDuration: batchDuration,
|
||||
raft: raft,
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestVolumeWatch_Batcher(t *testing.T) {
|
||||
|
||||
srv := &MockBatchingRPCServer{}
|
||||
srv.state = state.TestStateStore(t)
|
||||
srv.volumeUpdateBatcher = NewVolumeUpdateBatcher(CrossVolumeUpdateBatchDuration, srv, ctx)
|
||||
srv.volumeUpdateBatcher = NewVolumeUpdateBatcher(ctx, CrossVolumeUpdateBatchDuration, srv)
|
||||
srv.nextCSIControllerDetachError = fmt.Errorf("some controller plugin error")
|
||||
|
||||
plugin := mock.CSIPlugin()
|
||||
|
||||
@@ -124,7 +124,7 @@ func (w *Watcher) flush(enabled bool) {
|
||||
w.ctx, w.exitFn = context.WithCancel(context.Background())
|
||||
|
||||
if enabled {
|
||||
w.volumeUpdateBatcher = NewVolumeUpdateBatcher(w.updateBatchDuration, w.raft, w.ctx)
|
||||
w.volumeUpdateBatcher = NewVolumeUpdateBatcher(w.ctx, w.updateBatchDuration, w.raft)
|
||||
} else {
|
||||
w.volumeUpdateBatcher = nil
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func TestVolumeWatch_StartStop(t *testing.T) {
|
||||
srv.state = state.TestStateStore(t)
|
||||
index := uint64(100)
|
||||
srv.volumeUpdateBatcher = NewVolumeUpdateBatcher(
|
||||
CrossVolumeUpdateBatchDuration, srv, ctx)
|
||||
ctx, CrossVolumeUpdateBatchDuration, srv)
|
||||
|
||||
watcher := NewVolumesWatcher(testlog.HCLogger(t),
|
||||
srv, srv,
|
||||
@@ -261,7 +261,7 @@ func TestVolumeWatch_RegisterDeregister(t *testing.T) {
|
||||
srv := &MockStatefulRPCServer{}
|
||||
srv.state = state.TestStateStore(t)
|
||||
srv.volumeUpdateBatcher = NewVolumeUpdateBatcher(
|
||||
CrossVolumeUpdateBatchDuration, srv, ctx)
|
||||
ctx, CrossVolumeUpdateBatchDuration, srv)
|
||||
|
||||
index := uint64(100)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user