func WithWindowWidth(w time.Duration) WindowOption {
	return windowOptionFunc(func(c *windowConfig) {
		c.width = w
	})
}
WithWindowWidth sets the width (end-start=width) of the query. It defaults
to an hour.
package client
import (
	"context"
	"io/ioutil"
	"log"
	"time"
	"code.cloudfoundry.org/go-loggregator/rpc/loggregator_v2"
)
func Window(ctx context.Context, v Visitor, w Walker, opts ...WindowOption) {
	c := windowConfig{
		log:      log.New(ioutil.Discard, "", 0),
		width:    time.Hour,
		interval: time.Minute,
	}
	for _, o := range opts {
		o.configure(&c)
	}
	if c.start.IsZero() {
		c.start = time.Now().Add(-c.width)
	}
	ticker := time.NewTicker(c.interval)
	defer ticker.Stop()
	for range ticker.C {
		walkCtx, cancel := context.WithTimeout(ctx, c.interval)
		es := w(walkCtx, c.start, c.start.Add(c.width))
		cancel()
		if !v(es) {
			return
		}
		c.start = c.start.Add(c.interval)
	}
}
type Walker func(
	ctx context.Context,
	start time.Time,
	end time.Time,
) []*loggregator_v2.Envelope
func BuildWalker(sourceID string, r Reader) Walker {
	return func(ctx context.Context, start, end time.Time) []*loggregator_v2.Envelope {
		var results []*loggregator_v2.Envelope
		Walk(ctx, sourceID, func(e []*loggregator_v2.Envelope) bool {
			results = append(results, e...)
			return true
		}, r,
			WithWalkStartTime(start),
			WithWalkEndTime(end),
		)
		return results
	}
}
type WindowOption interface {
	configure(*windowConfig)
}
func WithWindowLogger(l *log.Logger) WindowOption {
	return windowOptionFunc(func(c *windowConfig) {
		c.log = l
	})
}
func WithWindowStartTime(t time.Time) WindowOption {
	return windowOptionFunc(func(c *windowConfig) {
		c.start = t
	})
}