Documentation ¶
Overview ¶
Package config provides business API for config.
Index ¶
- Variables
- type Config
- type Core
- func (c Core) Create(ctx context.Context, newConfig NewConfig, now time.Time) (Config, error)
- func (c Core) Delete(ctx context.Context, configKey string) error
- func (c Core) QueryByKey(ctx context.Context, configKey string) (Config, error)
- func (c Core) QueryEngineConfig(ctx context.Context) (*config.Config, error)
- func (c Core) Update(ctx context.Context, configKey string, updateConfig UpdateConfig, ...) error
- type NewConfig
- type UpdateConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("config not found") ErrInvalidConfig = errors.New("config is not in its proper form") )
Set of error variables for CRUD operations.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Key string `db:"key"` Value string `db:"value"` DateCreated time.Time `db:"date_created"` DateUpdated time.Time `db:"date_updated"` }
Config represents an individual config.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core manages the set of APIs for config access.
func NewCore ¶
func NewCore(log *zap.SugaredLogger, sqlxDB *sqlx.DB) Core
NewCore constructs a core for config api access.
func (Core) QueryByKey ¶
QueryByKey gets the specified config from the database.
func (Core) QueryEngineConfig ¶
QueryEngineConfig gets the parsed engine config from the database.
type UpdateConfig ¶
type UpdateConfig struct {
Value *string `json:"value"`
}
UpdateConfig defines what information may be provided to modify an existing Config. All fields are optional so clients can send just the fields they want changed. It uses pointer fields so we can differentiate between a field that was not provided and a field that was provided as explicitly blank. Normally we do not want to use pointers to basic types but we make exceptions around marshalling/unmarshalling.