GetByID retrieves the frequency plan that has the given ID.
(id string)
| 691 | |
| 692 | // GetByID retrieves the frequency plan that has the given ID. |
| 693 | func (s *Store) GetByID(id string) (*FrequencyPlan, error) { |
| 694 | if s == nil { |
| 695 | return nil, errNotConfigured.New() |
| 696 | } |
| 697 | |
| 698 | if id == "" { |
| 699 | return nil, errNotFound.WithAttributes("id", id) |
| 700 | } |
| 701 | |
| 702 | s.frequencyPlansMu.Lock() |
| 703 | defer s.frequencyPlansMu.Unlock() |
| 704 | if cached, ok := s.frequencyPlansCache[id]; ok && cached.err == nil || time.Since(cached.time) < yamlFetchErrorCache { |
| 705 | return cached.fp, cached.err |
| 706 | } |
| 707 | fp, err := s.getByID(id) |
| 708 | s.frequencyPlansCache[id] = queryResult{ |
| 709 | time: time.Now(), |
| 710 | fp: fp, |
| 711 | err: err, |
| 712 | } |
| 713 | return fp, err |
| 714 | } |
| 715 | |
| 716 | // GetAllIDs returns the list of IDs of the available frequency plans. |
| 717 | func (s *Store) GetAllIDs() ([]string, error) { |