Exemple #1
0
// Open create new tsdb with root directory
func Open(filepath string) (DataSource, error) {

	if !fs.Exists(filepath) {
		err := os.MkdirAll(filepath, 0644)
		if err != nil {
			return nil, err
		}
	}

	idgen, err := newSEQIDGen(filepath)

	if err != nil {
		return nil, err
	}

	persistence, err := newDB(filepath)

	if err != nil {
		return nil, err
	}

	return &_DataSource{
		Log:         gslogger.Get("tsdb"),
		SEQIDGen:    idgen,
		Persistence: persistence,
		cached:      make(map[string]*_Cached),
		cachedsize:  gsconfig.Int("tsdb.cached.size", 1024),
	}, nil
}
Exemple #2
0
// BuildPipeline creaet new pipeline builder
func BuildPipeline(timerTick time.Duration) *PipelineBuilder {
	return &PipelineBuilder{
		timeout:    gsconfig.Seconds("gorpc.timeout", 5),
		cachedsize: gsconfig.Int("gorpc.sendQ", 1024),
		timewheel:  timer.NewWheel(timerTick),
	}
}
Exemple #3
0
// BuildAgent .
func BuildAgent(system System) *AgentBuilder {
	return &AgentBuilder{
		system:     system,
		cachedsize: gsconfig.Int("gsagent.rpc.sendQ", 1024),
		timeout:    gsconfig.Seconds("gsagent.rpc.timeout", 5),
		reconnect:  gsconfig.Seconds("gsagent.reconnect.delay", 5),
	}
}
Exemple #4
0
func newDB(dir string) (Persistence, error) {
	db, err := leveldb.OpenFile(filepath.Join(dir, "keyspace.db"), nil)

	if err != nil {
		return nil, err
	}

	return &_DB{
		Log:      gslogger.Get("tsdb.backend"),
		db:       db,
		storages: make(map[string]Storage),
		valen:    gsconfig.Int("tsdb.value.length", 1024),
	}, nil
}