Skip to content

Commit

Permalink
Add missing godoc
Browse files Browse the repository at this point in the history
  • Loading branch information
rs committed Mar 9, 2018
1 parent cb5c1d0 commit cb27111
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions aggr/aggr.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package aggr provides aggregation primitives for jaggr.
package aggr

import (
Expand Down
6 changes: 6 additions & 0 deletions aggr/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ type Field struct {
Aggrs map[string]Aggregator
}

// Fields holds a set of aggregation fields
type Fields struct {
f []Field
mu sync.Mutex
}

// NewFields parses defs and create aggregation fields.
func NewFields(defs []string) (*Fields, error) {
fields := make([]Field, 0, len(defs))
for _, def := range defs {
Expand All @@ -33,6 +35,7 @@ func NewFields(defs []string) (*Fields, error) {
return &Fields{f: fields}, nil
}

// Push pushes new pre-parsed JSON data to the aggregations.
func (fs *Fields) Push(jq *gojq.JQ) error {
fs.mu.Lock()
defer fs.mu.Unlock()
Expand All @@ -44,6 +47,7 @@ func (fs *Fields) Push(jq *gojq.JQ) error {
return nil
}

// Aggr gets and flush aggregated data.
func (fs *Fields) Aggr() map[string]interface{} {
fs.mu.Lock()
defer fs.mu.Unlock()
Expand Down Expand Up @@ -89,6 +93,7 @@ func NewField(def string) (Field, error) {
return f, nil
}

// Push pushes new pre-parsed JSON data to the aggregations.
func (f *Field) Push(jq *gojq.JQ) error {
v, err := jq.Query(f.Path)
if err != nil {
Expand All @@ -102,6 +107,7 @@ func (f *Field) Push(jq *gojq.JQ) error {
return nil
}

// Aggr gets and flush aggregated data.
func (f *Field) Aggr() interface{} {
if f.Path == "." && f.Aggrs[""] != nil {
// Count special field
Expand Down

0 comments on commit cb27111

Please sign in to comment.