package stub
import "github.com/google/trillian/util/election/stub"
Package stub contains a MasterElection implementation for testing.
Index ¶
- type Errors
- type MasterElection
- func NewMasterElection(isMaster bool, errs *Errors) *MasterElection
- func (e *MasterElection) Close(context.Context) error
- func (e *MasterElection) GetCurrentMaster(context.Context) (string, error)
- func (e *MasterElection) IsMaster(context.Context) (bool, error)
- func (e *MasterElection) Resign(context.Context) error
- func (e *MasterElection) Start(context.Context) error
- func (e *MasterElection) Update(isMaster bool, errs *Errors)
- func (e *MasterElection) WaitForMastership(ctx context.Context) error
Types ¶
type Errors ¶
type Errors struct { Start error Wait error // WaitForMastership error. IsMaster error Resign error // ResignAndRestart error. Close error GetMaster error // GetCurrentMaster error. }
Errors contains errors to be returned by each of MasterElection methods.
func ErrAll ¶
ErrAll creates Errors containing the same err associated with each method.
type MasterElection ¶
type MasterElection struct {
// contains filtered or unexported fields
}
MasterElection implements election.MasterElection interface for testing.
func NewMasterElection ¶
func NewMasterElection(isMaster bool, errs *Errors) *MasterElection
NewMasterElection returns a new initialized MasterElection for testing.
func (*MasterElection) Close ¶
func (e *MasterElection) Close(context.Context) error
Close returns the stored error.
func (*MasterElection) GetCurrentMaster ¶
func (e *MasterElection) GetCurrentMaster(context.Context) (string, error)
GetCurrentMaster returns the current master which is *this* instance, or error if not currently the master.
func (*MasterElection) IsMaster ¶
func (e *MasterElection) IsMaster(context.Context) (bool, error)
IsMaster returns the stored mastership status and error.
func (*MasterElection) Resign ¶
func (e *MasterElection) Resign(context.Context) error
Resign returns the stored error and resets mastership status if the error is nil.
func (*MasterElection) Start ¶
func (e *MasterElection) Start(context.Context) error
Start returns the stored error for this call.
func (*MasterElection) Update ¶
func (e *MasterElection) Update(isMaster bool, errs *Errors)
Update changes mastership status and errors returned by interface calls.
func (*MasterElection) WaitForMastership ¶
func (e *MasterElection) WaitForMastership(ctx context.Context) error
WaitForMastership blocks until this instance is master, or an error is supplied, or context is done.
Source Files ¶
- Version
- v1.2.0
- Published
- Jun 22, 2018
- Platform
- js/wasm
- Imports
- 5 packages
- Last checked
- 22 seconds ago –
Tools for package owners.