From 4677b9c7e1991af2dab3b1a44440feabe4d326a0 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Wed, 25 May 2016 15:40:25 -0500 Subject: [PATCH] Added a channel version.. --- flake.go | 20 ++++++++++++++++++++ flake_test.go | 14 ++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/flake.go b/flake.go index b205fd2..bb0e5ed 100644 --- a/flake.go +++ b/flake.go @@ -54,8 +54,28 @@ func NewFlakeNode(node int64) (*Node, error) { } // high performance generator +// well, that w as the idea... func (n *Node) Generator(c chan Flake) { + ticker := time.NewTicker(time.Millisecond) + now := int64(time.Now().UnixNano() / 1000000) + for { + + n.step = 0 + + select { + case c <- Flake((now-n.epoch)<