Documentation ¶
Index ¶
- Variables
- type Infoer
- type Storage
- func (s *Storage) FilterServers(provider string, selection settings.ServerSelection) (servers []models.Server, err error)
- func (s *Storage) FlushToFile(path string) error
- func (s *Storage) FormatToMarkdown(provider string) (formatted string)
- func (s *Storage) GetFilterChoices(provider string) models.FilterChoices
- func (s *Storage) GetServerByName(provider, name string) (server models.Server, ok bool)
- func (s *Storage) GetServersCount(provider string) (count int)
- func (s *Storage) ServersAreEqual(provider string, servers []models.Server) (equal bool)
- func (s *Storage) SetServers(provider string, servers []models.Server) (err error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoServerFound = errors.New("no server found")
Functions ¶
This section is empty.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new storage and reads the servers from the embedded servers file and the file on disk. Passing an empty filepath disables writing servers to a file.
func (*Storage) FilterServers ¶
func (s *Storage) FilterServers(provider string, selection settings.ServerSelection) ( servers []models.Server, err error)
FilterServers filter servers for the given provider and according to the given selection. The filtered servers are deep copied so they are safe for mutation by the caller.
func (*Storage) FlushToFile ¶
FlushToFile flushes the merged servers data to the file specified by path, as indented JSON.
func (*Storage) FormatToMarkdown ¶
FormatToMarkdown Markdown formats the servers for the provider given and returns the resulting string.
func (*Storage) GetFilterChoices ¶
func (s *Storage) GetFilterChoices(provider string) models.FilterChoices
func (*Storage) GetServerByName ¶
GetServerByName returns the server for the given provider and server name. It returns `ok` as false if the server is not found. The returned server is also deep copied so it is safe for mutation and/or thread safe use.
func (*Storage) GetServersCount ¶
GetServersCount returns the number of servers for the provider given.
func (*Storage) ServersAreEqual ¶
GetServersCount returns the number of servers for the provider given.
func (*Storage) SetServers ¶
SetServers sets the given servers for the given provider in the storage in-memory map and saves all the servers to file. Note the servers given are not copied so the caller must NOT MUTATE them after calling this method.