Documentation ¶
Index ¶
- Constants
- type Config
- type Dependency
- type HasConfig
- type HasDefaultConfig
- type Manager
- type Object
- func (n Object) Get(key string) interface{}
- func (n Object) GetBool(key string) bool
- func (n Object) GetDuration(key string) time.Duration
- func (n Object) GetInt(key string) int
- func (n Object) GetString(key string) string
- func (n Object) GetStrings(key string) []string
- func (n Object) IsSet(key string) bool
- func (n Object) Keys() (keys []string)
- func (n Object) Marshal() ([]byte, error)
- func (n Object) Set(key string, value interface{})
- func (n Object) SetDefault(key string, defaultValue interface{})
- func (n Object) Unmarshal(data []byte) error
- type Service
- func (s *Service) ConfigDirectory() string
- func (s *Service) Configs() map[string]*Config
- func (s *Service) CreateConfig(path string) (*Config, error)
- func (s *Service) GetConfig(path string) (*Config, error)
- func (s *Service) GetPath(name string) string
- func (s *Service) Init(mesh servicemesh.Mesh)
- func (s *Service) LoadConfig(path string) (*Config, error)
- func (s *Service) Logger() *slog.Logger
- func (s *Service) Name() string
- func (s *Service) Ready() bool
- func (s *Service) SaveConfig(path string) error
- func (s *Service) SetConfigDirectory(dir string) error
- func (s *Service) SetLogger(l *slog.Logger)
Constants ¶
const (
EventConfigChanged = "config file changed"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dependency ¶
type Dependency = Manager
type HasConfig ¶
type HasConfig interface { ConfigFileName() string // ConfigFilePath returns the path to the configuration file. Config() (*Config, error) // Config retrieves the configuration from the file. }
HasConfig represents a something with a configuration file path and retrieval methods.
type HasDefaultConfig ¶
type HasDefaultConfig interface { HasConfig DefaultConfig() Config // DefaultConfig returns the default configuration. }
HasDefaultConfig represents something with a default configuration.
type Manager ¶
type Manager interface { GetPath(path string) string ConfigDirectory() string // ConfigDirectory returns the directory path where configurations are stored. SetConfigDirectory(string) error // SetConfigDirectory sets the directory path for configurations. Configs() map[string]*Config // Configs returns all configurations stored in the service. GetConfig(string) (*Config, error) // GetConfig retrieves a configuration by its path. CreateConfig(path string) (*Config, error) // CreateConfig creates a new configuration file at the specified path. LoadConfig(string) (*Config, error) // LoadConfig loads a configuration from the specified path. SaveConfig(string) error // SaveConfig saves a configuration to the specified path. }
Manager represents something that manages configurations.
type Object ¶
type Object map[string]interface{}
func (Object) GetStrings ¶
func (Object) SetDefault ¶
type Service ¶
type Service struct { RootDirectory string // contains filtered or unexported fields }
Service is a config file manager that marshals to and from json files.
func (*Service) ConfigDirectory ¶
ConfigDirectory returns the directory path where the service's configurations are stored. If the directory is not set, it returns a default.
func (*Service) CreateConfig ¶
CreateConfig creates a new configuration file at the specified path. It locks the service's mutex to ensure safe concurrent access.
func (*Service) GetConfig ¶
GetConfig retrieves a configuration by its path from the service's internal map. It locks the service's mutex to ensure safe concurrent access.
func (*Service) Init ¶
func (s *Service) Init(mesh servicemesh.Mesh)
Init satisfies the servicemesh.Service interface
func (*Service) LoadConfig ¶
LoadConfig loads a configuration from the specified path. It locks the service's mutex to ensure safe concurrent access.
func (*Service) SaveConfig ¶
SaveConfig saves a configuration to the specified path. It locks the service's mutex to ensure safe concurrent access.
func (*Service) SetConfigDirectory ¶
SetConfigDirectory sets the directory path where the service's configurations should be stored. It locks the service's mutex to ensure safe concurrent access.