Version: v1.0.4 Latest Latest

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

Go to latest
Published: Jun 20, 2018 License: MIT Imports: 19 Imported by: 0




View Source
const (
	VERSION = "1.0.3"


View Source
var (
	Pid        = path.CurrentPath + "/"
	DEBUG      = false
	ConfigPath = path.CurrentPath + "/config"
	CachePath  = path.CurrentPath + "/cache"
	LogPath    = path.CurrentPath + "/logs"
View Source
var (
	ErrorFileNotFound = errors.New("file does not exists")
	ErrorFileParse    = errors.New("config file parse error")


func DaemonProcess

func DaemonProcess(d bool) bool

run as daemon process

func GetKey

func GetKey(sessionFile string) string

get unique key, param if file path if file does not exists, try to create it, and write a unique key return the unique key if exists, read file and return it

func Init

func Init(hasCmd bool, configPath string)

app init config path parse cache path parse log path parse get app config check app is running, if pid file exists, app is running write pid file start pprof set logger

func Release

func Release()

use for main func, defer app.Release release ctx resource

func Usage

func Usage()

show usage


type Config

type Config struct {
	LogLevel      int    `toml:"log_level"`
	PprofListen   string `toml:"pprof_listen"`
	ControlListen string `toml:"control_listen"`
	TimeZone      string `toml:"time_zone"`
	CachePath     string `toml:"cache_path"`
	LogPath       string `toml:"log_path"`
	PidFile       string `toml:"pid_file"`

type Context

type Context struct {
	// canal context
	Ctx context.Context
	// canal context func
	Cancel context.CancelFunc
	// pid file path
	PidFile string

	//reloadChan chan string
	//ShowMembersChan chan struct{}
	//ShowMembersRes chan string
	PosChan chan string
	//HttpConfig *HttpConfig
	//TcpConfig *TcpConfig
	MysqlConfig *MysqlConfig
	//ClusterConfig *ClusterConfig
	AppConfig *Config
	// contains filtered or unexported fields


func NewContext

func NewContext() *Context

new app context

func (*Context) Done

func (ctx *Context) Done() <-chan struct{}

func (*Context) Stop

func (ctx *Context) Stop()

type MysqlConfig

type MysqlConfig struct {
	// mysql service ip and port, like: ""
	Addr string `toml:"addr"`
	// mysql service user
	User string `toml:"user"`
	// mysql password
	Password string `toml:"password"`
	// mysql default charset
	Charset string `toml:"charset"`
	// mysql binlog client id, it must be unique
	ServerID uint32 `toml:"server_id"`
	// mysql or mariadb
	Flavor string `toml:"flavor"`
	// heartbeat interval, unit is ns, 30000000000  = 30s   1000000000 = 1s
	HeartbeatPeriod time.Duration `toml:"heartbeat_period"`
	// read timeout, unit is ns, 0 is never timeout, 30000000000  = 30s   1000000000 = 1s
	ReadTimeout time.Duration `toml:"read_timeout"`
	// read start form the binlog file
	BinFile string `toml:"bin_file"`
	// read start form the pos
	BinPos uint32 `toml:"bin_pos"`

type TcpConfig

type TcpConfig struct {
	Listen    string `toml:"listen"`
	Port      int    `toml:"port"`
	Enable    bool   `toml:"enable"`
	ServiceIp string `toml:"service_ip"`
	Groups    TcpGroupConfigs

type TcpGroupConfig

type TcpGroupConfig struct {
	Name   string
	Filter []string

type TcpGroupConfigs

type TcpGroupConfigs map[string]TcpGroupConfig

func (*TcpGroupConfigs) HasName

func (cs *TcpGroupConfigs) HasName(name string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL