package stub

import "github.com/google/trillian/util/election/stub"

Package stub contains a MasterElection implementation for testing.

Index

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

func ErrAll(err error) *Errors

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

election.go

Version
v1.2.1
Published
Aug 16, 2018
Platform
js/wasm
Imports
5 packages
Last checked
6 hours ago

Tools for package owners.