Documentation ¶
Index ¶
- Constants
- func NewService(ctx gousu.IContext) gousu.IService
- type IService
- type Service
- func (s *Service) AddProfile(profile *model.ProfileV1) (int64, error)
- func (s *Service) DeleteProfile(id int64) error
- func (s *Service) GetProfile(id int64) (*model.ProfileV1, error)
- func (s *Service) GetProfiles() ([]*model.ProfileV1, error)
- func (s *Service) Health() error
- func (s *Service) Name() string
- func (s *Service) Start() error
- func (s *Service) Stop() error
- func (s *Service) UpdateKey(newKey string) error
- func (s *Service) UpdateProfile(profile *model.ProfileV1) error
- func (s *Service) UseKey(key string) error
Constants ¶
const ServiceName = "settings"
ServiceName defines the name of the settings service
Variables ¶
This section is empty.
Functions ¶
func NewService ¶
func NewService(ctx gousu.IContext) gousu.IService
NewService creates a new instance of the settings Service
Types ¶
type IService ¶
type IService interface { gousu.IService GetProfiles() ([]*model.ProfileV1, error) GetProfile(id int64) (*model.ProfileV1, error) AddProfile(profile *model.ProfileV1) (int64, error) UpdateProfile(profile *model.ProfileV1) error DeleteProfile(id int64) error }
IService defines the interface of the settings service
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides a service for accesisng the settings file
func (*Service) AddProfile ¶
AddProfile adds a new profile to the settings, stores them to file and returns the profile's new ID
func (*Service) DeleteProfile ¶
DeleteProfile deletes an existing profile and stores all settings to file
Returns an error if the profile doesn't exist
func (*Service) GetProfile ¶
GetProfile loads an existing profile by its ID
Returns an error if the profile was not found
func (*Service) GetProfiles ¶
GetProfiles returns all known profiles
func (*Service) Start ¶
Start loads an existing settings file if it exists, else the settings are created in memory an written to file later on the first change
func (*Service) UpdateProfile ¶
UpdateProfile updates an existing profile (profile ID must be set) and stores all settings to file