hardware

package
v0.0.0-...-bb322fc Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Machine

type Machine interface {
	// The Machine will be locked whenever vending, exposed for when actions need to wait for the current vend.
	sync.Locker
	// Setup configures the machine to do things, and sets up a handler to stop doing things when the context closes.
	// If it returns an error all following vends will fail.
	Setup(ctx context.Context) error
	// Vend requests the hardware to vend an item. Blocks until done.
	// If a second request comes in while the first is processing that will block too.
	// Vend respects context deadlines / cancels before the physical vend action starts,
	//  but will not abort once in progress to avoid becoming physically out of sync.
	Vend(ctx context.Context, location uint8) vend.Result
}

Machine is a cross-platform way of using the vending machine

func NewMachine

func NewMachine(log *logging.Logger) Machine

NewMachine returns this platform's vending options

type MockHardware

type MockHardware struct {
	sync.Mutex
	SetupError  error
	VendResult  vend.Result
	VendRequest uint8
}

MockHardware is a mock for the Hardware type

func (*MockHardware) Setup

func (hw *MockHardware) Setup(ctx context.Context) error

func (*MockHardware) Vend

func (hw *MockHardware) Vend(ctx context.Context, location uint8) vend.Result

Jump to

Keyboard shortcuts

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