(successTTL, errorTTL time.Duration)
| 56 | } |
| 57 | |
| 58 | func (c *cachedRes) valid(successTTL, errorTTL time.Duration) bool { |
| 59 | if c == nil { |
| 60 | return false |
| 61 | } |
| 62 | select { |
| 63 | case <-c.waitChan: |
| 64 | default: |
| 65 | return true // still fetching... |
| 66 | } |
| 67 | now := now() |
| 68 | if c.err != nil { |
| 69 | return now.Sub(c.time) <= errorTTL |
| 70 | } |
| 71 | return now.Sub(c.time) <= successTTL |
| 72 | } |
| 73 | |
| 74 | func (c *cachedRes) set(rights *ttnpb.Rights, err error) { |
| 75 | c.rights, c.err = rights, err |
no test coverage detected