Ejemplo n.º 1
0
func (r *Receiver) accept() {
	for req := range r.Inbox {
		rdr := bufio.NewReader(bytes.NewReader(req.Body))
		//TODO(ryandotsmith): Use a cached store time.
		// The code to use here should look something like this:
		// storeTime := r.Store.Now()
		// However, since we are in a tight loop here,
		// we cant make this call. Benchmarks show that using a local
		// redis and making the time call on the redis store will slow
		// down the receive loop by 10x.
		// However, we run the risk of accepting data that is past
		// its deadline due to clock drift on the localhost. Although
		// we don't run the risk of re-reporting an interval to Librato
		// because our outlet uses the store time to process buckets.
		// So even if we write a bucket to redis that is past the
		// deadline, our outlet scanner should not pick it up because
		// it uses redis time to find buckets to process.
		storeTime := time.Now()
		startParse := time.Now()
		for b := range parser.BuildBuckets(rdr, req.Opts, r.Mchan) {
			if b.Id.Delay(storeTime) <= r.deadline {
				r.inFlight.Add(1)
				r.addRegister(b)
			} else {
				r.Mchan.Measure("receiver.drop", 1)
			}
		}
		r.Mchan.Time("receiver.accept", startParse)
		r.inFlight.Done()
	}
}
Ejemplo n.º 2
0
func (r *Receiver) accept() {
	for lreq := range r.Inbox {
		rdr := bufio.NewReader(bytes.NewReader(lreq.Body))
		startParse := time.Now()
		for bucket := range parser.BuildBuckets(rdr, lreq.Opts) {
			if bucket.Id.Delay(time.Now()) <= r.deadline {
				r.addRegister(bucket)
			} else {
				r.Mchan.Measure("receiver.drop", 1)
			}
		}
		r.Mchan.Time("receiver.accept", startParse)
	}
}
Ejemplo n.º 3
0
func (r *Receiver) accept() {
	for lreq := range r.Inbox {
		rdr := bufio.NewReader(bytes.NewReader(lreq.Body))
		startParse := time.Now()
		for bucket := range parser.BuildBuckets(rdr, lreq.Opts) {
			now := time.Now().Truncate(bucket.Id.Resolution)
			if bucket.Id.Time.Equal(now) {
				r.addRegister(bucket)
			} else {
				fmt.Printf("at=receiver-drop b=%s n=%s\n",
					bucket.Id.Time, now)
			}
		}
		r.Mchan.Measure("receiver.accept", startParse)
	}
}