Beispiel #1
0
//工厂初始化函数
func EtlOutputerInit(buffer chan bytes.Buffer, config map[string]string) (e etlOutputer) {

	e.buffer = buffer
	saveDir, _ := config["save_dir"]
	e.saveDir = saveDir
	e.dataDir = filepath.Join(saveDir, "log_data")
	e.headerDir = filepath.Join(saveDir, "headers")
	e.icDir = filepath.Join(saveDir, "received")
	e.etlDir = filepath.Join(saveDir, "etl")
	e.etlDoneDir = filepath.Join(saveDir, "etl_done")
	e.etlFailDir = filepath.Join(saveDir, "etl_fail")
	e.ic = integrity.NewIntegrityChecker(e.icDir)

	os.MkdirAll(e.dataDir, 0775)
	os.MkdirAll(e.headerDir, 0775)
	os.MkdirAll(e.etlDir, 0775)
	os.MkdirAll(e.etlDoneDir, 0775)
	os.MkdirAll(e.etlFailDir, 0775)

	e.writers = make(map[string]*os.File)
	e.headerWriters = make(map[string]*os.File)
	e.config = config
	e.wq = lib.NewWaitQuit("etl outputer", -1) //不限退出超时时间,以便etl能做完

	return e
}
Beispiel #2
0
//工厂初始化函数
func FileOutputerInit(buffer chan bytes.Buffer, saveDir string) (f fileOutputer) {

	f.buffer = buffer
	f.saveDir = saveDir
	f.dataDir = filepath.Join(saveDir, "log_data")
	f.headerDir = filepath.Join(saveDir, "headers")
	f.icDir = filepath.Join(saveDir, "received")
	f.ic = integrity.NewIntegrityChecker(f.icDir)

	os.MkdirAll(f.dataDir, 0775)
	os.MkdirAll(f.headerDir, 0775)

	f.writers = make(map[string]*os.File)
	f.headerWriters = make(map[string]*os.File)
	f.checkTime = time.Now().Add(2 * time.Minute)

	f.wq = lib.NewWaitQuit("file outputer", -1)
	return f
}