Help us shape the future of Go! Take the 2026 Go Developer Survey

stub

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package stub contains a MasterElection implementation for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL