Implementation has unit name
This commit is contained in:
+2
-1
@@ -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
@@ -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
@@ -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
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user