MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / GetByID

Method GetByID

pkg/frequencyplans/frequencyplans.go:693–714  ·  view source on GitHub ↗

GetByID retrieves the frequency plan that has the given ID.

(id string)

Source from the content-addressed store, hash-verified

691
692// GetByID retrieves the frequency plan that has the given ID.
693func (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.
717func (s *Store) GetAllIDs() ([]string, error) {

Callers 6

ExampleFunction · 0.95
TestEmptyStoreFunction · 0.95
TestStoreFunction · 0.95
TestRespectsDwellTimeFunction · 0.95
TestBuildLoradFunction · 0.95
TestFrequencyPlansFunction · 0.95

Calls 4

getByIDMethod · 0.95
NewMethod · 0.65
NowMethod · 0.65
WithAttributesMethod · 0.45

Tested by 6

ExampleFunction · 0.76
TestEmptyStoreFunction · 0.76
TestStoreFunction · 0.76
TestRespectsDwellTimeFunction · 0.76
TestBuildLoradFunction · 0.76
TestFrequencyPlansFunction · 0.76