Added a new layer: engine (equivalent to use cases in Clean Architecture). Should make testing things easier

This commit is contained in:
Deluan 2016-03-07 10:57:32 -05:00
parent 56e9ad3def
commit 91c660c746
6 changed files with 91 additions and 39 deletions

View file

@ -11,7 +11,7 @@ var (
definitions map[reflect.Type]interface{}
)
func DefineSingleton(ptr interface{}, constructor interface{}, args ...interface{}) {
func DefineSingleton(ptr interface{}, constructor interface{}, args ...interface{}) interface{} {
typ := reflect.TypeOf(ptr)
provider := inject.NewProvider(constructor, args...)
@ -21,6 +21,7 @@ func DefineSingleton(ptr interface{}, constructor interface{}, args ...interface
definitions[typ] = ptr
}
Graph.Define(ptr, provider)
return ptr
}
func init() {

11
utils/time.go Normal file
View file

@ -0,0 +1,11 @@
package utils
import "time"
func ToTime(millis int64) time.Time {
return time.Unix(0, millis*int64(time.Millisecond))
}
func ToMillis(t time.Time) int64 {
return t.UnixNano() / int64(time.Millisecond)
}