client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package client is one client of a lock server: it asks for the lock, holds it once granted, and releases it. New can also build a client that is not idempotent under duplicated grants, for the acceptance tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actions

type Actions uint64

Actions is the set of things the holder must do after a transition, one bit each. The holder performs them in declaration order. The zero value is the empty set.

const (
	ActRequest Actions = 1 << iota
	ActRelease
	ActModeChanged
)

Actions values.

type Event

type Event uint8

Event is an input to Fire.

const (
	EvWant Event
	EvGrant
	EvDone
)

Event values.

type Machine

type Machine struct {
	// contains filtered or unexported fields
}

Machine is one client. Build it with New and change it only with Fire.

func New

func New(acceptStale bool) Machine

New returns a client in Idle. With acceptStale it is the seeded bug: it takes any grant, even when not waiting, so a duplicated grant makes it hold the lock again.

func (Machine) Fire

func (m Machine) Fire(e Event) (Machine, Actions, fsm.Outcome)

Fire applies e and returns the next machine, its actions and what happened.

func (Machine) Mode

func (m Machine) Mode() Mode

Mode derives the mode from the state.

func (Machine) State

func (m Machine) State() State

State returns the control state.

type Mode

type Mode uint8

Mode is derived from State. A client has one mode.

const (
	Normal Mode
)

Mode values.

func (Mode) String

func (m Mode) String() string

type State

type State uint8

State is the client's control state.

const (
	Idle State
	Waiting
	Holding
)

State values.

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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