Bump reva deps (#8412)
* bump dependencies Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * bump reva and add config options Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> --------- Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
+20
-23
@@ -13,30 +13,29 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/nxadm/tail"
|
||||
|
||||
log "go-micro.dev/v4/logger"
|
||||
"go-micro.dev/v4/runtime/local/git"
|
||||
)
|
||||
|
||||
// defaultNamespace to use if not provided as an option
|
||||
// defaultNamespace to use if not provided as an option.
|
||||
const defaultNamespace = "default"
|
||||
|
||||
type runtime struct {
|
||||
sync.RWMutex
|
||||
// options configure runtime
|
||||
options *Options
|
||||
// used to stop the runtime
|
||||
closed chan bool
|
||||
// used to start new services
|
||||
start chan *service
|
||||
// indicates if we're running
|
||||
running bool
|
||||
// namespaces stores services grouped by namespace, e.g. namespaces["foo"]["go.micro.auth:latest"]
|
||||
// would return the latest version of go.micro.auth from the foo namespace
|
||||
namespaces map[string]map[string]*service
|
||||
sync.RWMutex
|
||||
// indicates if we're running
|
||||
running bool
|
||||
}
|
||||
|
||||
// NewRuntime creates new local runtime and returns it
|
||||
// NewRuntime creates new local runtime and returns it.
|
||||
func NewRuntime(opts ...Option) Runtime {
|
||||
// get default options
|
||||
options := NewOptions(opts...)
|
||||
@@ -53,7 +52,7 @@ func NewRuntime(opts ...Option) Runtime {
|
||||
}
|
||||
}
|
||||
|
||||
// @todo move this to runtime default
|
||||
// @todo move this to runtime default.
|
||||
func (r *runtime) checkoutSourceIfNeeded(s *Service) error {
|
||||
// Runtime service like config have no source.
|
||||
// Skip checkout in that case
|
||||
@@ -131,7 +130,6 @@ func uncompress(src string, dst string) error {
|
||||
|
||||
// check the type
|
||||
switch header.Typeflag {
|
||||
|
||||
// if its a dir and it doesn't exist create it (with 0755 permission)
|
||||
case tar.TypeDir:
|
||||
if _, err := os.Stat(target); err != nil {
|
||||
@@ -162,7 +160,7 @@ func uncompress(src string, dst string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// check for path traversal and correct forward slashes
|
||||
// check for path traversal and correct forward slashes.
|
||||
func validRelPath(p string) bool {
|
||||
if p == "" || strings.Contains(p, `\`) || strings.HasPrefix(p, "/") || strings.Contains(p, "../") {
|
||||
return false
|
||||
@@ -170,7 +168,7 @@ func validRelPath(p string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Init initializes runtime options
|
||||
// Init initializes runtime options.
|
||||
func (r *runtime) Init(opts ...Option) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
@@ -182,7 +180,7 @@ func (r *runtime) Init(opts ...Option) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// run runs the runtime management loop
|
||||
// run runs the runtime management loop.
|
||||
func (r *runtime) run(events <-chan Event) {
|
||||
t := time.NewTicker(time.Second * 5)
|
||||
defer t.Stop()
|
||||
@@ -306,7 +304,7 @@ func serviceKey(s *Service) string {
|
||||
return fmt.Sprintf("%v:%v", s.Name, s.Version)
|
||||
}
|
||||
|
||||
// Create creates a new service which is then started by runtime
|
||||
// Create creates a new service which is then started by runtime.
|
||||
func (r *runtime) Create(s *Service, opts ...CreateOption) error {
|
||||
err := r.checkoutSourceIfNeeded(s)
|
||||
if err != nil {
|
||||
@@ -357,7 +355,7 @@ func (r *runtime) Create(s *Service, opts ...CreateOption) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// exists returns whether the given file or directory exists
|
||||
// exists returns whether the given file or directory exists.
|
||||
func exists(path string) (bool, error) {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
@@ -431,19 +429,18 @@ func (r *runtime) Logs(s *Service, options ...LogsOption) (LogStream, error) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}()
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
type logStream struct {
|
||||
err error
|
||||
logger log.Logger
|
||||
tail *tail.Tail
|
||||
service string
|
||||
stream chan LogRecord
|
||||
stop chan bool
|
||||
service string
|
||||
sync.Mutex
|
||||
stop chan bool
|
||||
err error
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
func (l *logStream) Chan() chan LogRecord {
|
||||
@@ -516,7 +513,7 @@ func (r *runtime) Read(opts ...ReadOption) ([]*Service, error) {
|
||||
return services, nil
|
||||
}
|
||||
|
||||
// Update attempts to update the service
|
||||
// Update attempts to update the service.
|
||||
func (r *runtime) Update(s *Service, opts ...UpdateOption) error {
|
||||
var options UpdateOptions
|
||||
for _, o := range opts {
|
||||
@@ -553,7 +550,7 @@ func (r *runtime) Update(s *Service, opts ...UpdateOption) error {
|
||||
return service.Start()
|
||||
}
|
||||
|
||||
// Delete removes the service from the runtime and stops it
|
||||
// Delete removes the service from the runtime and stops it.
|
||||
func (r *runtime) Delete(s *Service, opts ...DeleteOption) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
@@ -594,7 +591,7 @@ func (r *runtime) Delete(s *Service, opts ...DeleteOption) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start starts the runtime
|
||||
// Start starts the runtime.
|
||||
func (r *runtime) Start() error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
@@ -623,7 +620,7 @@ func (r *runtime) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop stops the runtime
|
||||
// Stop stops the runtime.
|
||||
func (r *runtime) Stop() error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
@@ -658,7 +655,7 @@ func (r *runtime) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// String implements stringer interface
|
||||
// String implements stringer interface.
|
||||
func (r *runtime) String() string {
|
||||
return "local"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user