mirror of
https://github.com/safing/portbase
synced 2025-09-10 15:34:26 +00:00
Add GetMeta to database storage interface
This commit is contained in:
parent
3f3786b854
commit
0061572e1b
11 changed files with 170 additions and 32 deletions
|
@ -42,7 +42,7 @@ func (c *Controller) Injected() bool {
|
|||
return c.storage.Injected()
|
||||
}
|
||||
|
||||
// Get return the record with the given key.
|
||||
// Get returns the record with the given key.
|
||||
func (c *Controller) Get(key string) (record.Record, error) {
|
||||
if shuttingDown.IsSet() {
|
||||
return nil, ErrShuttingDown
|
||||
|
@ -76,6 +76,28 @@ func (c *Controller) Get(key string) (record.Record, error) {
|
|||
return r, nil
|
||||
}
|
||||
|
||||
// Get returns the metadata of the record with the given key.
|
||||
func (c *Controller) GetMeta(key string) (*record.Meta, error) {
|
||||
if shuttingDown.IsSet() {
|
||||
return nil, ErrShuttingDown
|
||||
}
|
||||
|
||||
m, err := c.storage.GetMeta(key)
|
||||
if err != nil {
|
||||
// replace not found error
|
||||
if err == storage.ErrNotFound {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !m.CheckValidity() {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Put saves a record in the database, executes any registered
|
||||
// pre-put hooks and finally send an update to all subscribers.
|
||||
// The record must be locked and secured from concurrent access
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue