* Add String to Runtime interface

* Setup Dynamic Runtime Configuration
This commit is contained in:
ben-toogood
2020-02-05 13:59:35 +00:00
committed by GitHub
parent 4333f00a43
commit bf747a86f4
7 changed files with 50 additions and 1 deletions

View File

@@ -2,7 +2,9 @@
package kubernetes
import (
"errors"
"fmt"
"strings"
"sync"
"time"
@@ -245,6 +247,10 @@ func (k *kubernetes) Init(opts ...runtime.Option) error {
o(&k.options)
}
if strings.HasPrefix(k.options.Source, "github.com") {
return errors.New("invalid source provided to kubernetes runtime, expected docker image")
}
return nil
}

11
runtime/local/local.go Normal file
View File

@@ -0,0 +1,11 @@
// Package local provides a local runtime
package local
import (
"github.com/micro/go-micro/v2/runtime"
)
// NewRuntime returns a new local runtime
func NewRuntime(opts ...runtime.Option) runtime.Runtime {
return runtime.NewRuntime(opts...)
}

View File

@@ -12,6 +12,15 @@ type Options struct {
Scheduler Scheduler
// Service type to manage
Type string
// Source of the services repository
Source string
}
// WithSource sets the host addresses to be used by the broker
func WithSource(src string) Option {
return func(o *Options) {
o.Source = src
}
}
// WithScheduler specifies a scheduler for updates

View File

@@ -17,6 +17,8 @@ var (
// Runtime is a service runtime manager
type Runtime interface {
// String describes runtime
String() string
// Init initializes runtime
Init(...Option) error
// Create registers a service

View File

@@ -170,6 +170,8 @@ func (s *service) Wait() {
s.Metadata["status"] = "error"
s.Metadata["error"] = err.Error()
s.err = err
} else {
s.Metadata["status"] = "done"
}
// no longer running