func (s *MemoryStore) GetLocation(ctx context.Context, name string) (*resources.Location, error) {
	s.m.Lock()
	defer s.m.Unlock()
	r, ok := s.locations[name]
	if !ok {
		return nil, fmt.Errorf("location %q does not exist", name)
	}
	return &r, nil
}
GetLocation returns the Location with the given name.
package store
import (
	"context"
	"fmt"
	"sort"
	"sync"
	"time"
	"github.com/google/emitto/source/resources"
)
type MemoryStore struct {
	m              sync.Mutex
	locations      map[string]resources.Location
	rules          map[int64]resources.Rule
	sensorRequests map[string]resources.SensorRequest
	sensorMessages map[string]resources.SensorMessage
}
func NewMemoryStore() *MemoryStore {
	return &MemoryStore{
		locations:      make(map[string]resources.Location),
		rules:          make(map[int64]resources.Rule),
		sensorRequests: make(map[string]resources.SensorRequest),
		sensorMessages: make(map[string]resources.SensorMessage),
	}
}
func (s *MemoryStore) AddLocation(ctx context.Context, l *resources.Location) error {
	s.m.Lock()
	defer s.m.Unlock()
	cp := *l
	if _, ok := s.locations[cp.Name]; ok {
		return fmt.Errorf("location %q already exists", cp.Name)
	}
	cp.LastModified = TimeNow().Format(time.RFC1123Z)
	s.locations[cp.Name] = cp
	return nil
}
func (s *MemoryStore) ModifyLocation(ctx context.Context, l *resources.Location) error {
	s.m.Lock()
	defer s.m.Unlock()
	cp := *l
	loc, ok := s.locations[cp.Name]
	if !ok {
		return fmt.Errorf("location %q does not exist", cp.Name)
	}
	if err := MutateLocation(&cp, &loc); err != nil {
		return fmt.Errorf("unable to mutate location src=%+v dst=%+v: %v", cp, loc, err)
	}
	loc.LastModified = TimeNow().Format(time.RFC1123Z)
	s.locations[cp.Name] = loc
	return nil
}
func (s *MemoryStore) DeleteLocation(ctx context.Context, name string) error {
	s.m.Lock()
	defer s.m.Unlock()
	if _, ok := s.locations[name]; !ok {
		return fmt.Errorf("location %q does not exist", name)
	}
	delete(s.locations, name)
	return nil
}