package gorm

Import Path
	/pkg/history/gorm (on go.dev)

Dependency Relation
	imports 22 packages, and imported by 0 packages

Involved Source Files gorm.go
Package-Level Type Names (total 7)
/* sort by: | */
BaseConfig amhist.BaseConfig Called is a list of mutation states (called ones) required to track a transition. See also CalledExclude. Optional. CalledExclude flips Called to be a blocklist. Changed is a list of transition states which had clock changes, required to track a transition. See also ChangedExclude. A state can be called, but not changed. Optional. ChangedExclude flips Changed to be a blocklist. BaseConfig.Log bool MaxRecords is the maximum number of records to keep in the history before a rotation begins. TODO StoreSchema keeps the latest machine schema and state names within [MachineRecord]. Useful for dynamic machines. StoreTransitions is a flag to store TransitionRecord, in addition to TimeRecord, for each tracked transition. TrackRejected is a flag to track rejected transitions. TrackedStates is a list of states to store clock values of. amount of records to save in bulk (default: 1000) amount of goroutines doing bulk saving (default: 10) func NewMemory(ctx context.Context, db *gorm.DB, mach am.Api, cfg Config, onErr func(err error)) (*Memory, error)
Machine is a SQL version of [amhist.MachineRecord]. first time the machine has been tracked ID uint32 last time a sync has been performed last time a tracking of this machine has started current (total) machine time TODO optimize: collect in a separate query sum of the current machine time MachId string current machine start tick next ID for time records Schema datatypes.JSON StateNames datatypes.JSON States []State Times []Time func GetMachine(db *gorm.DB, id string, inclStates bool) (*Machine, error)
func (*Memory).Match(ctx context.Context, limit int, matcherFn MatcherFn) ([]*amhist.MemoryRecord, error)
BaseMemory *amhist.BaseMemory BaseMemory.Ctx context.Context BaseMemory.Mach am.Api Cfg *Config Db *gorm.DB SaveInProgress atomic.Bool SavePending atomic.Int32 Saved atomic.Uint64 Value of Saved at the end of the last GC ActivatedBetween returns true if the state was activated within the passed human time range. ActiveBetween returns true if the state was activated all the time within the passed human time range. Config is [amhist.BaseMemory.Config]. ( Memory) Context() context.Context ( Memory) DeactivatedBetween(ctx context.Context, state string, start, end time.Time) bool Dispose is [amhist.BaseMemory.Dispose]. TODO merge with ctx FindLatest is [amhist.BaseMemory.FindLatest]. ( Memory) InactiveBetween(ctx context.Context, state string, start, end time.Time) bool Index returns the indexes of the given states in the history records, or -1 if the state is not being tracked. Index1 is [BaseMemory.Index] for a single state. IsTracked returns true if the given states are all being tracked by this memory instance. IsTracked1 is IsTracked for a single state. (*Memory) JoinState(query *gorm.DB, name string) *gorm.DB (*Memory) JoinTransition(query *gorm.DB) *gorm.DB Machine is [amhist.BaseMemory.Machine]. MachineRecord is [amhist.BaseMemory.MachineRecord]. Match returns the latest record that matches the given matcher function. Sync is [amhist.BaseMemory.Sync]. ( Memory) ToMachineRecord(format any) (*history.MachineRecord, error) ( Memory) ToMemoryRecord(format any) (*history.MemoryRecord, error) ( Memory) ToTimeRecord(format any) (*history.TimeRecord, error) ( Memory) ToTransitionRecord(format any) (*history.TransitionRecord, error) ( Memory) ValidateQuery(query history.Query) error *Memory : github.com/pancsta/asyncmachine-go/pkg/history.MemoryApi *Memory : github.com/polarsignals/frostdb.Sync func NewMemory(ctx context.Context, db *gorm.DB, mach am.Api, cfg Config, onErr func(err error)) (*Memory, error)
ID uint Index is the state index in the machine (not the tracked states index). MachineID string Name string
was the state activated in this transition? state is currently active was the state deactivated in this transition? MachineID uint32 State State StateID uint Tick uint64 TimeID uint64
Time is a SQL version of [amhist.TimeRecord]. HTime is a human time in UTC. ID uint64 MTimeDiffSum is a machine time difference for this transition. MTimeRecordDiffSum is a machine time difference since the previous [amhist.TimeRecord]. MTimeSum is a machine time sum after this transition. MTime is a machine time for tracked states after this mutation. MTimeTrackedDiff is a machine time diff compared to the previous mutation (not a record). TODO make optional? can be generated MTimeDiffSum is a machine time difference for this transition for tracked states only. MTimeSum is a machine time sum after this transition for tracked states only. TODO MTimeTrackedDiffCompact arpc-like clock encoding MachTick is the machine tick at the time of this transition. MachineID uint32 MutType is a mutation type. Ticks []Tick TxArguments *datatypes.JSON TxCalled datatypes.JSON TxExecutedAt *uint64 TxId string TxIsAccepted bool TxIsAuto bool TxIsBroken bool TxIsCheck bool TxQueueLen uint16 TxQueuedAt *uint64 TxSourceMach *string TxSourceTx *string
Package-Level Functions (total 4)
GetMachine returns a machine record for a given machine id.
ListMachines returns a list of all machines in a database. TODO
NewDb returns a new SQLite DB for GORM.
func NewMemory(ctx context.Context, db *gorm.DB, mach am.Api, cfg Config, onErr func(err error)) (*Memory, error)