Documentation ¶
Index ¶
- Variables
- type Entry
- type Period
- type Periods
- type TimeAggregator
- func (a *TimeAggregator) Add(date time.Time, value int64)
- func (a *TimeAggregator) Entries() ([]Entry, error)
- func (a *TimeAggregator) Get(date time.Time) int64
- func (a *TimeAggregator) GetBSON() (interface{}, error)
- func (a *TimeAggregator) GobDecode(body []byte) error
- func (a *TimeAggregator) GobEncode() ([]byte, error)
- func (a *TimeAggregator) Marshal() []byte
- func (a *TimeAggregator) MarshalJSON() ([]byte, error)
- func (a *TimeAggregator) SetBSON(raw bson.Raw) error
- func (a *TimeAggregator) String() string
- func (a *TimeAggregator) Sum(b *TimeAggregator) error
- func (a *TimeAggregator) Unmarshal(v []byte) error
- type Unit
Constants ¶
This section is empty.
Variables ¶
var ( InvalidOrderError = errors.New("Invalid order of time units") UnitsMismatch = errors.New("Units mismatch") )
Functions ¶
This section is empty.
Types ¶
type Period ¶
type Period uint64
type TimeAggregator ¶
type TimeAggregator struct { Values map[Period]*aggregator // contains filtered or unexported fields }
func NewTimeAggregator ¶
func NewTimeAggregator(units ...Unit) (*TimeAggregator, error)
NewTimeAggregator returns a new TimeAggregator configured with the given units, InvalidOrderError is return if the units are not sorted
func (*TimeAggregator) Add ¶
func (a *TimeAggregator) Add(date time.Time, value int64)
Add sum a value to the correct count using date
func (*TimeAggregator) Entries ¶
func (a *TimeAggregator) Entries() ([]Entry, error)
Entries return a list of Entry structs with non-zero values
func (*TimeAggregator) Get ¶
func (a *TimeAggregator) Get(date time.Time) int64
Get returns the count for the given date
func (*TimeAggregator) GetBSON ¶
func (a *TimeAggregator) GetBSON() (interface{}, error)
GetBSON implements bson.Setter, marshall the a TimeAggregator to a string ussing TimeAggregator.Marshal
func (*TimeAggregator) GobDecode ¶
func (a *TimeAggregator) GobDecode(body []byte) error
func (*TimeAggregator) GobEncode ¶
func (a *TimeAggregator) GobEncode() ([]byte, error)
func (*TimeAggregator) Marshal ¶
func (a *TimeAggregator) Marshal() []byte
Marshal returns a binary representation of TimeAggregator
func (*TimeAggregator) MarshalJSON ¶
func (a *TimeAggregator) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler, creates a JSON representation of the aggregator.
func (*TimeAggregator) SetBSON ¶
func (a *TimeAggregator) SetBSON(raw bson.Raw) error
SetBSON implements bson.Setter, unmarshals a bson.Raw into a TimeAggregator
func (*TimeAggregator) String ¶
func (a *TimeAggregator) String() string
func (*TimeAggregator) Sum ¶
func (a *TimeAggregator) Sum(b *TimeAggregator) error
Sum sum a TimeAggregator to other, if the units are diferent UnitsMismatch error is returned
func (*TimeAggregator) Unmarshal ¶
func (a *TimeAggregator) Unmarshal(v []byte) error
Unmarshal a binary string into a TimeAggregator, units and values are restored