Runtime (#1160)
* Add String to Runtime interface * Setup Dynamic Runtime Configuration
This commit is contained in:
@@ -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
11
runtime/local/local.go
Normal 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...)
|
||||
}
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user