Documentation
¶
Overview ¶
Package differ defines typed differences and audit records for scoped handler capabilities.
Index ¶
Constants ¶
View Source
const ( //ChangeTypeCreate defines create change type ChangeTypeCreate = ChangeType("create") //ChangeTypeUpdate defines update change type ChangeTypeUpdate = ChangeType("update") //ChangeTypeDelete defines delete change type ChangeTypeDelete = ChangeType("delete") )
View Source
const ( //PathKindRoot defines root path kind PathKindRoot = PathKind(iota) //PathKinField defines field path kind PathKinField //PathKindKey defines key path kind PathKindKey //PathKindIndex defines index path kind PathKindIndex )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
Type ChangeType
Path *Path
From interface{}
To interface{}
Error string
}
Change represents a change
type ChangeLog ¶
type ChangeLog struct {
Changes []*Change
}
ChangeLog represents a change log
func (*ChangeLog) ToChangeRecords ¶
func (l *ChangeLog) ToChangeRecords(options ...LogOption) []*ChangeRecord
ToChangeRecords converts changeLog to change records
type ChangeRecord ¶
type ChangeRecord struct {
Source string `json:",omitempty"`
SourceID interface{} `json:",omitempty"`
UserID interface{} `json:",omitempty"`
Path string
Change string
From interface{} `json:",omitempty"`
To interface{} `json:",omitempty"`
Error string `json:",omitempty"`
}
ChangeRecord defines a change record
type Differ ¶
type Differ interface {
Diff(ctx context.Context, from, to any, options ...Option) (*ChangeLog, error)
}
Differ compares values without mutating them. Comparison failures are explicit; native comparison errors are returned and retained in ChangeLog.
type LogOption ¶
type LogOption func(l *logOptions)
func WithSource ¶
func WithSourceID ¶
func WithSourceID(id interface{}) LogOption
func WithUserID ¶
func WithUserID(userID interface{}) LogOption
Click to show internal directories.
Click to hide internal directories.