Alexey Kim 6 months ago
parent
commit
c9ecb6e300
4 changed files with 36 additions and 2 deletions
  1. 1 1
      Makefile
  2. 19 0
      clock.go
  3. 15 0
      strategy/clock_test.go
  4. 1 1
      version.go

+ 1 - 1
Makefile

@@ -25,7 +25,7 @@ all: gen deps fmt test
 gen:
 	-@echo "-> $@"
 	-@echo "=== Generate strategies"
-	$(foreach file, $(wildcard ./strategy/*.go), CGO_ENABLED=1 go build -ldflags=$(LDFLAGS) -buildmode=plugin -gcflags=$(GCFLAGS) -o $(file).so $(file);)
+	$(foreach file, $(filter-out $(wildcard ./strategy/*_test.go), $(wildcard ./strategy/*.go)), CGO_ENABLED=1 go build -ldflags=$(LDFLAGS) -buildmode=plugin -gcflags=$(GCFLAGS) -o $(file).so $(file);)
 
 .PHONY: deps
 deps:

+ 19 - 0
clock.go

@@ -0,0 +1,19 @@
+package sentio
+
+import "time"
+
+type Clock interface {
+	Now() time.Time
+	After(d time.Duration) <-chan time.Time
+}
+
+type ClockUTC struct {
+}
+
+func (t ClockUTC) Now() time.Time {
+	return time.Now().In(time.UTC)
+}
+
+func (t ClockUTC) After(d time.Duration) <-chan time.Time {
+	return time.After(d)
+}

+ 15 - 0
strategy/clock_test.go

@@ -0,0 +1,15 @@
+package main
+
+import "time"
+
+type ClockFixed struct {
+	fix time.Time
+}
+
+func (t ClockFixed) Now() time.Time {
+	return t.fix.In(time.UTC)
+}
+
+func (t ClockFixed) After(d time.Duration) <-chan time.Time {
+	return time.After(d)
+}

+ 1 - 1
version.go

@@ -1,3 +1,3 @@
 package sentio
 
-var VERSION = "0.0.0-dev"
+var Version = "0.0.0-dev"