Get returns the record with the given key.
(key string)
| 46 | |
| 47 | // Get returns the record with the given key. |
| 48 | func (c *Controller) Get(key string) (record.Record, error) { |
| 49 | if shuttingDown.IsSet() { |
| 50 | return nil, ErrShuttingDown |
| 51 | } |
| 52 | |
| 53 | if err := c.runPreGetHooks(key); err != nil { |
| 54 | return nil, err |
| 55 | } |
| 56 | |
| 57 | r, err := c.storage.Get(key) |
| 58 | if err != nil { |
| 59 | // replace not found error |
| 60 | if errors.Is(err, storage.ErrNotFound) { |
| 61 | return nil, ErrNotFound |
| 62 | } |
| 63 | return nil, err |
| 64 | } |
| 65 | |
| 66 | r.Lock() |
| 67 | defer r.Unlock() |
| 68 | |
| 69 | r, err = c.runPostGetHooks(r) |
| 70 | if err != nil { |
| 71 | return nil, err |
| 72 | } |
| 73 | |
| 74 | if !r.Meta().CheckValidity() { |
| 75 | return nil, ErrNotFound |
| 76 | } |
| 77 | |
| 78 | return r, nil |
| 79 | } |
| 80 | |
| 81 | // GetMeta returns the metadata of the record with the given key. |
| 82 | func (c *Controller) GetMeta(key string) (*record.Meta, error) { |
nothing calls this directly
no test coverage detected