Implementation has unit name

This commit is contained in:
2015-02-11 19:33:46 +07:00
parent 9e472cc9a3
commit 7f552e5c8a
4 changed files with 9 additions and 6 deletions
+2 -1
View File
@@ -2,8 +2,9 @@ package impl
// Implementation of a echo unit
// Comes handy when you need to mock a unit
func Echo() *Impl {
func Echo(name string) *Impl {
return &Impl{
name: name,
actor: func(data []byte) (resp []byte, err error) {
return data, nil
},
+4 -3
View File
@@ -2,14 +2,15 @@ package impl
type (
Impl struct {
name string
actor func([]byte) ([]byte, error)
}
)
func New(name string) *Impl {
switch name {
func New(name, impl string) *Impl {
switch impl {
case "units.throttler.Throttler":
return Throttler()
return Throttler(name)
default:
return nil
}
+2 -1
View File
@@ -1,7 +1,8 @@
package impl
func Throttler() *Impl {
func Throttler(name string) *Impl {
return &Impl{
name: name,
actor: func(data []byte) (resp []byte, err error) {
return data, nil
},