コード例 #1
0
ファイル: service.go プロジェクト: rwarren/influxdb
// NewService returns an instance of the Graphite service.
func NewService(c Config) (*Service, error) {
	// Use defaults where necessary.
	d := c.WithDefaults()

	s := Service{
		bindAddress:    d.BindAddress,
		database:       d.Database,
		protocol:       d.Protocol,
		batchSize:      d.BatchSize,
		batchPending:   d.BatchPending,
		udpReadBuffer:  d.UDPReadBuffer,
		batchTimeout:   time.Duration(d.BatchTimeout),
		logger:         log.New(os.Stderr, "[graphite] ", log.LstdFlags),
		tcpConnections: make(map[string]*tcpConnection),
		done:           make(chan struct{}),
	}

	consistencyLevel, err := cluster.ParseConsistencyLevel(d.ConsistencyLevel)
	if err != nil {
		return nil, err
	}
	s.consistencyLevel = consistencyLevel

	parser, err := NewParserWithOptions(Options{
		Templates:   d.Templates,
		DefaultTags: d.DefaultTags(),
		Separator:   d.Separator})

	if err != nil {
		return nil, err
	}
	s.parser = parser

	return &s, nil
}
コード例 #2
0
ファイル: cli.go プロジェクト: rwarren/influxdb
// SetWriteConsistency sets cluster consistency level
func (c *CommandLine) SetWriteConsistency(cmd string) {
	// Remove the "consistency" keyword if it exists
	cmd = strings.TrimSpace(strings.Replace(cmd, "consistency", "", -1))
	// normalize cmd
	cmd = strings.ToLower(cmd)

	_, err := cluster.ParseConsistencyLevel(cmd)
	if err != nil {
		fmt.Printf("Unknown consistency level %q. Please use any, one, quorum, or all.\n", cmd)
		return
	}
	c.WriteConsistency = cmd
}
コード例 #3
0
ファイル: service.go プロジェクト: hawson/influxdb
// NewService returns a new instance of Service.
func NewService(c Config) (*Service, error) {
	consistencyLevel, err := cluster.ParseConsistencyLevel(c.ConsistencyLevel)
	if err != nil {
		return nil, err
	}

	s := &Service{
		done:             make(chan struct{}),
		tls:              c.TLSEnabled,
		cert:             c.Certificate,
		err:              make(chan error),
		BindAddress:      c.BindAddress,
		Database:         c.Database,
		RetentionPolicy:  c.RetentionPolicy,
		ConsistencyLevel: consistencyLevel,
		batchSize:        c.BatchSize,
		batchPending:     c.BatchPending,
		batchTimeout:     time.Duration(c.BatchTimeout),
		Logger:           log.New(os.Stderr, "[opentsdb] ", log.LstdFlags),
		LogPointErrors:   c.LogPointErrors,
	}
	return s, nil
}