domain

package
v0.0.0-...-cbea63e Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPathNotFound   = errors.New("Config path not found")
	ErrIdNotFound     = errors.New("Config ID not found")
	DefaultRepository ConfigRepository
)

Functions

func CompileConfig

func CompileConfig(ids []string, path string) ([]byte, error)

CompileConfig will combine multiple configs together.

func CreateOrUpdateConfig

func CreateOrUpdateConfig(changeId, id, path, userMech, userId, message string, data []byte) error

CreateOrUpdateConfig will create or update the config for id at the specified path. Message should be a description of the change. Data should be the JSON data. userMech identifies the authentication mechanism of the scope from which this change was applied

func DeleteConfig

func DeleteConfig(changeId, id, path, userMech, userId, message string) error

DeleteConfig will delete the node at the specified path It will return ErrPathNotFound if the path does not exist

func ExplainConfig

func ExplainConfig(ids []string, path string) ([]byte, error)

ExplainConfig returns the compiled config except that instead of showing the original values, it shows which id was responsible for setting it

func NewMemoryRepository

func NewMemoryRepository(data map[string]*ChangeSet) *memoryRepository

Types

type ChangeSet

type ChangeSet struct {
	// Id is a unique ID for the change
	Id string `cf:"configservice" key:"Id" name:"id" json:"id"`
	// Body is the JSON being applied
	Body []byte `name:"body" json:"body"`
	// Timestamp is when this happened
	Timestamp time.Time `name:"timestamp" json:"timestamp"`
	// UserMech identifies the authentication mechanism of the scope from which this change was applied
	UserMech string `name:"userMech" json:"userMech"`
	// UserId identifies the authenticated user ID of the scope from which this change was applied
	UserId string `name:"userId" json:"userId"`
	// Message tells us some human-readable message about the change
	Message string `name:"message" json:"message"`
	// ChangeId is some unique ID for this change
	ChangeId string `name:"changeId" json:"changeId"`
	// Path of the config being updated
	Path string `name:"path" json:"path"`
	// Old value for the config
	OldConfig []byte `name:"oldConfig" json:"oldConfig"`
}

ChangeSet represents some change to our config

func ChangeLog

func ChangeLog(start, end time.Time, count int, lastId string) ([]*ChangeSet, string, error)

ChangeLog returns a time series list of changes

func ReadConfig

func ReadConfig(id, path string) ([]byte, *ChangeSet, error)

ReadConfig returns the config item with the specified id. The path is optional, and if included will only return the contents at that path within the config. For reference, the changeset is included which will contain meta data about the last update

func ServiceChangeLog

func ServiceChangeLog(id string, start, end time.Time, count int, lastId string) ([]*ChangeSet, string, error)

ChangeLog returns a time series list of changes for the given ID

type ConfigRepository

type ConfigRepository interface {
	ReadConfig(ids []string) ([]*ChangeSet, error)
	UpdateConfig(cs *ChangeSet) error
	ChangeLog(start, end time.Time, count int, lastId string) ([]*ChangeSet, string, error)
	ServiceChangeLog(id string, start, end time.Time, count int, lastId string) ([]*ChangeSet, string, error)
}

Jump to

Keyboard shortcuts

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