config

package
v0.0.0-...-65e2f22 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2018 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeBaseHandler

func MakeBaseHandler(
	svc BaseService,
	opts ...kithttp.ServerOption,
) http.Handler

MakeBaseHandler returns an http.Handler for the base config service.

func MakeHandler

func MakeHandler(
	svc UserService,
	auth endpoint.Middleware,
	opts ...kithttp.ServerOption,
) http.Handler

MakeHandler returns an http.Handler for the user config service.

Types

type BaseConfig

type BaseConfig struct {
	ClientID   string
	Deleted    bool
	ID         string
	Name       string
	Parameters rule.Parameters
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

BaseConfig is the entire space of available parameters.

type BaseList

type BaseList []BaseConfig

BaseList is a collection of BaseConfig.

func (BaseList) Len

func (l BaseList) Len() int

func (BaseList) Less

func (l BaseList) Less(i, j int) bool

func (BaseList) Swap

func (l BaseList) Swap(i, j int)

type BaseRepo

type BaseRepo interface {
	Create(id, clientID, name string, parameters rule.Parameters) (BaseConfig, error)
	GetByID(id string) (BaseConfig, error)
	GetByName(clientID, name string) (BaseConfig, error)
	List() (BaseList, error)
	Update(BaseConfig) (BaseConfig, error)
	// contains filtered or unexported methods
}

BaseRepo provides access to base configs.

type BaseRepoMiddleware

type BaseRepoMiddleware func(BaseRepo) BaseRepo

BaseRepoMiddleware is chainable behaviour modifier for BaseRepo.

func NewBaseRepoInstrumentMiddleware

func NewBaseRepoInstrumentMiddleware(
	opObserve instrument.ObserveRepoFunc,
	store string,
) BaseRepoMiddleware

NewBaseRepoInstrumentMiddleware wraps the next BaseRepo and add Prometheus instrumentation capabilities.

func NewBaseRepoLogMiddleware

func NewBaseRepoLogMiddleware(logger log.Logger, store string) BaseRepoMiddleware

NewBaseRepoLogMiddleware wraps the next BaseRepo with logging capabilities.

type BaseService

type BaseService interface {
	Create(clientID, name string) (BaseConfig, error)
	Get(id string) (BaseConfig, error)
	List() ([]BaseConfig, error)
	Update(id string, parameters rule.Parameters) (BaseConfig, error)
}

BaseService provides base configs.

func NewBaseService

func NewBaseService(baseRepo BaseRepo, clientRepo client.Repo) BaseService

NewBaseService provides base configs.

type PGBaseRepo

type PGBaseRepo struct {
	// contains filtered or unexported fields
}

PGBaseRepo is a Postgres backed BaseRepo implementation.

func NewPostgresBaseRepo

func NewPostgresBaseRepo(db *sqlx.DB, options ...PGBaseRepoOption) *PGBaseRepo

NewPostgresBaseRepo returns a Postgres backed BaseRepo implementation.

func (*PGBaseRepo) Create

func (r *PGBaseRepo) Create(
	id, clientID, name string,
	parameters rule.Parameters,
) (BaseConfig, error)

Create stores a new base config with the given inputs.

func (*PGBaseRepo) GetByID

func (r *PGBaseRepo) GetByID(id string) (BaseConfig, error)

GetByID returns the base config for the given id.

func (*PGBaseRepo) GetByName

func (r *PGBaseRepo) GetByName(clientID, name string) (BaseConfig, error)

GetByName retrieves the base config for the given name.

func (*PGBaseRepo) List

func (r *PGBaseRepo) List() (BaseList, error)

List returns all base configs.

func (*PGBaseRepo) Update

func (r *PGBaseRepo) Update(c BaseConfig) (BaseConfig, error)

Update overrides the base config stored under the id of the input config.

type PGBaseRepoOption

type PGBaseRepoOption func(*PGBaseRepo)

PGBaseRepoOption sets an optional parameter for the base repo.

func PGBaseRepoSchema

func PGBaseRepoSchema(schema string) PGBaseRepoOption

PGBaseRepoSchema sets the namespacing of the Postgres tables toa non-default schema.

type PGUserRepo

type PGUserRepo struct {
	// contains filtered or unexported fields
}

PGUserRepo is a Postgres backed UserRepo implementation.

func (*PGUserRepo) Append

func (r *PGUserRepo) Append(
	id, baseID, userID string,
	decisions rule.Decisions,
	render rule.Parameters,
) (UserConfig, error)

Append creates a new user config with the given inputs. We want to enforce append only semantics.

func (*PGUserRepo) GetLatest

func (r *PGUserRepo) GetLatest(baseID, userID string) (UserConfig, error)

GetLatest returns the last rendered user config for the give base and user id.

type PGUserRepoOption

type PGUserRepoOption func(*PGUserRepo)

PGUserRepoOption sets an optional parameter for the user repo.

func PGUserRepoSchema

func PGUserRepoSchema(schema string) PGUserRepoOption

PGUserRepoSchema sets the namespacing of the Postgres tables toa non-default schema.

type UserConfig

type UserConfig struct {
	// contains filtered or unexported fields
}

UserConfig is a users rendered config.

type UserRepo

type UserRepo interface {
	Append(
		id, baseID, userID string,
		decisiosn rule.Decisions,
		render rule.Parameters,
	) (UserConfig, error)
	GetLatest(baseID, userID string) (UserConfig, error)
	// contains filtered or unexported methods
}

UserRepo provides access to user configs.

func NewPostgresUserRepo

func NewPostgresUserRepo(db *sqlx.DB, options ...PGUserRepoOption) UserRepo

NewPostgresUserRepo returns a Postgres backed UserRepo implementation.

type UserRepoMiddleware

type UserRepoMiddleware func(UserRepo) UserRepo

UserRepoMiddleware is chainable behaviour modifier for UserRepo.

func NewUserRepoInstrumentMiddleware

func NewUserRepoInstrumentMiddleware(
	opObserve instrument.ObserveRepoFunc,
	store string,
) UserRepoMiddleware

NewUserRepoInstrumentMiddleware wraps the next BaseRepo and add Prometheus instrumentation capabilities.

func NewUserRepoLogMiddleware

func NewUserRepoLogMiddleware(logger log.Logger, store string) UserRepoMiddleware

NewUserRepoLogMiddleware wraps the next UserRepo with logging capabilities.

type UserService

type UserService interface {
	Render(clientID, baseName, userID string, ctx userRenderContext) (UserConfig, error)
}

UserService provides user specific configs.

func NewUserService

func NewUserService(
	baseRepo BaseRepo,
	userRepo UserRepo,
	ruleRepo rule.Repo,
	randFn generate.RandPercentageFunc,
) UserService

NewUserService provides user specific configs.

Jump to

Keyboard shortcuts

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