Exemplo n.º 1
0
func (s *SegmentPump) Init(config interface{}) error {
	s.segmentConf = &SegmentConf{}
	loadConfigErr := mapstructure.Decode(config, &s.segmentConf)

	if loadConfigErr != nil {
		log.WithFields(logrus.Fields{
			"prefix": segmentPrefix,
		}).Fatal("Failed to decode configuration: ", loadConfigErr)
	}

	s.segmentClient = segment.New(s.segmentConf.WriteKey)

	return nil
}
Exemplo n.º 2
0
func NewSegmentIOExporter(key string, size int) *SegmentIOExporter {
	client := analytics.New(key) // access token to authorize requests
	client.Size = size           // size of queue before flushing to api

	return &SegmentIOExporter{Client: client}
}