Exemplo n.º 1
0
// Returns packet receiver object
func NewWorkerReceiver(storage storage.Storage) *WorkerReceiver {
	addr, err := config.Instance().String("receiver", "addr")
	cli.CheckError(err)

	reader, err := gelf.NewReader(addr)
	cli.CheckError(err)

	return &WorkerReceiver{
		storage: storage,
		reader:  reader,
	}
}
Exemplo n.º 2
0
func initConfig(paths []string) {
	if len(paths) == 1 {
		once.Do(func() {
			var err error

			conf, err = c.ReadDefault(paths[0])
			hc.CheckError(err)
		})
	}
}
Exemplo n.º 3
0
// Returns HTTP server object
func NewWorkerHttp(storage storage.Storage) *WorkerHttp {
	addr, err := config.Instance().String("http", "addr")
	cli.CheckError(err)

	maxPerPage, err := config.Instance().Int("http", "max_per_page")
	if err != nil || maxPerPage <= 0 {
		maxPerPage = 100
	}

	maxResults, err := config.Instance().Int("http", "max_results")
	if err != nil || maxPerPage <= 0 {
		maxResults = 1000
	}

	return &WorkerHttp{
		addr:       addr,
		maxPerPage: maxPerPage,
		maxResults: maxResults,
		storage:    storage,
	}
}