settings

package
v0.0.0-...-92b1827 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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

func (s *Service) AddProfile(profile *model.ProfileV1) (int64, error)

AddProfile adds a new profile to the settings, stores them to file and returns the profile's new ID

func (*Service) DeleteProfile

func (s *Service) DeleteProfile(id int64) error

DeleteProfile deletes an existing profile and stores all settings to file

Returns an error if the profile doesn't exist

func (*Service) GetProfile

func (s *Service) GetProfile(id int64) (*model.ProfileV1, error)

GetProfile loads an existing profile by its ID

Returns an error if the profile was not found

func (*Service) GetProfiles

func (s *Service) GetProfiles() ([]*model.ProfileV1, error)

GetProfiles returns all known profiles

func (*Service) Health

func (s *Service) Health() error

Health returns always nil (healthy)

func (*Service) Name

func (s *Service) Name() string

Name returns the name of the settings service defined by ServiceName

func (*Service) Start

func (s *Service) Start() error

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) Stop

func (s *Service) Stop() error

Stop does nothing

func (*Service) UpdateKey

func (s *Service) UpdateKey(newKey string) error

func (*Service) UpdateProfile

func (s *Service) UpdateProfile(profile *model.ProfileV1) error

UpdateProfile updates an existing profile (profile ID must be set) and stores all settings to file

func (*Service) UseKey

func (s *Service) UseKey(key string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL