-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from lytics/time-windowing
Adding a time windowed queue, so that we can support sliding windows.
- Loading branch information
Showing
8 changed files
with
474 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
language: go | ||
|
||
go: | ||
- 1.9.x | ||
- 1.10.x | ||
- master | ||
|
||
before_install: | ||
- go get -t -v ./... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package inflight | ||
|
||
import "time" | ||
|
||
// OpSet represents the set of Ops that have been merged in an OpQueue, | ||
// It provides convenience functions for appending new Ops and for completing them. | ||
type OpSet struct { | ||
set []*Op | ||
// used by the opWindow determine when it's ok to dequeue | ||
enqueuedAt time.Time | ||
} | ||
|
||
func newOpSet(op *Op) *OpSet { | ||
return &OpSet{ | ||
set: []*Op{op}, | ||
} | ||
} | ||
|
||
func (os *OpSet) append(op *Op) { | ||
os.set = append(os.set, op) | ||
} | ||
|
||
// Ops get the list of ops in this set. | ||
func (os *OpSet) Ops() []*Op { | ||
return os.set | ||
} | ||
|
||
// FinishAll a convenience func that calls finish on each Op in the set, passing the | ||
// results or error to all the Ops in the OpSet. | ||
// | ||
// NOTE: The call group that owns this OP will not call it's finish function until all | ||
// Ops are complete. And one callgroup could be spread over multiple op sets or | ||
// multiple op queues. | ||
func (os *OpSet) FinishAll(err error, resp interface{}) { | ||
for _, op := range os.set { | ||
op.Finish(err, resp) | ||
} | ||
} |
Oops, something went wrong.