From f9fe5ded8d117c47075139e3e25646026521caef Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 19 Jun 2019 18:49:46 +0700 Subject: [PATCH 1/8] Add ToProtoService functions --- server/grpc/api/service.go | 98 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/server/grpc/api/service.go b/server/grpc/api/service.go index 5c1cb5054..fe007b4f3 100644 --- a/server/grpc/api/service.go +++ b/server/grpc/api/service.go @@ -103,3 +103,101 @@ func fromProtoDependencies(deps []*definition.Dependency) []*service.Dependency } return ds } + +// ToProtoService converts an internal service struct to the protobuf definition +// TODO: should not be public. Need to move server/grpc/service.go to server/grpc/api/service.go +func ToProtoService(s *service.Service) *definition.Service { + return &definition.Service{ + Hash: s.Hash, + Sid: s.Sid, + Name: s.Name, + Description: s.Description, + Repository: s.Repository, + Source: s.Source, + Tasks: toProtoTasks(s.Tasks), + Events: toProtoEvents(s.Events), + Configuration: toProtoConfiguration(s.Configuration), + Dependencies: toProtoDependencies(s.Dependencies), + } +} + +func toProtoTasks(tasks []*service.Task) []*definition.Task { + ts := make([]*definition.Task, len(tasks)) + for i, task := range tasks { + ts[i] = &definition.Task{ + Key: task.Key, + Name: task.Name, + Description: task.Description, + Inputs: toProtoParameters(task.Inputs), + Outputs: toProtoParameters(task.Outputs), + } + } + return ts +} + +func toProtoEvents(events []*service.Event) []*definition.Event { + es := make([]*definition.Event, len(events)) + for i, event := range events { + es[i] = &definition.Event{ + Key: event.Key, + Name: event.Name, + Description: event.Description, + Data: toProtoParameters(event.Data), + } + } + return es +} + +func toProtoParameters(params []*service.Parameter) []*definition.Parameter { + ps := make([]*definition.Parameter, len(params)) + for i, param := range params { + ps[i] = &definition.Parameter{ + Key: param.Key, + Name: param.Name, + Description: param.Description, + Type: param.Type, + Repeated: param.Repeated, + Optional: param.Optional, + Object: toProtoParameters(param.Object), + } + } + return ps +} + +func toProtoConfiguration(configuration *service.Dependency) *definition.Configuration { + if configuration == nil { + return nil + } + return &definition.Configuration{ + Args: configuration.Args, + Command: configuration.Command, + Ports: configuration.Ports, + Volumes: configuration.Volumes, + VolumesFrom: configuration.VolumesFrom, + Env: configuration.Env, + } +} + +func toProtoDependency(dep *service.Dependency) *definition.Dependency { + if dep == nil { + return nil + } + return &definition.Dependency{ + Key: dep.Key, + Image: dep.Image, + Volumes: dep.Volumes, + VolumesFrom: dep.VolumesFrom, + Ports: dep.Ports, + Command: dep.Command, + Args: dep.Args, + Env: dep.Env, + } +} + +func toProtoDependencies(deps []*service.Dependency) []*definition.Dependency { + ds := make([]*definition.Dependency, len(deps)) + for i, dep := range deps { + ds[i] = toProtoDependency(dep) + } + return ds +} From 8968c32f56d90af037b21a1f6d7907dce7d51b47 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 19 Jun 2019 18:50:04 +0700 Subject: [PATCH 2/8] Add Get api to service gRPC --- protobuf/api/service.pb.go | 113 +++++++++++++++++++++++++++++++------ protobuf/api/service.proto | 8 +++ 2 files changed, 103 insertions(+), 18 deletions(-) diff --git a/protobuf/api/service.pb.go b/protobuf/api/service.pb.go index a3fb216b3..56351896d 100644 --- a/protobuf/api/service.pb.go +++ b/protobuf/api/service.pb.go @@ -35,7 +35,7 @@ func (m *CreateServiceRequest) Reset() { *m = CreateServiceRequest{} } func (m *CreateServiceRequest) String() string { return proto.CompactTextString(m) } func (*CreateServiceRequest) ProtoMessage() {} func (*CreateServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_service_e517ed1dd58135c7, []int{0} + return fileDescriptor_service_c439b291bb00d662, []int{0} } func (m *CreateServiceRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CreateServiceRequest.Unmarshal(m, b) @@ -74,7 +74,7 @@ func (m *CreateServiceResponse) Reset() { *m = CreateServiceResponse{} } func (m *CreateServiceResponse) String() string { return proto.CompactTextString(m) } func (*CreateServiceResponse) ProtoMessage() {} func (*CreateServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_service_e517ed1dd58135c7, []int{1} + return fileDescriptor_service_c439b291bb00d662, []int{1} } func (m *CreateServiceResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CreateServiceResponse.Unmarshal(m, b) @@ -108,9 +108,49 @@ func (m *CreateServiceResponse) GetHash() string { return "" } +// GetServiceRequest defines request to retrieve a single service. +type GetServiceRequest struct { + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetServiceRequest) Reset() { *m = GetServiceRequest{} } +func (m *GetServiceRequest) String() string { return proto.CompactTextString(m) } +func (*GetServiceRequest) ProtoMessage() {} +func (*GetServiceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_service_c439b291bb00d662, []int{2} +} +func (m *GetServiceRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetServiceRequest.Unmarshal(m, b) +} +func (m *GetServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetServiceRequest.Marshal(b, m, deterministic) +} +func (dst *GetServiceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetServiceRequest.Merge(dst, src) +} +func (m *GetServiceRequest) XXX_Size() int { + return xxx_messageInfo_GetServiceRequest.Size(m) +} +func (m *GetServiceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetServiceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetServiceRequest proto.InternalMessageInfo + +func (m *GetServiceRequest) GetHash() string { + if m != nil { + return m.Hash + } + return "" +} + func init() { proto.RegisterType((*CreateServiceRequest)(nil), "api.CreateServiceRequest") proto.RegisterType((*CreateServiceResponse)(nil), "api.CreateServiceResponse") + proto.RegisterType((*GetServiceRequest)(nil), "api.GetServiceRequest") } // Reference imports to suppress errors if they are not otherwise used. @@ -126,6 +166,8 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type ServiceXClient interface { Create(ctx context.Context, in *CreateServiceRequest, opts ...grpc.CallOption) (*CreateServiceResponse, error) + // Get returns a single Service specified in a request. + Get(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*definition.Service, error) } type serviceXClient struct { @@ -145,9 +187,20 @@ func (c *serviceXClient) Create(ctx context.Context, in *CreateServiceRequest, o return out, nil } +func (c *serviceXClient) Get(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*definition.Service, error) { + out := new(definition.Service) + err := c.cc.Invoke(ctx, "/api.ServiceX/Get", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ServiceXServer is the server API for ServiceX service. type ServiceXServer interface { Create(context.Context, *CreateServiceRequest) (*CreateServiceResponse, error) + // Get returns a single Service specified in a request. + Get(context.Context, *GetServiceRequest) (*definition.Service, error) } func RegisterServiceXServer(s *grpc.Server, srv ServiceXServer) { @@ -172,6 +225,24 @@ func _ServiceX_Create_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _ServiceX_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceXServer).Get(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.ServiceX/Get", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceXServer).Get(ctx, req.(*GetServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _ServiceX_serviceDesc = grpc.ServiceDesc{ ServiceName: "api.ServiceX", HandlerType: (*ServiceXServer)(nil), @@ -180,25 +251,31 @@ var _ServiceX_serviceDesc = grpc.ServiceDesc{ MethodName: "Create", Handler: _ServiceX_Create_Handler, }, + { + MethodName: "Get", + Handler: _ServiceX_Get_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "protobuf/api/service.proto", } -func init() { proto.RegisterFile("protobuf/api/service.proto", fileDescriptor_service_e517ed1dd58135c7) } - -var fileDescriptor_service_e517ed1dd58135c7 = []byte{ - // 187 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x28, 0xca, 0x2f, - 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x2c, 0xc8, 0xd4, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, - 0xd5, 0x03, 0x0b, 0x0a, 0x31, 0x27, 0x16, 0x64, 0x4a, 0x29, 0xc2, 0x15, 0xa4, 0xa4, 0xa6, 0x65, - 0xe6, 0x65, 0x96, 0x64, 0xe6, 0xe7, 0xa1, 0xaa, 0x53, 0xf2, 0xe6, 0x12, 0x71, 0x2e, 0x4a, 0x4d, - 0x2c, 0x49, 0x0d, 0x86, 0x08, 0x07, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0x19, 0x73, 0x71, - 0x21, 0xf4, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x09, 0xeb, 0x21, 0x84, 0xf4, 0x60, 0xea, - 0x91, 0x94, 0x29, 0xd9, 0x72, 0x89, 0xa2, 0x19, 0x56, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x2a, 0x24, - 0xc0, 0xc5, 0x5c, 0x9c, 0x99, 0x02, 0x36, 0x86, 0x33, 0x08, 0xc4, 0x14, 0x12, 0xe2, 0x62, 0xc9, - 0x48, 0x2c, 0xce, 0x90, 0x60, 0x02, 0x0b, 0x81, 0xd9, 0x46, 0xbe, 0x5c, 0x1c, 0x50, 0x8d, 0x11, - 0x42, 0x8e, 0x5c, 0x6c, 0x10, 0xa3, 0x84, 0x24, 0xf5, 0x12, 0x0b, 0x32, 0xf5, 0xb0, 0x39, 0x52, - 0x4a, 0x0a, 0x9b, 0x14, 0xc4, 0x4a, 0x25, 0x86, 0x24, 0x36, 0xb0, 0x0f, 0x8d, 0x01, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x2b, 0xb6, 0x9f, 0xac, 0x27, 0x01, 0x00, 0x00, +func init() { proto.RegisterFile("protobuf/api/service.proto", fileDescriptor_service_c439b291bb00d662) } + +var fileDescriptor_service_c439b291bb00d662 = []byte{ + // 220 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xbd, 0x52, 0x85, 0x30, + 0x10, 0x85, 0x6f, 0xc4, 0xb9, 0xa3, 0x6b, 0xa3, 0xeb, 0xcf, 0x5c, 0x53, 0x69, 0x1a, 0xad, 0xc2, + 0x0c, 0xd8, 0x5a, 0x38, 0x16, 0x14, 0x76, 0xd8, 0xd8, 0x06, 0x59, 0x86, 0x6d, 0x48, 0x24, 0xc1, + 0x17, 0xf0, 0xc5, 0x1d, 0x83, 0x88, 0x22, 0xdd, 0xce, 0x97, 0x2f, 0x9b, 0x73, 0x02, 0xd2, 0xf5, + 0x36, 0xd8, 0x6a, 0x68, 0x52, 0xe3, 0x38, 0xf5, 0xd4, 0xbf, 0xf3, 0x2b, 0xe9, 0x08, 0x31, 0x31, + 0x8e, 0xe5, 0xf5, 0x8f, 0x50, 0x53, 0xc3, 0x1d, 0x07, 0xb6, 0xdd, 0x5f, 0x4f, 0x3d, 0xc1, 0xd9, + 0x63, 0x4f, 0x26, 0xd0, 0xf3, 0x88, 0x4b, 0x7a, 0x1b, 0xc8, 0x07, 0xcc, 0x01, 0xe6, 0x3b, 0x3b, + 0x71, 0x25, 0x6e, 0x8f, 0xb2, 0x53, 0x3d, 0x23, 0x3d, 0xf9, 0xbf, 0x34, 0x75, 0x0f, 0xe7, 0x8b, + 0x65, 0xde, 0xd9, 0xce, 0x13, 0x1e, 0x43, 0xe2, 0xb9, 0x8e, 0x6b, 0x0e, 0xcb, 0xaf, 0x11, 0x11, + 0xf6, 0x5b, 0xe3, 0xdb, 0xdd, 0x5e, 0x44, 0x71, 0x56, 0x37, 0x70, 0x52, 0x50, 0x58, 0x04, 0x99, + 0x44, 0x31, 0x8b, 0xd9, 0x87, 0x80, 0x83, 0x6f, 0xed, 0x05, 0x1f, 0x60, 0x3b, 0x3e, 0x8a, 0x97, + 0xda, 0x38, 0xd6, 0x6b, 0x75, 0xa4, 0x5c, 0x3b, 0x1a, 0xc3, 0xa9, 0x0d, 0xde, 0x41, 0x52, 0x50, + 0xc0, 0x8b, 0x28, 0xfd, 0x8b, 0x20, 0xd7, 0x7a, 0xab, 0x4d, 0xb5, 0x8d, 0x3f, 0x98, 0x7f, 0x06, + 0x00, 0x00, 0xff, 0xff, 0x1c, 0x95, 0x61, 0x97, 0x87, 0x01, 0x00, 0x00, } diff --git a/protobuf/api/service.proto b/protobuf/api/service.proto index fa864d7de..7d7fdf2f0 100644 --- a/protobuf/api/service.proto +++ b/protobuf/api/service.proto @@ -8,6 +8,9 @@ package api; // right now we have conflicts with api.Service. service ServiceX { rpc Create (CreateServiceRequest) returns (CreateServiceResponse) {} + + // Get returns a single Service specified in a request. + rpc Get(GetServiceRequest) returns (definition.Service) {} } message CreateServiceRequest { @@ -18,3 +21,8 @@ message CreateServiceResponse { string sid = 1; string hash = 2; } + +// GetServiceRequest defines request to retrieve a single service. +message GetServiceRequest { + string hash = 1; +} From 85a409581211b667800c66aed4886f7c8c357fea Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 19 Jun 2019 18:50:25 +0700 Subject: [PATCH 3/8] Add get function to service sdk --- sdk/service/service.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/service/service.go b/sdk/service/service.go index 85a8ccb13..4bf27506b 100644 --- a/sdk/service/service.go +++ b/sdk/service/service.go @@ -87,3 +87,8 @@ func (s *Service) Create(srv *service.Service) error { return s.db.Save(srv) } + +// Get returns the service that matches given hash. +func (s *Service) Get(hash string) (*service.Service, error) { + return s.db.Get(hash) +} From 34dd62f8187252e7b970454e9142d12da9c1a176 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 19 Jun 2019 18:50:41 +0700 Subject: [PATCH 4/8] Implement grpc server get service function --- server/grpc/service.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/grpc/service.go b/server/grpc/service.go index 59c4c6e7e..428f3bc98 100644 --- a/server/grpc/service.go +++ b/server/grpc/service.go @@ -3,7 +3,9 @@ package grpc import ( "context" + protoApi "github.com/mesg-foundation/core/protobuf/api" protobuf_api "github.com/mesg-foundation/core/protobuf/api" + "github.com/mesg-foundation/core/protobuf/definition" "github.com/mesg-foundation/core/sdk" "github.com/mesg-foundation/core/server/grpc/api" ) @@ -26,3 +28,12 @@ func (s *ServiceServer) Create(ctx context.Context, request *protobuf_api.Create } return &protobuf_api.CreateServiceResponse{Sid: srv.Sid, Hash: srv.Hash}, nil } + +// Get returns service from given hash. +func (s *ServiceServer) Get(ctx context.Context, req *protoApi.GetServiceRequest) (*definition.Service, error) { + exec, err := s.sdk.Service.Get(req.Hash) + if err != nil { + return nil, err + } + return api.ToProtoService(exec), nil +} From 06534d337ce894fac8012f7aca3f2d9f11714f2d Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 20 Jun 2019 10:40:35 +0700 Subject: [PATCH 5/8] Remove toProtoService functions from server/grpc/core in favor of the ones in server/grpc/api. --- server/grpc/api/service.go | 12 ++++- server/grpc/core/core.go | 5 +- server/grpc/core/proto.go | 103 ------------------------------------- 3 files changed, 14 insertions(+), 106 deletions(-) diff --git a/server/grpc/api/service.go b/server/grpc/api/service.go index fe007b4f3..e7f1b2ce5 100644 --- a/server/grpc/api/service.go +++ b/server/grpc/api/service.go @@ -104,8 +104,18 @@ func fromProtoDependencies(deps []*definition.Dependency) []*service.Dependency return ds } +// ToProtoServices converts internal services struct to their protobuf definition +// TODO: should not be public. Need to move server/grpc/service.go to server/grpc/api/service.go and delete server/grpc/core package +func ToProtoServices(ss []*service.Service) []*definition.Service { + services := make([]*definition.Service, len(ss)) + for i, s := range ss { + services[i] = ToProtoService(s) + } + return services +} + // ToProtoService converts an internal service struct to the protobuf definition -// TODO: should not be public. Need to move server/grpc/service.go to server/grpc/api/service.go +// TODO: should not be public. Need to move server/grpc/service.go to server/grpc/api/service.go and delete server/grpc/core package func ToProtoService(s *service.Service) *definition.Service { return &definition.Service{ Hash: s.Hash, diff --git a/server/grpc/core/core.go b/server/grpc/core/core.go index fde8a38be..c67a3ae37 100644 --- a/server/grpc/core/core.go +++ b/server/grpc/core/core.go @@ -14,6 +14,7 @@ import ( "github.com/mesg-foundation/core/sdk" eventsdk "github.com/mesg-foundation/core/sdk/event" executionsdk "github.com/mesg-foundation/core/sdk/execution" + "github.com/mesg-foundation/core/server/grpc/api" "github.com/mesg-foundation/core/service" "github.com/mesg-foundation/core/version" "github.com/mesg-foundation/core/x/xerrors" @@ -40,7 +41,7 @@ func (s *Server) GetService(ctx context.Context, request *coreapi.GetServiceRequ return nil, err } details := &coreapi.Service{ - Definition: toProtoService(ss), + Definition: api.ToProtoService(ss), Status: toProtoServiceStatusType(status), } return &coreapi.GetServiceReply{Service: details}, nil @@ -72,7 +73,7 @@ func (s *Server) ListServices(ctx context.Context, request *coreapi.ListServices return } details := &coreapi.Service{ - Definition: toProtoService(ss), + Definition: api.ToProtoService(ss), Status: toProtoServiceStatusType(status), } mp.Lock() diff --git a/server/grpc/core/proto.go b/server/grpc/core/proto.go index ec2d02b13..4decba218 100644 --- a/server/grpc/core/proto.go +++ b/server/grpc/core/proto.go @@ -2,32 +2,9 @@ package core import ( "github.com/mesg-foundation/core/protobuf/coreapi" - "github.com/mesg-foundation/core/protobuf/definition" service "github.com/mesg-foundation/core/service" ) -func toProtoServices(ss []*service.Service) []*definition.Service { - services := make([]*definition.Service, len(ss)) - for i, s := range ss { - services[i] = toProtoService(s) - } - return services -} - -func toProtoService(s *service.Service) *definition.Service { - return &definition.Service{ - Hash: s.Hash, - Sid: s.Sid, - Name: s.Name, - Description: s.Description, - Repository: s.Repository, - Tasks: toProtoTasks(s.Tasks), - Events: toProtoEvents(s.Events), - Configuration: toProtoConfiguration(s.Configuration), - Dependencies: toProtoDependencies(s.Dependencies), - } -} - func toProtoServiceStatusType(s service.StatusType) coreapi.Service_Status { switch s { default: @@ -42,83 +19,3 @@ func toProtoServiceStatusType(s service.StatusType) coreapi.Service_Status { return coreapi.Service_RUNNING } } - -func toProtoTasks(tasks []*service.Task) []*definition.Task { - ts := make([]*definition.Task, len(tasks)) - for i, task := range tasks { - ts[i] = &definition.Task{ - Key: task.Key, - Name: task.Name, - Description: task.Description, - Inputs: toProtoParameters(task.Inputs), - Outputs: toProtoParameters(task.Outputs), - } - } - return ts -} - -func toProtoEvents(events []*service.Event) []*definition.Event { - es := make([]*definition.Event, len(events)) - for i, event := range events { - es[i] = &definition.Event{ - Key: event.Key, - Name: event.Name, - Description: event.Description, - Data: toProtoParameters(event.Data), - } - } - return es -} - -func toProtoParameters(params []*service.Parameter) []*definition.Parameter { - ps := make([]*definition.Parameter, len(params)) - for i, param := range params { - ps[i] = &definition.Parameter{ - Key: param.Key, - Name: param.Name, - Description: param.Description, - Type: param.Type, - Repeated: param.Repeated, - Optional: param.Optional, - Object: toProtoParameters(param.Object), - } - } - return ps -} - -func toProtoConfiguration(configuration *service.Dependency) *definition.Configuration { - if configuration == nil { - return nil - } - return &definition.Configuration{ - Args: configuration.Args, - Command: configuration.Command, - Ports: configuration.Ports, - Volumes: configuration.Volumes, - VolumesFrom: configuration.VolumesFrom, - Env: configuration.Env, - } -} - -func toProtoDependency(dep *service.Dependency) *definition.Dependency { - if dep == nil { - return nil - } - return &definition.Dependency{ - Key: dep.Key, - Image: dep.Image, - Volumes: dep.Volumes, - VolumesFrom: dep.VolumesFrom, - Ports: dep.Ports, - Command: dep.Command, - Args: dep.Args, - } -} - -func toProtoDependencies(deps []*service.Dependency) []*definition.Dependency { - ds := make([]*definition.Dependency, len(deps)) - for i, dep := range deps { - ds[i] = toProtoDependency(dep) - } - return ds -} From ae76ec74063769f22c4a25ae65b91fbfd3a7d0c3 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 20 Jun 2019 10:47:17 +0700 Subject: [PATCH 6/8] fix double import --- server/grpc/service.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/grpc/service.go b/server/grpc/service.go index 428f3bc98..915ee73e4 100644 --- a/server/grpc/service.go +++ b/server/grpc/service.go @@ -3,7 +3,6 @@ package grpc import ( "context" - protoApi "github.com/mesg-foundation/core/protobuf/api" protobuf_api "github.com/mesg-foundation/core/protobuf/api" "github.com/mesg-foundation/core/protobuf/definition" "github.com/mesg-foundation/core/sdk" @@ -30,7 +29,7 @@ func (s *ServiceServer) Create(ctx context.Context, request *protobuf_api.Create } // Get returns service from given hash. -func (s *ServiceServer) Get(ctx context.Context, req *protoApi.GetServiceRequest) (*definition.Service, error) { +func (s *ServiceServer) Get(ctx context.Context, req *protobuf_api.GetServiceRequest) (*definition.Service, error) { exec, err := s.sdk.Service.Get(req.Hash) if err != nil { return nil, err From 277e60eb63b68f8e6dbc4d3173673e4f4c7ac43b Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 20 Jun 2019 10:47:26 +0700 Subject: [PATCH 7/8] fix integration test --- server/grpc/core/core_integration_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/grpc/core/core_integration_test.go b/server/grpc/core/core_integration_test.go index a80c7d0ff..86514bf07 100644 --- a/server/grpc/core/core_integration_test.go +++ b/server/grpc/core/core_integration_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/mesg-foundation/core/config" + "github.com/mesg-foundation/core/server/grpc/api" "github.com/mesg-foundation/core/protobuf/coreapi" executionsdk "github.com/mesg-foundation/core/sdk/execution" "github.com/mesg-foundation/core/service" @@ -46,7 +47,7 @@ func TestListServices(t *testing.T) { services, err := server.sdk.ListServices() require.NoError(t, err) - apiProtoServices := toProtoServices(services) + apiProtoServices := api.ToProtoServices(services) require.Len(t, apiProtoServices, 1) require.Equal(t, reply.Services[0].Definition.Hash, apiProtoServices[0].Hash) From 95c3f822e3bb0a3d413c77774960ba58fcd74d47 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 20 Jun 2019 11:03:37 +0700 Subject: [PATCH 8/8] gofmt --- server/grpc/core/core_integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/grpc/core/core_integration_test.go b/server/grpc/core/core_integration_test.go index 86514bf07..6d6dccdcd 100644 --- a/server/grpc/core/core_integration_test.go +++ b/server/grpc/core/core_integration_test.go @@ -8,9 +8,9 @@ import ( "testing" "github.com/mesg-foundation/core/config" - "github.com/mesg-foundation/core/server/grpc/api" "github.com/mesg-foundation/core/protobuf/coreapi" executionsdk "github.com/mesg-foundation/core/sdk/execution" + "github.com/mesg-foundation/core/server/grpc/api" "github.com/mesg-foundation/core/service" "github.com/stretchr/testify/require" )