Documentation ¶
Index ¶
- func Expirable(ctx context.Context) bool
- func WithExpirable(parent context.Context) context.Context
- type Prefix
- type SQLiteIPAMStorage
- func (sqlis *SQLiteIPAMStorage) Add(ctx context.Context, prefix types.Prefix) error
- func (sqlis *SQLiteIPAMStorage) Delete(ctx context.Context, prefix types.Prefix) error
- func (sqlis *SQLiteIPAMStorage) Get(ctx context.Context, name string, parent types.Prefix) (types.Prefix, error)
- func (sqlis *SQLiteIPAMStorage) GetChilds(ctx context.Context, prefix types.Prefix) ([]types.Prefix, error)
- func (sqlis *SQLiteIPAMStorage) StartGarbageCollector(ctx context.Context, interval time.Duration, threshold time.Duration)
- func (sqlis *SQLiteIPAMStorage) Update(ctx context.Context, prefix types.Prefix) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Prefix ¶
type Prefix struct { Id string `gorm:"primaryKey"` Name string `gorm:"index"` // supposedly indexing could improve query performance Cidr string ParentID string `gorm:"index"` Parent *Prefix UpdatedAt time.Time `gorm:"index"` // supposedly indexing could improve query performance Expirable *bool `gorm:"index;default:false"` // indicates whether prefix can expire and thus be subject to garbage collection }
type SQLiteIPAMStorage ¶
func New ¶
func New(datastore string) (*SQLiteIPAMStorage, error)
func (*SQLiteIPAMStorage) Add ¶
Add adds prefix to database. Also sets the expirable field based on the context.
func (*SQLiteIPAMStorage) Get ¶
func (sqlis *SQLiteIPAMStorage) Get(ctx context.Context, name string, parent types.Prefix) (types.Prefix, error)
Get finds and returns the first database record matching the given prefix. Note: default or unset fields are ignored by the GORM query
func (*SQLiteIPAMStorage) StartGarbageCollector ¶ added in v1.1.2
func (sqlis *SQLiteIPAMStorage) StartGarbageCollector(ctx context.Context, interval time.Duration, threshold time.Duration)
StartGarbageCollector - StartGarbageCollector periodically runs a garbage collector to clean up outdated expirable records with valid updatedAt values (where threshold determines what is considered outdated).
func (*SQLiteIPAMStorage) Update ¶ added in v1.1.2
Update - Updates or add the database entry. Currently, the whole purpose of this function is to update the UpdatedAt field in the database that is used by garbage collector logic to clean up unused entries that haven't been updated for a long time. And to keep the expirable field set for records that can expire based on the context. (GORM Save() considers unset entries as well to update the record, thus expirable field must be set to either false or true.)