init micro runtime separately

This commit is contained in:
A.Unger
2019-12-17 14:40:39 +01:00
parent 93e17ea4f7
commit 819e8dc82d
5 changed files with 244 additions and 122 deletions
+48
View File
@@ -0,0 +1,48 @@
package runtime
import (
gorun "github.com/micro/go-micro/runtime"
"github.com/owncloud/ocis-pkg/log"
)
// Options is a runtime option
type Options struct {
Services []string
Logger log.Logger
MicroRuntime *gorun.Runtime
}
// Option undocummented
type Option func(o *Options)
// newOptions initializes the available default options.
func newOptions(opts ...Option) Options {
opt := Options{}
for _, o := range opts {
o(&opt)
}
return opt
}
// Services option
func Services(s []string) Option {
return func(o *Options) {
o.Services = append(o.Services, s...)
}
}
// Logger option
func Logger(l log.Logger) Option {
return func(o *Options) {
o.Logger = l
}
}
// MicroRuntime option
func MicroRuntime(rt *gorun.Runtime) Option {
return func(o *Options) {
o.MicroRuntime = rt
}
}