package history

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

Dependency Relation
	imports 8 packages, and imported by 3 packages

Involved Source Files Package history provides machine history tracking and traversal using the process' memory and structs.
Package-Level Type Names (total 14)
/* sort by: | */
Backend enumerates all available asyncmachine history backends. Value string var BackendBbolt var BackendMemory var BackendSqlite
BaseConfig describes the tracking configuration - conditions, list of tracked states and data expiration TTLs. 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. 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. func (*BaseMemory).Config() BaseConfig func (*Memory).Config() BaseConfig func MemoryApi.Config() BaseConfig func github.com/pancsta/asyncmachine-go/pkg/history/bbolt.(*Memory).Config() BaseConfig func github.com/pancsta/asyncmachine-go/pkg/history/gorm.(*Memory).Config() BaseConfig func NewBaseMemory(ctx context.Context, mach am.Api, config BaseConfig, memImpl MemoryApi) *BaseMemory func NewMemory(ctx context.Context, machRecord *MachineRecord, mach am.Api, config BaseConfig, onErr func(err error)) (*Memory, error)
BaseMemory are the common methods for all memory implementations, operating on common models, like [TimeRecord] or [Query]. read-only config for this history Ctx context.Context Mach am.Api 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. (*BaseMemory) Config() BaseConfig (*BaseMemory) Context() context.Context (*BaseMemory) DeactivatedBetween(ctx context.Context, state string, start, end time.Time) bool (*BaseMemory) Dispose() error FindLatest returns the latest records matching the given conditions, in order from the newest to the oldest. If the limit is 0, all records are returned. (*BaseMemory) 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. (*BaseMemory) Machine() am.Api MachineRecord returns a copy of the history record for the tracked machine. (*BaseMemory) Sync() error (*BaseMemory) ToMachineRecord(format any) (*MachineRecord, error) (*BaseMemory) ToMemoryRecord(format any) (*MemoryRecord, error) (*BaseMemory) ToTimeRecord(format any) (*TimeRecord, error) (*BaseMemory) ToTransitionRecord(format any) (*TransitionRecord, error) (*BaseMemory) ValidateQuery(query Query) error *BaseMemory : MemoryApi *BaseMemory : github.com/polarsignals/frostdb.Sync func NewBaseMemory(ctx context.Context, mach am.Api, config BaseConfig, memImpl MemoryApi) *BaseMemory
HTime is the human time for a mutation to match. MTime is the machine time for a mutation to match. MTimeDiff is a machine time difference for this transition, compared to the previous transition. MTimeRecordDiff is a machine time difference since the previous [TimeRecord]. MTimeStates is a set of states for MTime. MTimeSum is a machine time sum after this transition. MTimeDiff 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. MachTick is the machine tick at the time of this transition.
ConditionTx represents a condition for a single transition. Requires [BaseConfig.StoreTransitions] to be true. Called is a set of states that were called in the mutation. ExecutedAt uint64 IsAccepted bool IsAuto bool IsBroken bool IsCheck bool Query Query Activated is a set of states that were activated during the transition. Active is a set of states that were active AFTER the mutation Deactivated is a set of states that were deactivated during the transition. End is the end of a scalar time condition and requires an equivalent in [Query.Start]. Inactive is a set of states that were inactive AFTER the mutation Start is the beginning of a scalar time condition and requires an equivalent in [Query.End]. QueueLen uint16 QueuedAt uint64 SourceMach string SourceTx string
Config for the in-process memory.
first time the machine has been tracked last time a sync has been performed last time a tracking of this machine has started current (total) machine time sum of the current machine time ID of the tracked machine current machine start tick next ID for time records Schema am.Schema StateNames am.S func (*BaseMemory).MachineRecord() *MachineRecord func (*BaseMemory).ToMachineRecord(format any) (*MachineRecord, error) func (*Memory).MachineRecord() *MachineRecord func MemoryApi.MachineRecord() *MachineRecord func MemoryApi.ToMachineRecord(format any) (*MachineRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/bbolt.GetMachine(db *bbolt.DB, id string) (*MachineRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/bbolt.ListMachines(db *bbolt.DB) ([]*MachineRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/bbolt.(*Memory).MachineRecord() *MachineRecord func github.com/pancsta/asyncmachine-go/pkg/history/gorm.ListMachines(db *gorm.DB) ([]*MachineRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/gorm.(*Memory).MachineRecord() *MachineRecord func NewMemory(ctx context.Context, machRecord *MachineRecord, mach am.Api, config BaseConfig, onErr func(err error)) (*Memory, error)
func (*Memory).Match(ctx context.Context, matcherFn MatcherFn) ([]*MemoryRecord, error)
BaseMemory *BaseMemory read-only config for this history BaseMemory.Ctx context.Context BaseMemory.Mach am.Api 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. (*Memory) Config() BaseConfig ( Memory) Context() context.Context ( Memory) DeactivatedBetween(ctx context.Context, state string, start, end time.Time) bool (*Memory) Dispose() error (*Memory) Export() []*MemoryRecord FindLatest is [BaseMemory.FindLatest] for in-process memory. ( 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) Machine() am.Api (*Memory) MachineRecord() *MachineRecord Match returns the first record that matches the MatcherFn. ( Memory) Sync() error ( Memory) ToMachineRecord(format any) (*MachineRecord, error) ( Memory) ToMemoryRecord(format any) (*MemoryRecord, error) ( Memory) ToTimeRecord(format any) (*TimeRecord, error) ( Memory) ToTransitionRecord(format any) (*TransitionRecord, error) ( Memory) ValidateQuery(query Query) error *Memory : MemoryApi Memory : github.com/polarsignals/frostdb.Sync func NewMemory(ctx context.Context, machRecord *MachineRecord, mach am.Api, config BaseConfig, onErr func(err error)) (*Memory, error)
ActivatedBetween returns true if the state become active withing the passed conditions. ActiveBetween returns true if the state was active at least once within the passed conditions. Always true is ActivatedBetween is true. ( MemoryApi) Config() BaseConfig ( MemoryApi) Context() context.Context ( MemoryApi) DeactivatedBetween(ctx context.Context, state string, start, end time.Time) bool ( MemoryApi) Dispose() error ( MemoryApi) FindLatest(ctx context.Context, retTx bool, limit int, query Query) ([]*MemoryRecord, error) ( MemoryApi) InactiveBetween(ctx context.Context, state string, start, end time.Time) bool ( MemoryApi) Index(states am.S) []int ( MemoryApi) Index1(state string) int ( MemoryApi) IsTracked(states am.S) bool ( MemoryApi) IsTracked1(state string) bool ( MemoryApi) Machine() am.Api ( MemoryApi) MachineRecord() *MachineRecord Sync synchronizes the batch buffer with the underlying backend, making those new records appear in queries. Doesn't guarantee persistence. Useful when queries very fresh records. ( MemoryApi) ToMachineRecord(format any) (*MachineRecord, error) ( MemoryApi) ToTimeRecord(format any) (*TimeRecord, error) ( MemoryApi) ToTransitionRecord(format any) (*TransitionRecord, error) *BaseMemory *Memory *github.com/pancsta/asyncmachine-go/pkg/history/bbolt.Memory *github.com/pancsta/asyncmachine-go/pkg/history/gorm.Memory MemoryApi : github.com/polarsignals/frostdb.Sync func NewBaseMemory(ctx context.Context, mach am.Api, config BaseConfig, memImpl MemoryApi) *BaseMemory func github.com/pancsta/asyncmachine-go/pkg/history/test.AssertBasics(t *testing.T, mem MemoryApi, rounds int) func github.com/pancsta/asyncmachine-go/pkg/history/test.AssertGc(t *testing.T, mem MemoryApi, rounds int)
Time *TimeRecord Transition *TransitionRecord func (*BaseMemory).FindLatest(ctx context.Context, retTx bool, limit int, query Query) ([]*MemoryRecord, error) func (*BaseMemory).ToMemoryRecord(format any) (*MemoryRecord, error) func (*Memory).Export() []*MemoryRecord func (*Memory).FindLatest(ctx context.Context, _ bool, limit int, query Query) ([]*MemoryRecord, error) func (*Memory).Match(ctx context.Context, matcherFn MatcherFn) ([]*MemoryRecord, error) func MemoryApi.FindLatest(ctx context.Context, retTx bool, limit int, query Query) ([]*MemoryRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/bbolt.(*Memory).FindLatest(ctx context.Context, retTx bool, limit int, query Query) ([]*MemoryRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/bbolt.(*Memory).Match(ctx context.Context, matcherFn bbolt.MatcherFn) ([]*MemoryRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/gorm.(*Memory).FindLatest(ctx context.Context, retTx bool, limit int, query Query) ([]*MemoryRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/gorm.(*Memory).Match(ctx context.Context, limit int, matcherFn gorm.MatcherFn) ([]*MemoryRecord, error)
Query represents various conditions for a single mutation. All are optional, but at least one must be set. Activated is a set of states that were activated during the transition. Active is a set of states that were active AFTER the mutation Deactivated is a set of states that were deactivated during the transition. End is the end of a scalar time condition and requires an equivalent in [Query.Start]. Inactive is a set of states that were inactive AFTER the mutation Start is the beginning of a scalar time condition and requires an equivalent in [Query.End]. func (*BaseMemory).FindLatest(ctx context.Context, retTx bool, limit int, query Query) ([]*MemoryRecord, error) func (*BaseMemory).ValidateQuery(query Query) error func (*Memory).FindLatest(ctx context.Context, _ bool, limit int, query Query) ([]*MemoryRecord, error) func MemoryApi.FindLatest(ctx context.Context, retTx bool, limit int, query Query) ([]*MemoryRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/bbolt.(*Memory).FindLatest(ctx context.Context, retTx bool, limit int, query Query) ([]*MemoryRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/gorm.(*Memory).FindLatest(ctx context.Context, retTx bool, limit int, query Query) ([]*MemoryRecord, error)
HTime is a human time in UTC. MTimeDiffSum is a machine time difference for this transition. MTimeRecordDiffSum is a machine time difference since the previous [TimeRecord]. MTimeSum is a machine time sum after this transition. MTime is a machine time after this mutation. MTimeTrackedDiff is a machine time diff compared to the previous mutation (not a record). 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. MachTick is the machine tick at the time of this transition. MutType is a mutation type. func (*BaseMemory).ToTimeRecord(format any) (*TimeRecord, error) func MemoryApi.ToTimeRecord(format any) (*TimeRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/bbolt.DecTimeRecord(machId string, id uint64, v []byte, tryJson bool) (*TimeRecord, error)
Arguments map[string]string extra ExecutedAt uint64 IsAccepted bool IsAuto bool IsBroken bool IsCheck bool QueueLen uint16 QueuedAt uint64 SourceMach string SourceTx string TimeRecordId uint64 TransitionId string func (*BaseMemory).ToTransitionRecord(format any) (*TransitionRecord, error) func MemoryApi.ToTransitionRecord(format any) (*TransitionRecord, error) func github.com/pancsta/asyncmachine-go/pkg/history/bbolt.DecTransitionRecord(machId string, id uint64, v []byte, tryJson bool) (*TransitionRecord, error)
Package-Level Functions (total 2)
func NewBaseMemory(ctx context.Context, mach am.Api, config BaseConfig, memImpl MemoryApi) *BaseMemory
NewMemory returns a new memory instance that tracks the given machine according to the given tracking configuration. All states are tracked by default, which often is not desired. Keeps 1000 records by default.
Package-Level Variables (total 7)
TODO bind ErrConfig