* First commit: outline of K8s runtime package * Added poller. Added auto-updater into default runtime * Added build and updated Poller interface * Added comments and NewRuntime that accepts Options * DefaultPoller; Runtime options * First commit to add Kubernetes cruft * Add comments * Add micro- prefix to K8s runtime service names * Get rid of import cycles. Move K8s runtime into main runtime package * Major refactoring: Poller replaced by Notifier POller has been replaced by Notifier which returns a channel of events that can be consumed and acted upon. * Added runtime configuration options * K8s runtime is now Kubernetes runtime in dedicated pkg. Naming kung-fu. * Fix typo in command. * Fixed typo * Dont Delete service when runtime stops. runtime.Stop stops services; no need to double-stop * Track runtime services * Parse Unix timestamps properly * Added deployments into K8s client. Debug logging
		
			
				
	
	
		
			148 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			148 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package cmd
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
 | 
						|
	"github.com/micro/go-micro/broker"
 | 
						|
	"github.com/micro/go-micro/client"
 | 
						|
	"github.com/micro/go-micro/client/selector"
 | 
						|
	"github.com/micro/go-micro/registry"
 | 
						|
	"github.com/micro/go-micro/runtime"
 | 
						|
	"github.com/micro/go-micro/server"
 | 
						|
	"github.com/micro/go-micro/transport"
 | 
						|
)
 | 
						|
 | 
						|
type Options struct {
 | 
						|
	// For the Command Line itself
 | 
						|
	Name        string
 | 
						|
	Description string
 | 
						|
	Version     string
 | 
						|
 | 
						|
	// We need pointers to things so we can swap them out if needed.
 | 
						|
	Broker    *broker.Broker
 | 
						|
	Registry  *registry.Registry
 | 
						|
	Selector  *selector.Selector
 | 
						|
	Transport *transport.Transport
 | 
						|
	Client    *client.Client
 | 
						|
	Server    *server.Server
 | 
						|
	Runtime   *runtime.Runtime
 | 
						|
 | 
						|
	Brokers    map[string]func(...broker.Option) broker.Broker
 | 
						|
	Clients    map[string]func(...client.Option) client.Client
 | 
						|
	Registries map[string]func(...registry.Option) registry.Registry
 | 
						|
	Selectors  map[string]func(...selector.Option) selector.Selector
 | 
						|
	Servers    map[string]func(...server.Option) server.Server
 | 
						|
	Transports map[string]func(...transport.Option) transport.Transport
 | 
						|
	Runtimes   map[string]func(...runtime.Option) runtime.Runtime
 | 
						|
 | 
						|
	// Other options for implementations of the interface
 | 
						|
	// can be stored in a context
 | 
						|
	Context context.Context
 | 
						|
}
 | 
						|
 | 
						|
// Command line Name
 | 
						|
func Name(n string) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Name = n
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// Command line Description
 | 
						|
func Description(d string) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Description = d
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// Command line Version
 | 
						|
func Version(v string) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Version = v
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func Broker(b *broker.Broker) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Broker = b
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func Selector(s *selector.Selector) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Selector = s
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func Registry(r *registry.Registry) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Registry = r
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func Transport(t *transport.Transport) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Transport = t
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func Client(c *client.Client) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Client = c
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func Server(s *server.Server) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Server = s
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// New broker func
 | 
						|
func NewBroker(name string, b func(...broker.Option) broker.Broker) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Brokers[name] = b
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// New client func
 | 
						|
func NewClient(name string, b func(...client.Option) client.Client) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Clients[name] = b
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// New registry func
 | 
						|
func NewRegistry(name string, r func(...registry.Option) registry.Registry) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Registries[name] = r
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// New selector func
 | 
						|
func NewSelector(name string, s func(...selector.Option) selector.Selector) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Selectors[name] = s
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// New server func
 | 
						|
func NewServer(name string, s func(...server.Option) server.Server) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Servers[name] = s
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// New transport func
 | 
						|
func NewTransport(name string, t func(...transport.Option) transport.Transport) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Transports[name] = t
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// New runtime func
 | 
						|
func NewRuntime(name string, r func(...runtime.Option) runtime.Runtime) Option {
 | 
						|
	return func(o *Options) {
 | 
						|
		o.Runtimes[name] = r
 | 
						|
	}
 | 
						|
}
 |