Documentation
¶
Index ¶
- func ListMachines(db *gorm.DB) ([]*amhist.MachineRecord, error)
- func NewDb(name string, debug bool) (*gorm.DB, *sql.DB, error)
- type Config
- type Machine
- type MatcherFn
- type Memory
- func (m *Memory) Config() amhist.BaseConfig
- func (m *Memory) Dispose() error
- func (m *Memory) FindLatest(ctx context.Context, retTx bool, limit int, query amhist.Query) ([]*amhist.MemoryRecord, error)
- func (m *Memory) JoinState(query *gorm.DB, name string) *gorm.DB
- func (m *Memory) JoinTransition(query *gorm.DB) *gorm.DB
- func (m *Memory) Machine() am.Api
- func (m *Memory) MachineRecord() *amhist.MachineRecord
- func (m *Memory) Match(ctx context.Context, limit int, matcherFn MatcherFn) ([]*amhist.MemoryRecord, error)
- func (m *Memory) Sync() error
- type State
- type Tick
- type Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListMachines ¶
func ListMachines(db *gorm.DB) ([]*amhist.MachineRecord, error)
ListMachines returns a list of all machines in a database. TODO
Types ¶
type Config ¶
type Config struct {
amhist.BaseConfig
// amount of records to save in bulk (default: 1000)
QueueBatch int32
// amount of goroutines doing bulk saving (default: 10)
SavePool int
}
type Machine ¶
type Machine struct {
ID uint32 `gorm:"primaryKey"`
Times []Time
States []State
MachId string `gorm:"column:mach_id;index:mach_id"`
StateNames datatypes.JSON
Schema datatypes.JSON
// first time the machine has been tracked
FirstTracking time.Time
// last time a tracking of this machine has started
LastTracking time.Time
// last time a sync has been performed
LastSync time.Time
// current machine start tick
MachTick uint32
// current (total) machine time
// TODO optimize: collect in a separate query
MTime datatypes.JSON
// sum of the current machine time
MTimeSum uint64
// next ID for time records
NextId uint64
// contains filtered or unexported fields
}
Machine is a SQL version of amhist.MachineRecord.
type Memory ¶
type Memory struct {
*amhist.BaseMemory
Db *gorm.DB
Cfg *Config
SavePending atomic.Int32
SaveInProgress atomic.Bool
GcInProgress atomic.Bool
Saved atomic.Uint64
// Value of Saved at the end of the last GC
SavedGc atomic.Uint64
// contains filtered or unexported fields
}
func (*Memory) Config ¶
func (m *Memory) Config() amhist.BaseConfig
Config is amhist.BaseMemory.Config.
func (*Memory) Dispose ¶
Dispose is amhist.BaseMemory.Dispose. TODO merge with ctx
func (*Memory) FindLatest ¶
func (m *Memory) FindLatest( ctx context.Context, retTx bool, limit int, query amhist.Query, ) ([]*amhist.MemoryRecord, error)
FindLatest is amhist.BaseMemory.FindLatest.
func (*Memory) MachineRecord ¶
func (m *Memory) MachineRecord() *amhist.MachineRecord
MachineRecord is amhist.BaseMemory.MachineRecord.
type Tick ¶
type Tick struct {
TimeID uint64 `gorm:"primaryKey;autoIncrement:false;index:activated"`
MachineID uint32 `gorm:"primaryKey;autoIncrement:false;index:activated"`
StateID uint `gorm:"primaryKey;autoIncrement:false;index:activated"`
State State
Tick uint64
// was the state activated in this transition?
Activated bool `gorm:"index:activated"`
// was the state deactivated in this transition?
Deactivated bool
// state is currently active
Active bool
}
type Time ¶
type Time struct {
ID uint64 `gorm:"primaryKey;autoIncrement:false"`
MachineID uint32 `gorm:"primaryKey"`
Ticks []Tick `gorm:"foreignKey:TimeID,MachineID;references:ID,MachineID"`
// MutType is a mutation type.
MutType am.MutationType
// MTimeSum is a machine time sum after this transition.
MTimeSum uint64
// MTimeSum is a machine time sum after this transition for tracked states
// only.
MTimeTrackedSum uint64
// MTimeDiffSum is a machine time difference for this transition.
MTimeDiffSum uint64
// MTimeDiffSum is a machine time difference for this transition for tracked
// states only.
MTimeTrackedDiffSum uint64
// MTimeRecordDiffSum is a machine time difference since the previous
// [amhist.TimeRecord].
MTimeRecordDiffSum uint64
// HTime is a human time in UTC.
HTime time.Time
// MTime is a machine time for tracked states after this mutation.
MTimeTracked datatypes.JSON
// MTimeTrackedDiff is a machine time diff compared to the previous mutation
// (not a record). TODO make optional? can be generated
MTimeTrackedDiff datatypes.JSON
// TODO MTimeTrackedDiffCompact arpc-like clock encoding
// MachTick is the machine tick at the time of this transition.
MachTick uint32
TxId string `gorm:"index:tx_id"`
TxSourceTx *string
TxSourceMach *string
TxIsAuto bool
TxIsAccepted bool
TxIsCheck bool
TxIsBroken bool
TxQueueLen uint16
TxQueuedAt *uint64
TxExecutedAt *uint64
TxCalled datatypes.JSON
TxArguments *datatypes.JSON
// contains filtered or unexported fields
}
Time is a SQL version of amhist.TimeRecord.
Click to show internal directories.
Click to hide internal directories.