history

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2023 License: AGPL-3.0, BSD-2-Clause, ISC Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AdminCommands = []string{
	"importTransactions",
	"addSlot",
	"deleteSlot",
}

AdminCommands represents commands used by the administrator Notes ... do we separate configuration from user commands in the transaction history (probably no, for testing reasons)

View Source
var UserCommands = []string{
	"cancelBooking",
	"collectBooking",
	"requestBooking",
	"swapBooking",
	"getBookings",
	"listBookings",
}

UserCommands represents commands that users will send to the system

Functions

This section is empty.

Types

type Action

type Action struct {
	IssuedAt time.Time
	Do       string
	When     interval.Interval
	Slot     string
	Booking  string
	User     string
}

Action represents a booking action, including the time it was taken so as to allow history-replay to rebuild the booking status based on a record of past actions. This may also help with testing?

type History

type History struct {
	Name    string
	Actions map[string]Action
}

func (*History) Add

func (h *History) Add(action Action)

func (*History) NewReplayAll

func (h *History) NewReplayAll() *Replay

NewReplayAll returns a pointer to a Replay object which holds a pointer to the history, to save copying it. Messages will be replayed until there are no more messages. Messages added to the history after creating the object but before the message preceding them has been replayed will be replayed too.

func (*History) NewReplayAllUntilNow

func (h *History) NewReplayAllUntilNow() *Replay

NewReplayAllUntilNow returns a pointer to a Replay object which holds a pointer to the history, to save copying it. All messages received up until the current time will be replayed

func (*History) NewReplayInterval

func (h *History) NewReplayInterval(from, to time.Time) *Replay

NewReplayInterval returns a pointer to a Replay object which holds a pointer to the history, to save copying it. All messages received within the interval from -> to will be replayed. Intervals are exclusive, due to the use of time.Before, and time.After.

func (*History) Replay

func (h *History) Replay()

how many replay pointers do we need?

type Replay

type Replay struct {
	Name string
}

func (*Replay) GetNext

func (r *Replay) GetNext() (*Action, error)

Jump to

Keyboard shortcuts

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