Documentation
¶
Overview ¶
Package backend provides an in-memory thread-safe data store for creating and accessing geospatial.State objects. This data store implements the methods that satisfy the [server.StateLocationDataProvider] interface used by the state-server API webserver
Index ¶
- type InvalidStateError
- type StateLocationMemoryStore
- func (s *StateLocationMemoryStore) Create(state geospatial.State) (geospatial.State, error)
- func (s *StateLocationMemoryStore) Delete(name string) error
- func (s *StateLocationMemoryStore) GetAll() ([]geospatial.State, error)
- func (s *StateLocationMemoryStore) GetByName(name string) (geospatial.State, error)
- type StateNotFoundError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InvalidStateError ¶
type InvalidStateError struct {
Err error
}
Error struct which implements the Error interface and allows HTTP request handlers to generate the appropriate response
func (*InvalidStateError) Error ¶
func (e *InvalidStateError) Error() string
type StateLocationMemoryStore ¶
type StateLocationMemoryStore struct {
// contains filtered or unexported fields
}
func NewMemoryStore ¶
func NewMemoryStore() *StateLocationMemoryStore
Constructor for the StateLocationMemoryStore struct instaniates the data store with a string formatter for title-casing state names in a standardized manner
func (*StateLocationMemoryStore) Create ¶
func (s *StateLocationMemoryStore) Create(state geospatial.State) (geospatial.State, error)
Validates a provided geospatial.State object and adds it to the data store. Returns InvalidStateError is the geospatial.State provided is invalid.
func (*StateLocationMemoryStore) Delete ¶
func (s *StateLocationMemoryStore) Delete(name string) error
Removes the geospatial.State with the provided name from the data store collection if it exists.
func (*StateLocationMemoryStore) GetAll ¶
func (s *StateLocationMemoryStore) GetAll() ([]geospatial.State, error)
Gets the entire collection of geospatial.State objects from the data store
func (*StateLocationMemoryStore) GetByName ¶
func (s *StateLocationMemoryStore) GetByName(name string) (geospatial.State, error)
Gets a single geospatial.State object from the data store. Returns StateNotFoundError if no state exists for the given name
type StateNotFoundError ¶
type StateNotFoundError struct {
Name string
}
Error struct which implements the Error interface and allows HTTP request handlers to generate the appropriate response
func (*StateNotFoundError) Error ¶
func (e *StateNotFoundError) Error() string