github.com/searKing/golang/go@v1.2.117/sync/leaderelection/dummy_lock.go (about) 1 // Copyright 2021 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package leaderelection 6 7 import "context" 8 9 // NewDummyLock returns a locker which returns follower 10 func NewDummyLock(identity string) *dummyLock { 11 return &dummyLock{identity: identity} 12 } 13 14 type dummyLock struct { 15 identity string 16 } 17 18 // Get is a dummy to allow us to have a dummyLock for testing. 19 func (fl *dummyLock) Get(ctx context.Context) (ler *Record, rawRecord []byte, err error) { 20 return nil, nil, nil 21 } 22 23 // Create is a dummy to allow us to have a dummyLock for testing. 24 func (fl *dummyLock) Create(ctx context.Context, ler Record) error { 25 return nil 26 } 27 28 // Update is a dummy to allow us to have a dummyLock for testing. 29 func (fl *dummyLock) Update(ctx context.Context, ler Record) error { 30 return nil 31 } 32 33 // RecordEvent is a dummy to allow us to have a dummyLock for testing. 34 func (fl *dummyLock) RecordEvent(name, event string) {} 35 36 // Identity is a dummy to allow us to have a dummyLock for testing. 37 func (fl *dummyLock) Identity() string { 38 return fl.identity 39 } 40 41 // Describe is a dummy to allow us to have a dummyLock for testing. 42 func (fl *dummyLock) Describe() string { 43 return "Dummy implementation of lock for testing" 44 }