refactor: context is first parameter

By convention, go functions take `context.Context` as the first
argument.
This commit is contained in:
Mahmood Ali
2020-05-26 09:24:50 -04:00
parent ada9a6a844
commit 2bdbed0974
4 changed files with 5 additions and 5 deletions

View File

@@ -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,

View File

@@ -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()

View File

@@ -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
}

View File

@@ -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)