func do(writer io.Writer, address string, documentRoot string, dbPath string) error { dbPath, err := io_util.NormalizePath(dbPath) if err != nil { return err } gracehttp.Serve(createServer(address, documentRoot, dbPath)) return nil }
func (c *configParser) ParseFileToConfig(config *debian_config.Config, path string) (*debian_config.Config, error) { var content []byte var err error if path, err = io_util.NormalizePath(path); err != nil { return nil, err } if content, err = ioutil.ReadFile(path); err != nil { glog.Warningf("read file %v failed: %v", path, err) return nil, err } return c.ParseContentToConfig(config, content) }
func readEntriesFromDb(dbPath string) ([]stats_entry.Entry, error) { var err error var entries []stats_entry.Entry dbPath, err = io_util.NormalizePath(dbPath) if err != nil { return nil, err } storage := stats_entry_storage.New(dbPath, false) if entries, err = storage.FindEntries(); err != nil { return nil, err } return entries, nil }
func do(writer io.Writer, dbPath string, valueString string) error { var err error dbPath, err = io_util.NormalizePath(dbPath) if err != nil { return err } var value int if value, err = strconv.Atoi(valueString); err != nil { return err } storage := stats_entry_storage.New(dbPath, false) timestamp := time.Now().UnixNano() entry := &stats_entry.Entry{Value: value, Timestamp: timestamp} return storage.CreateEntry(entry) }