Merge pull request #1000 from micro/runtime-type

Support service types in runtime
This commit is contained in:
Asim Aslam 2019-11-29 11:46:21 +00:00 committed by GitHub
commit 8b6475b8d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 171 additions and 164 deletions

View File

@ -163,7 +163,7 @@ func (r *runtime) Create(s *Service, opts ...CreateOption) error {
o(&options) o(&options)
} }
if len(s.Exec) == 0 && len(options.Command) == 0 { if len(options.Command) == 0 {
return errors.New("missing exec command") return errors.New("missing exec command")
} }
@ -179,31 +179,36 @@ func (r *runtime) Create(s *Service, opts ...CreateOption) error {
// Read returns all instances of requested service // Read returns all instances of requested service
// If no service name is provided we return all the track services. // If no service name is provided we return all the track services.
func (r *runtime) Read(name string, opts ...ReadOption) ([]*Service, error) { func (r *runtime) Read(opts ...ReadOption) ([]*Service, error) {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
if len(name) == 0 {
return nil, errors.New("missing service name")
}
gopts := ReadOptions{} gopts := ReadOptions{}
for _, o := range opts { for _, o := range opts {
o(&gopts) o(&gopts)
} }
save := func(k, v string) bool {
if len(k) == 0 {
return true
}
return k == v
}
var services []*Service var services []*Service
// if we track the service check if the version is provided
if s, ok := r.services[name]; ok { for _, service := range r.services {
if len(gopts.Version) > 0 { if !save(gopts.Service, service.Name) {
if s.Version == gopts.Version { continue
services = append(services, s.Service)
} }
return services, nil if !save(gopts.Version, service.Version) {
continue
} }
// TODO deal with service type
// no version has sbeen requested, just append the service // no version has sbeen requested, just append the service
services = append(services, s.Service) services = append(services, service.Service)
} }
return services, nil return services, nil
} }

View File

@ -27,13 +27,13 @@ type Kubernetes interface {
} }
// NewService returns default micro kubernetes service definition // NewService returns default micro kubernetes service definition
func NewService(name, version string) *Service { func NewService(name, version, typ string) *Service {
log.Tracef("kubernetes default service: name: %s, version: %s", name, version) log.Tracef("kubernetes default service: name: %s, version: %s", name, version)
Labels := map[string]string{ Labels := map[string]string{
"name": name, "name": name,
"version": version, "version": version,
"micro": "service", "micro": typ,
} }
svcName := name svcName := name
@ -64,13 +64,13 @@ func NewService(name, version string) *Service {
} }
// NewService returns default micro kubernetes deployment definition // NewService returns default micro kubernetes deployment definition
func NewDeployment(name, version string) *Deployment { func NewDeployment(name, version, typ string) *Deployment {
log.Tracef("kubernetes default deployment: name: %s, version: %s", name, version) log.Tracef("kubernetes default deployment: name: %s, version: %s", name, version)
Labels := map[string]string{ Labels := map[string]string{
"name": name, "name": name,
"version": version, "version": version,
"micro": "service", "micro": typ,
} }
depName := name depName := name

View File

@ -8,16 +8,17 @@ import (
func TestTemplates(t *testing.T) { func TestTemplates(t *testing.T) {
name := "foo" name := "foo"
version := "123" version := "123"
typ := "service"
// Render default service // Render default service
s := NewService(name, version) s := NewService(name, version, typ)
bs := new(bytes.Buffer) bs := new(bytes.Buffer)
if err := renderTemplate(templates["service"], bs, s); err != nil { if err := renderTemplate(templates["service"], bs, s); err != nil {
t.Errorf("Failed to render kubernetes service: %v", err) t.Errorf("Failed to render kubernetes service: %v", err)
} }
// Render default deployment // Render default deployment
d := NewDeployment(name, version) d := NewDeployment(name, version, typ)
bd := new(bytes.Buffer) bd := new(bytes.Buffer)
if err := renderTemplate(templates["deployment"], bd, d); err != nil { if err := renderTemplate(templates["deployment"], bd, d); err != nil {
t.Errorf("Failed to render kubernetes deployment: %v", err) t.Errorf("Failed to render kubernetes deployment: %v", err)

View File

@ -2,7 +2,6 @@
package kubernetes package kubernetes
import ( import (
"errors"
"fmt" "fmt"
"sync" "sync"
"time" "time"
@ -204,7 +203,7 @@ func (k *kubernetes) run(events <-chan runtime.Event) {
// set the default labels // set the default labels
labels := map[string]string{ labels := map[string]string{
"micro": "service", "micro": k.options.Type,
"name": name, "name": name,
} }
@ -281,7 +280,9 @@ func (k *kubernetes) Create(s *runtime.Service, opts ...runtime.CreateOption) er
k.Lock() k.Lock()
defer k.Unlock() defer k.Unlock()
var options runtime.CreateOptions options := runtime.CreateOptions{
Type: k.options.Type,
}
for _, o := range opts { for _, o := range opts {
o(&options) o(&options)
} }
@ -310,22 +311,13 @@ func (k *kubernetes) Create(s *runtime.Service, opts ...runtime.CreateOption) er
} }
// Read returns all instances of given service // Read returns all instances of given service
func (k *kubernetes) Read(name string, opts ...runtime.ReadOption) ([]*runtime.Service, error) { func (k *kubernetes) Read(opts ...runtime.ReadOption) ([]*runtime.Service, error) {
k.Lock() k.Lock()
defer k.Unlock() defer k.Unlock()
// if no name has been passed in, return error
if len(name) == 0 {
return nil, errors.New("missing service name")
}
// format the name
name = client.Format(name)
// set the default labels // set the default labels
labels := map[string]string{ labels := map[string]string{
"micro": "service", "micro": k.options.Type,
"name": name,
} }
var options runtime.ReadOptions var options runtime.ReadOptions
@ -333,12 +325,18 @@ func (k *kubernetes) Read(name string, opts ...runtime.ReadOption) ([]*runtime.S
o(&options) o(&options)
} }
if len(options.Service) > 0 {
labels["name"] = client.Format(options.Service)
}
// add version to labels if a version has been supplied // add version to labels if a version has been supplied
if len(options.Version) > 0 { if len(options.Version) > 0 {
labels["version"] = options.Version labels["version"] = options.Version
} }
log.Debugf("Runtime querying service %s", name) if len(options.Type) > 0 {
labels["type"] = options.Type
}
return k.getService(labels) return k.getService(labels)
} }
@ -349,7 +347,7 @@ func (k *kubernetes) List() ([]*runtime.Service, error) {
defer k.Unlock() defer k.Unlock()
labels := map[string]string{ labels := map[string]string{
"micro": "service", "micro": k.options.Type,
} }
log.Debugf("Runtime listing all micro services") log.Debugf("Runtime listing all micro services")
@ -360,7 +358,9 @@ func (k *kubernetes) List() ([]*runtime.Service, error) {
// Update the service in place // Update the service in place
func (k *kubernetes) Update(s *runtime.Service) error { func (k *kubernetes) Update(s *runtime.Service) error {
// create new kubernetes micro service // create new kubernetes micro service
service := newService(s, runtime.CreateOptions{}) service := newService(s, runtime.CreateOptions{
Type: k.options.Type,
})
// update build time annotation // update build time annotation
service.kdeploy.Spec.Template.Metadata.Annotations["build"] = time.Now().Format(time.RFC3339) service.kdeploy.Spec.Template.Metadata.Annotations["build"] = time.Now().Format(time.RFC3339)
@ -382,7 +382,9 @@ func (k *kubernetes) Delete(s *runtime.Service) error {
defer k.Unlock() defer k.Unlock()
// create new kubernetes micro service // create new kubernetes micro service
service := newService(s, runtime.CreateOptions{}) service := newService(s, runtime.CreateOptions{
Type: k.options.Type,
})
log.Debugf("Runtime queueing service %s for delete action", service.Name) log.Debugf("Runtime queueing service %s for delete action", service.Name)
@ -457,7 +459,10 @@ func (k *kubernetes) String() string {
// NewRuntime creates new kubernetes runtime // NewRuntime creates new kubernetes runtime
func NewRuntime(opts ...runtime.Option) runtime.Runtime { func NewRuntime(opts ...runtime.Option) runtime.Runtime {
// get default options // get default options
options := runtime.Options{} options := runtime.Options{
// Create labels with type "micro": "service"
Type: "service",
}
// apply requested options // apply requested options
for _, o := range opts { for _, o := range opts {

View File

@ -23,8 +23,8 @@ func newService(s *runtime.Service, c runtime.CreateOptions) *service {
name := client.Format(s.Name) name := client.Format(s.Name)
version := client.Format(s.Version) version := client.Format(s.Version)
kservice := client.NewService(name, version) kservice := client.NewService(name, version, c.Type)
kdeploy := client.NewDeployment(name, version) kdeploy := client.NewDeployment(name, version, c.Type)
// attach our values to the deployment; name, version, source // attach our values to the deployment; name, version, source
kdeploy.Metadata.Annotations["name"] = s.Name kdeploy.Metadata.Annotations["name"] = s.Name
@ -53,10 +53,8 @@ func newService(s *runtime.Service, c runtime.CreateOptions) *service {
kdeploy.Spec.Template.PodSpec.Containers[0].Env = append(kdeploy.Spec.Template.PodSpec.Containers[0].Env, env...) kdeploy.Spec.Template.PodSpec.Containers[0].Env = append(kdeploy.Spec.Template.PodSpec.Containers[0].Env, env...)
} }
// if Exec/Command has been supplied override the default command // specify the command to exec
if len(s.Exec) > 0 { if len(c.Command) > 0 {
kdeploy.Spec.Template.PodSpec.Containers[0].Command = s.Exec
} else if len(c.Command) > 0 {
kdeploy.Spec.Template.PodSpec.Containers[0].Command = c.Command kdeploy.Spec.Template.PodSpec.Containers[0].Command = c.Command
} else if len(s.Source) > 0 { } else if len(s.Source) > 0 {
// default command for our k8s service should be source // default command for our k8s service should be source

View File

@ -10,17 +10,28 @@ type Option func(o *Options)
type Options struct { type Options struct {
// Notifier for updates // Notifier for updates
Notifier Notifier Notifier Notifier
// Service type to manage
Type string
} }
// AutoUpdate enables micro auto-updates // WithNotifier specifies a notifier for updates
func WithNotifier(n Notifier) Option { func WithNotifier(n Notifier) Option {
return func(o *Options) { return func(o *Options) {
o.Notifier = n o.Notifier = n
} }
} }
// WithType sets the service type to manage
func WithType(t string) Option {
return func(o *Options) {
o.Type = t
}
}
type CreateOption func(o *CreateOptions) type CreateOption func(o *CreateOptions)
type ReadOption func(o *ReadOptions)
// CreateOptions configure runtime services // CreateOptions configure runtime services
type CreateOptions struct { type CreateOptions struct {
// command to execute including args // command to execute including args
@ -29,6 +40,18 @@ type CreateOptions struct {
Env []string Env []string
// Log output // Log output
Output io.Writer Output io.Writer
// Type of service to create
Type string
}
// ReadOptions queries runtime services
type ReadOptions struct {
// Service name
Service string
// Version queries services with given version
Version string
// Type of service
Type string
} }
// WithCommand specifies the command to execute // WithCommand specifies the command to execute
@ -55,17 +78,23 @@ func WithOutput(out io.Writer) CreateOption {
} }
} }
type ReadOption func(o *ReadOptions) // ReadService returns services with the given name
func ReadService(service string) ReadOption {
// ReadOptions queries runtime services return func(o *ReadOptions) {
type ReadOptions struct { o.Service = service
// Version queries services with given version }
Version string
} }
// WithVersion confifgures service version // WithVersion confifgures service version
func WithVersion(version string) ReadOption { func ReadVersion(version string) ReadOption {
return func(o *ReadOptions) { return func(o *ReadOptions) {
o.Version = version o.Version = version
} }
} }
// ReadType returns services of the given type
func ReadType(t string) ReadOption {
return func(o *ReadOptions) {
o.Type = t
}
}

View File

@ -17,7 +17,7 @@ type Runtime interface {
// Create registers a service // Create registers a service
Create(*Service, ...CreateOption) error Create(*Service, ...CreateOption) error
// Read returns the service // Read returns the service
Read(string, ...ReadOption) ([]*Service, error) Read(...ReadOption) ([]*Service, error)
// Update the service in place // Update the service in place
Update(*Service) error Update(*Service) error
// Remove a service // Remove a service
@ -84,10 +84,6 @@ type Service struct {
Version string Version string
// url location of source // url location of source
Source string Source string
// Path to store source
Path string
// Exec command
Exec []string
// Metadata stores metadata // Metadata stores metadata
Metadata map[string]string Metadata map[string]string
} }

View File

@ -37,23 +37,12 @@ func newService(s *Service, c CreateOptions) *service {
var exec string var exec string
var args []string var args []string
if len(s.Exec) > 0 {
if len(s.Exec) > 0 {
exec = s.Exec[0]
}
args = []string{}
if len(s.Exec) > 1 {
args = s.Exec[1:]
}
} else {
// set command // set command
exec = c.Command[0] exec = c.Command[0]
// set args // set args
if len(c.Command) > 1 { if len(c.Command) > 1 {
args = c.Command[1:] args = c.Command[1:]
} }
}
return &service{ return &service{
Service: s, Service: s,

View File

@ -17,8 +17,6 @@ func toProto(s *runtime.Service) *pb.Service {
Name: s.Name, Name: s.Name,
Version: s.Version, Version: s.Version,
Source: s.Source, Source: s.Source,
Path: s.Path,
Exec: s.Exec,
Metadata: s.Metadata, Metadata: s.Metadata,
} }
} }
@ -28,8 +26,6 @@ func toService(s *pb.Service) *runtime.Service {
Name: s.Name, Name: s.Name,
Version: s.Version, Version: s.Version,
Source: s.Source, Source: s.Source,
Path: s.Path,
Exec: s.Exec,
Metadata: s.Metadata, Metadata: s.Metadata,
} }
} }
@ -56,9 +52,14 @@ func toCreateOptions(opts *pb.CreateOptions) []runtime.CreateOption {
func toReadOptions(opts *pb.ReadOptions) []runtime.ReadOption { func toReadOptions(opts *pb.ReadOptions) []runtime.ReadOption {
options := []runtime.ReadOption{} options := []runtime.ReadOption{}
// version options if len(opts.Service) > 0 {
options = append(options, runtime.ReadService(opts.Service))
}
if len(opts.Version) > 0 { if len(opts.Version) > 0 {
options = append(options, runtime.WithVersion(opts.Version)) options = append(options, runtime.ReadVersion(opts.Version))
}
if len(opts.Type) > 0 {
options = append(options, runtime.ReadType(opts.Type))
} }
return options return options
@ -84,16 +85,12 @@ func (r *Runtime) Create(ctx context.Context, req *pb.CreateRequest, rsp *pb.Cre
} }
func (r *Runtime) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ReadResponse) error { func (r *Runtime) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ReadResponse) error {
if len(req.Name) == 0 {
return errors.BadRequest("go.micro.runtime", "blank service")
}
var options []runtime.ReadOption var options []runtime.ReadOption
if req.Options != nil { if req.Options != nil {
options = toReadOptions(req.Options) options = toReadOptions(req.Options)
} }
services, err := r.Runtime.Read(req.Name, options...) services, err := r.Runtime.Read(options...)
if err != nil { if err != nil {
return errors.InternalServerError("go.micro.runtime", err.Error()) return errors.InternalServerError("go.micro.runtime", err.Error())
} }

View File

@ -27,12 +27,8 @@ type Service struct {
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
// git url of the source // git url of the source
Source string `protobuf:"bytes,3,opt,name=source,proto3" json:"source,omitempty"` Source string `protobuf:"bytes,3,opt,name=source,proto3" json:"source,omitempty"`
// local path of the source
Path string `protobuf:"bytes,4,opt,name=path,proto3" json:"path,omitempty"`
// command to execute
Exec []string `protobuf:"bytes,5,rep,name=exec,proto3" json:"exec,omitempty"`
// service metadata // service metadata
Metadata map[string]string `protobuf:"bytes,6,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -84,20 +80,6 @@ func (m *Service) GetSource() string {
return "" return ""
} }
func (m *Service) GetPath() string {
if m != nil {
return m.Path
}
return ""
}
func (m *Service) GetExec() []string {
if m != nil {
return m.Exec
}
return nil
}
func (m *Service) GetMetadata() map[string]string { func (m *Service) GetMetadata() map[string]string {
if m != nil { if m != nil {
return m.Metadata return m.Metadata
@ -242,8 +224,12 @@ func (m *CreateResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_CreateResponse proto.InternalMessageInfo var xxx_messageInfo_CreateResponse proto.InternalMessageInfo
type ReadOptions struct { type ReadOptions struct {
// service name
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
// version of the service // version of the service
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
// type of service
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -274,6 +260,13 @@ func (m *ReadOptions) XXX_DiscardUnknown() {
var xxx_messageInfo_ReadOptions proto.InternalMessageInfo var xxx_messageInfo_ReadOptions proto.InternalMessageInfo
func (m *ReadOptions) GetService() string {
if m != nil {
return m.Service
}
return ""
}
func (m *ReadOptions) GetVersion() string { func (m *ReadOptions) GetVersion() string {
if m != nil { if m != nil {
return m.Version return m.Version
@ -281,9 +274,15 @@ func (m *ReadOptions) GetVersion() string {
return "" return ""
} }
func (m *ReadOptions) GetType() string {
if m != nil {
return m.Type
}
return ""
}
type ReadRequest struct { type ReadRequest struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Options *ReadOptions `protobuf:"bytes,1,opt,name=options,proto3" json:"options,omitempty"`
Options *ReadOptions `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -314,13 +313,6 @@ func (m *ReadRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_ReadRequest proto.InternalMessageInfo var xxx_messageInfo_ReadRequest proto.InternalMessageInfo
func (m *ReadRequest) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *ReadRequest) GetOptions() *ReadOptions { func (m *ReadRequest) GetOptions() *ReadOptions {
if m != nil { if m != nil {
return m.Options return m.Options
@ -599,37 +591,36 @@ func init() {
} }
var fileDescriptor_4bc91a8efec81434 = []byte{ var fileDescriptor_4bc91a8efec81434 = []byte{
// 498 bytes of a gzipped FileDescriptorProto // 492 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4b, 0x6f, 0xd3, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x6e, 0xd3, 0x40,
0x10, 0xae, 0xe3, 0xd4, 0x2e, 0x63, 0x8c, 0xa2, 0x15, 0x42, 0x4b, 0x25, 0x20, 0xf2, 0xa5, 0xbd, 0x10, 0xae, 0xe3, 0x10, 0xb7, 0x63, 0x8c, 0xa2, 0x15, 0x42, 0xa6, 0x12, 0x10, 0xf9, 0x42, 0x2f,
0xe0, 0x48, 0xae, 0x10, 0xaf, 0x63, 0x53, 0x71, 0x21, 0x42, 0x72, 0xc5, 0x85, 0xdb, 0xe2, 0x8c, 0x38, 0x92, 0x2b, 0xc4, 0xdf, 0xb1, 0x29, 0x5c, 0x88, 0x90, 0x5c, 0xf5, 0x01, 0x96, 0x64, 0x54,
0x8a, 0x45, 0xed, 0x35, 0xde, 0x75, 0x44, 0x4f, 0x5c, 0xf9, 0xcb, 0xdc, 0xd0, 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55, 0x39, 0x91, 0x91, 0x07, 0x2c, 0xdd, 0x13, 0xf2, 0x0d, 0xc6, 0x2a, 0x27, 0x32, 0x90, 0xab, 0x83, 0x7a, 0x3d, 0x74,
0x5c, 0x1d, 0xd4, 0xf3, 0xb1, 0xe3, 0x2d, 0xd0, 0x0a, 0x02, 0xe3, 0xf1, 0x10, 0xaf, 0xbd, 0x0c, 0xbd, 0x03, 0x5a, 0xc2, 0xc4, 0x78, 0xdc, 0xc7, 0xab, 0x93, 0x61, 0x1f, 0xaf, 0x83, 0x78, 0x34,
0x87, 0x78, 0xf5, 0xe2, 0xd1, 0x70, 0xc6, 0xda, 0x21, 0xb8, 0xbd, 0xe8, 0x86, 0xe0, 0x7a, 0xa9, 0x9c, 0xb1, 0xb6, 0x0f, 0xae, 0x13, 0x5d, 0x1f, 0xdc, 0x41, 0x2a, 0x5a, 0xa6, 0x0a, 0xa2, 0x4f,
0x68, 0x99, 0x2a, 0x88, 0x21, 0x99, 0x3b, 0x79, 0x0d, 0xc9, 0xdc, 0xcd, 0x2f, 0x39, 0xfa, 0x1a, 0x66, 0x2b, 0xaf, 0x3e, 0x99, 0xed, 0xfc, 0x92, 0x93, 0x9f, 0x13, 0xfd, 0x2f, 0xbd, 0xfc, 0x1f,
0xe8, 0x3f, 0xeb, 0xc5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbe, 0x95, 0xdf, 0xf9, 0x8f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x14, 0x09, 0x5e, 0x98, 0x81, 0x05, 0x00, 0x00,
0x00, 0x00,
} }

View File

@ -17,12 +17,8 @@ message Service {
string version = 2; string version = 2;
// git url of the source // git url of the source
string source = 3; string source = 3;
// local path of the source
string path = 4;
// command to execute
repeated string exec = 5;
// service metadata // service metadata
map<string,string> metadata = 6; map<string,string> metadata = 4;
} }
message CreateOptions { message CreateOptions {
@ -42,13 +38,16 @@ message CreateRequest {
message CreateResponse {} message CreateResponse {}
message ReadOptions { message ReadOptions {
// service name
string service = 1;
// version of the service // version of the service
string version = 2; string version = 2;
// type of service
string type = 3;
} }
message ReadRequest { message ReadRequest {
string name = 1; ReadOptions options = 1;
ReadOptions options = 2;
} }
message ReadResponse { message ReadResponse {

View File

@ -76,7 +76,7 @@ func (s *svc) Create(svc *runtime.Service, opts ...runtime.CreateOption) error {
} }
// Read returns the service with the given name from the runtime // Read returns the service with the given name from the runtime
func (s *svc) Read(name string, opts ...runtime.ReadOption) ([]*runtime.Service, error) { func (s *svc) Read(opts ...runtime.ReadOption) ([]*runtime.Service, error) {
options := runtime.ReadOptions{} options := runtime.ReadOptions{}
// apply requested options // apply requested options
for _, o := range opts { for _, o := range opts {
@ -85,9 +85,10 @@ func (s *svc) Read(name string, opts ...runtime.ReadOption) ([]*runtime.Service,
// runtime service create request // runtime service create request
req := &pb.ReadRequest{ req := &pb.ReadRequest{
Name: name,
Options: &pb.ReadOptions{ Options: &pb.ReadOptions{
Service: options.Service,
Version: options.Version, Version: options.Version,
Type: options.Type,
}, },
} }
@ -102,8 +103,6 @@ func (s *svc) Read(name string, opts ...runtime.ReadOption) ([]*runtime.Service,
Name: service.Name, Name: service.Name,
Version: service.Version, Version: service.Version,
Source: service.Source, Source: service.Source,
Path: service.Path,
Exec: service.Exec,
Metadata: service.Metadata, Metadata: service.Metadata,
} }
services = append(services, svc) services = append(services, svc)
@ -160,8 +159,6 @@ func (s *svc) List() ([]*runtime.Service, error) {
Name: service.Name, Name: service.Name,
Version: service.Version, Version: service.Version,
Source: service.Source, Source: service.Source,
Path: service.Path,
Exec: service.Exec,
Metadata: service.Metadata, Metadata: service.Metadata,
} }
services = append(services, svc) services = append(services, svc)