minor fixes

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-07-01 15:56:22 +03:00
parent eb107020c7
commit c592fabe2a
3 changed files with 18 additions and 3 deletions

View File

@ -32,7 +32,7 @@ func TestMemoryBroker(t *testing.T) {
"foo": "bar", "foo": "bar",
"id": fmt.Sprintf("%d", i), "id": fmt.Sprintf("%d", i),
}, },
Body: []byte(`hello world`), Body: []byte(`"hello world"`),
} }
if err := b.Publish(ctx, topic, message); err != nil { if err := b.Publish(ctx, topic, message); err != nil {

View File

@ -43,13 +43,13 @@ type Watcher interface {
} }
// Load loads config from config sources // Load loads config from config sources
func Load(ctx context.Context, cs ...Config) error { func Load(ctx context.Context, cs []Config, opts ...LoadOption) error {
var err error var err error
for _, c := range cs { for _, c := range cs {
if err = c.Init(); err != nil { if err = c.Init(); err != nil {
return err return err
} }
if err = c.Load(ctx); err != nil { if err = c.Load(ctx, opts...); err != nil {
return err return err
} }
} }

15
util/fn/fn.go Normal file
View File

@ -0,0 +1,15 @@
package fn
type Initer interface {
Init(opts ...interface{}) error
}
func Init(ifaces ...Initer) error {
var err error
for _, iface := range ifaces {
if err = iface.Init(); err != nil {
return err
}
}
return nil
}