func NewCounter(buckets int, resolution time.Duration, options ...rcOptSetter) (*RollingCounter, error) {
	if buckets <= 0 {
		return nil, fmt.Errorf("Buckets should be >= 0")
	}
	if resolution < time.Second {
		return nil, fmt.Errorf("Resolution should be larger than a second")
	}
	rc := &RollingCounter{
		lastBucket: -1,
		resolution: resolution,
		values: make([]int, buckets),
	}
	for _, o := range options {
		if err := o(rc); err != nil {
			return nil, err
		}
	}
	if rc.clock == nil {
		rc.clock = &timetools.RealTime{}
	}
	return rc, nil
}
NewCounter creates a counter with fixed amount of buckets that are rotated every resolution period.
E.g. 10 buckets with 1 second means that every new second the bucket is refreshed, so it maintains 10 second rolling window.
By default creates a bucket with 10 buckets and 1 second resolution
package memmetrics
import (
	"fmt"
	"time"
	"github.com/mailgun/timetools"
)
type rcOptSetter func(*RollingCounter) error
func CounterClock(c timetools.TimeProvider) rcOptSetter {
	return func(r *RollingCounter) error {
		r.clock = c
		return nil
	}
}
type RollingCounter struct {
	clock          timetools.TimeProvider
	resolution     time.Duration
	values         []int
	countedBuckets int  
	lastBucket     int  
	lastUpdated    time.Time
}