config

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package config provides business API for config.

Index

Constants

This section is empty.

Variables

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

func (c Core) Create(ctx context.Context, newConfig NewConfig, now time.Time) (Config, error)

Create inserts a new config into the database.

func (Core) Delete

func (c Core) Delete(ctx context.Context, configKey string) error

Delete removes a config from the database.

func (Core) QueryByKey

func (c Core) QueryByKey(ctx context.Context, configKey string) (Config, error)

QueryByKey gets the specified config from the database.

func (Core) QueryEngineConfig

func (c Core) QueryEngineConfig(ctx context.Context) (*config.Config, error)

QueryEngineConfig gets the parsed engine config from the database.

func (Core) Update

func (c Core) Update(ctx context.Context, configKey string, updateConfig UpdateConfig, now time.Time) error

Update replaces a config document in the database.

type NewConfig

type NewConfig struct {
	Key   string `db:"key"`
	Value string `db:"value"`
}

NewConfig contains information needed to create a new Config.

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.

Directories

Path Synopsis
Package db contains config related CRUD functionality.
Package db contains config related CRUD functionality.

Jump to

Keyboard shortcuts

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