func (b *InjectionStreamer) WriteInjections(p []apimodel.Injection) (s *InjectionStreamer, err error) {
	s = newInjectionStreamerDuration(b.head, b.startTime, b.wr, b.d)
	if err != nil {
		return s, err
	}
	for i := range p {
		c := p[i]
		t := c.GetTime()
		truncatedTime := t.Truncate(s.d)
		if s.head == nil {
			s = newInjectionStreamerDuration(container.NewImmutableList(nil, c), &truncatedTime, s.wr, s.d)
		} else if t.Sub(*s.startTime) >= s.d {
			s, err = s.Flush()
			if err != nil {
				return s, err
			}
			s = newInjectionStreamerDuration(container.NewImmutableList(nil, c), &truncatedTime, s.wr, s.d)
		} else {
			s = newInjectionStreamerDuration(container.NewImmutableList(s.head, c), s.startTime, s.wr, s.d)
		}
	}
	return s, err
}
WriteInjections writes the contents of p into the buffer.
It returns the number of bytes written.
If nn < len(p), it also returns an error explaining
why the write is short. p must be sorted by time (oldest to most recent).
package streaming
import (
	"github.com/alexandre-normand/glukit/app/apimodel"
	"github.com/alexandre-normand/glukit/app/container"
	"github.com/alexandre-normand/glukit/app/glukitio"
	"time"
)
type InjectionStreamer struct {
	head      *container.ImmutableList
	startTime *time.Time
	wr        glukitio.InjectionBatchWriter
	d         time.Duration
}
func NewInjectionStreamerDuration(wr glukitio.InjectionBatchWriter, bufferDuration time.Duration) *InjectionStreamer {
	return newInjectionStreamerDuration(nil, nil, wr, bufferDuration)
}
func newInjectionStreamerDuration(head *container.ImmutableList, startTime *time.Time, wr glukitio.InjectionBatchWriter, bufferDuration time.Duration) *InjectionStreamer {
	w := new(InjectionStreamer)
	w.head = head
	w.startTime = startTime
	w.wr = wr
	w.d = bufferDuration
	return w
}
func (b *InjectionStreamer) WriteInjection(c apimodel.Injection) (s *InjectionStreamer, err error) {
	return b.WriteInjections([]apimodel.Injection{c})
}