config

package
v0.0.0-...-cb7d7c7 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SyncTypeMongo = "mongo"
	SyncTypeEs    = "elasticsearch"
	SyncTypeMysql = "mysql"
	SyncTypeFile  = "file"
)

Variables

This section is empty.

Functions

func NewConfig

func NewConfig(path string) (cfgChan chan *Config, err error)

NewConfig 初始化一个server配置文件对象

Types

type Config

type Config struct {
	Debug bool          `toml:"debug" json:"debug,omitempty"`
	Mongo *MongoConfig  `toml:"mongo" json:"mongo,omitempty"`
	Sync  []*SyncConfig `toml:"sync" json:"sync,omitempty"`
}

Config 配置文件

type MongoConfig

type MongoConfig struct {
	SourceUri     string  `toml:"source_uri" json:"source_uri,omitempty"`
	SourceVersion float32 `toml:"source_version" json:"source_version,omitempty"`
}

func (*MongoConfig) String

func (c *MongoConfig) String() string

type SyncConfig

type SyncConfig struct {
	Enable          bool                `toml:"enable" json:"enable,omitempty"`                     // 是否启用
	Type            string              `toml:"type" json:"type,omitempty"`                         // mongo elasticsearch mysql file 一种输出类型只能配置一个,如果多个,请开启多个程序
	DestinationUri  string              `toml:"destination_uri" json:"destination_uri,omitempty"`   // 目标db链接地址
	SourceDb        string              `toml:"source_db" json:"source_db,omitempty"`               // 源db
	DestinationDb   string              `toml:"destination_db" json:"destination_db,omitempty"`     // 目标db
	Collections     map[string]string   `toml:"collections" json:"collections,omitempty"`           // 同步的集合对照 key:来源集合 val:目标集合或表等
	CollectionField map[string][]string `toml:"collection_field" json:"collection_field,omitempty"` // 需要同步的字段列表 - 下标为来源db的collection名值为同步的字段列表
}

func (*SyncConfig) GetKey

func (cfg *SyncConfig) GetKey() string

用于区分某个同步配置

func (*SyncConfig) InCollectionField

func (cfg *SyncConfig) InCollectionField(collection, field string) bool

func (*SyncConfig) String

func (cfg *SyncConfig) String() string

Jump to

Keyboard shortcuts

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