config

package
v0.0.0-...-193f563 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication

type Authentication struct {
	SerectKey string `yaml:"secret_key" json:"secret_key"`
}

Authentication use to authenticate

type Config

type Config struct {
	SerectKey           string `yaml:"agent_serect_key"`
	AgentURL            string `yaml:"agent_url"`
	PersistenceSupport  string `yaml:"persistence_support"`
	PersistenceFileName string `yaml:"persistence_file_name"`

	database.ConnectionInfo `yaml:"-"`
	Databases               []database.Database                  `yaml:"-" json:"databases_list,omitempty"`
	ModelMap                map[string]map[string]database.Model `yaml:"-" json:"-"`
	Version                 Version                              `yaml:"-" json:"version"`

	Authentication *Authentication `yaml:"authentication" json:"authentication"`

	sync.Mutex `yaml:"-"`
	// contains filtered or unexported fields
}

Config contain config for dashboard

func (*Config) AddHook

func (c *Config) AddHook(tableName, hookType, content string) error

AddHook add hook to configuration

func (*Config) ChangeVersion

func (c *Config) ChangeVersion(id int) error

ChangeVersion get config in persistent by version number

func (*Config) CheckSum

func (c *Config) CheckSum() (string, error)

CheckSum to checksum md5 when agent-sync check version

func (*Config) DB

func (c *Config) DB(dbName string) *gorm.DB

DB get db connection from config

func (*Config) DBs

func (c *Config) DBs() map[string]*gorm.DB

DBs get db connection from config

func (*Config) UpdateConfig

func (c *Config) UpdateConfig(cfg *Config) error

UpdateConfig update configuration

func (*Config) UpdateConfigFromAgent

func (c *Config) UpdateConfigFromAgent() error

UpdateConfigFromAgent update configuration from agent

func (*Config) UpdateConfigFromAgentConfig

func (c *Config) UpdateConfigFromAgentConfig(agentCfg *agentConfig.Config) error

UpdateConfigFromAgentConfig update config from AgentConfig

func (*Config) UpdateDB

func (c *Config) UpdateDB() error

UpdateDB update db connection

type Querier

type Querier interface {
	ListVersion() ([]Version, error)
	LastestVersion() (*Config, error)
}

Querier interface for reading config for agent

type Reader

type Reader interface {
	Read() (*Config, error)
}

Reader interface for reading config for agent

func ReadYAML

func ReadYAML(file string) Reader

ReadYAML reader dashboard config from front-end

type ReaderWriterQuerier

type ReaderWriterQuerier interface {
	Reader
	Writer
	Querier
}

ReaderWriterQuerier compose interface for read/write/query config for agent

func NewBoltPersistent

func NewBoltPersistent(persistenceFileName string, versionID int) ReaderWriterQuerier

NewBoltPersistent Peristent Bolt

type Version

type Version struct {
	Checksum string    `json:"checksum"`
	ID       int       `json:"id"`
	SyncAt   time.Time `json:"sync_at"`
}

Version version of backend config

type Wrapper

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

Wrapper use to hide detail of a config

func NewWrapper

func NewWrapper(cfg *Config) *Wrapper

NewWrapper .

func (*Wrapper) SyncConfig

func (w *Wrapper) SyncConfig() *Config

SyncConfig get synchronized config from wrapper

type Writer

type Writer interface {
	Write(cfg *Config) error
}

Writer interface for reading config for agent

func WriteYAML

func WriteYAML(file string) Writer

WriteYAML to write data to .yaml file

Directories

Path Synopsis
database
pg

Jump to

Keyboard shortcuts

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