diff --git a/protobuf/api/event.pb.go b/protobuf/api/event.pb.go index 6452a0919..5e757fed5 100644 --- a/protobuf/api/event.pb.go +++ b/protobuf/api/event.pb.go @@ -125,11 +125,15 @@ func (m *StreamEventRequest_Filter) GetKey() string { // CreateEventRequest defines request for execution update. type CreateEventRequest struct { - // The event type to use to create the Event. - Event *types.Event `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + // instanceHash is hash of instance that can proceed an execution. + InstanceHash string `protobuf:"bytes,1,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` + // key is the key of the event. + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + // data is the data for the event. + Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *CreateEventRequest) Reset() { *m = CreateEventRequest{} } @@ -157,11 +161,25 @@ func (m *CreateEventRequest) XXX_DiscardUnknown() { var xxx_messageInfo_CreateEventRequest proto.InternalMessageInfo -func (m *CreateEventRequest) GetEvent() *types.Event { +func (m *CreateEventRequest) GetInstanceHash() string { if m != nil { - return m.Event + return m.InstanceHash } - return nil + return "" +} + +func (m *CreateEventRequest) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *CreateEventRequest) GetData() string { + if m != nil { + return m.Data + } + return "" } // CreateEventResponse defines response for execution update. @@ -215,23 +233,24 @@ func init() { func init() { proto.RegisterFile("protobuf/api/event.proto", fileDescriptor_c0ad091fa003d2ac) } var fileDescriptor_c0ad091fa003d2ac = []byte{ - // 253 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x41, 0x4b, 0xc4, 0x30, - 0x10, 0x85,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da, 0xea, 0x0b, 0xe6, 0x02, 0xe1, 0x1d, 0xa8, - 0x94, 0xc1, 0x33, 0xd9, 0x39, 0xff, 0xb5, 0xae, 0x72, 0x23, 0x7d, 0xd9, 0xcc, 0x70, 0x0d, 0x2a, - 0x5d, 0x69, 0x8c, 0xe7, 0x27, 0xd3, 0x93, 0xaa, 0x66, 0x76, 0x5d, 0x6c, 0x94, 0xbc, 0xc5, 0xfa, - 0x27, 0x00, 0x00, 0xff, 0xff, 0x6b, 0xa1, 0x43, 0x64, 0xc8, 0x01, 0x00, 0x00, + // 260 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x41, 0x4b, 0xc3, 0x40, + 0x10, 0x85, 0xbb, 0x8d, 0x2e, 0x38, 0xf6, 0x20, 0xe3, 0xc1, 0xb0, 0x07, 0x91, 0x3d, 0xe9, 0x65, + 0x2b, 0x2d, 0x78, 0xf3, 0x24, 0x8a, 0xe7, 0x78, 0x17, 0xb6, 0x3a, 0xa5, 0x8b, 0x9a, 0xac, 0xd9, + 0xa9, 0x50, 0xfc, 0x33, 0xfe, 0x54, 0xc9, 0x24, 0x04, 0x63, 0xf4, 0x36, 0xbc, 0xf7, 0xe6, 0x63, + 0xf6, 0x2d, 0xe4, 0xb1, 0xae, 0xb8, 0x5a, 0x6d, 0xd7, 0x73, 0x1f, 0xc3, 0x9c, 0x3e, 0xa8, 0x64, + 0x27, 0x12, 0x66, 0x3e, 0x06, 0x63, 0x7a, 0x9b, 0x77, 0x91, 0xd2, 0xcf, 0x80, 0xfd, 0x52, 0x80, + 0x0f, 0x5c, 0x93, 0x7f, 0xbb, 0x6d, 0xd4, 0x82, 0xde, 0xb7, 0x94, 0x18, 0xaf, 0x40, 0xaf, 0xc3, + 0x2b, 0x53, 0x9d, 0xab, 0x33, 0x75, 0x7e, 0xb8, 0x38, 0x75, 0x3e, 0x06, 0x37, 0x0e, 0xba, 0x3b, + 0x49, 0x15, 0x5d, 0xda, 0x14, 0xa0, 0x5b, 0x05, 0x11, 0xf6, 0x36, 0x3e, 0x6d, 0x64, 0xff, 0xa0, + 0x90, 0x19, 0x2d, 0xcc, 0x42, 0x99, 0xd8, 0x97, 0x4f, 0x74, 0xdf, 0x78, 0x53, 0xf1, 0x06, 0x1a, + 0x1e, 0x41, 0xf6, 0x42, 0xbb, 0x3c, 0x13, 0xab, 0x19, 0xed, 0x23, 0xe0, 0x4d, 0x4d, 0x9e, 0x69, + 0x70, 0xe1, 0x6f, 0x96, 0xfa, 0x9f, 0x35, 0xed, 0x59, 0xcd, 0x55, 0xcf, 0x9e, 0x7d, 0x87, 0x97, + 0xd9, 0x5e, 0xc0, 0xf1, 0x80, 0x9f, 0x62, 0x55, 0x26, 0xfa, 0xeb, 0x01, 0x8b, 0x4f, 0xd8, 0x97, + 0x10, 0x5e, 0x83, 0x6e, 0x77, 0xf0, 0x44, 0x9a, 0x19, 0x1f, 0x68, 0xf2, 0xb1, 0xd1, 0x92, 0xed, + 0x04, 0x97, 0xa0, 0xdb, 0x2e, 0xbb, 0xf5, 0x71, 0xb1, 0x66, 0xe6, 0xe4, 0xb3, 0x9c, 0x88, 0x76, + 0x72, 0xa9, 0x56, 0x5a, 0x7e, 0x6c, 0xf9, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x58, 0x6b, 0x0c, 0x12, + 0xee, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/protobuf/api/event.proto b/protobuf/api/event.proto index 7bf142239..fddb0d8bb 100644 --- a/protobuf/api/event.proto +++ b/protobuf/api/event.proto @@ -38,8 +38,14 @@ message StreamEventRequest { // CreateEventRequest defines request for execution update. message CreateEventRequest { - // The event type to use to create the Event. - types.Event event = 1; + // instanceHash is hash of instance that can proceed an execution. + string instanceHash = 1; + + // key is the key of the event. + string key = 2; + + // data is the data for the event. + string data = 3; } // CreateEventResponse defines response for execution update. diff --git a/protobuf/api/service.pb.go b/protobuf/api/service.pb.go index e31319b83..d3d4784f5 100644 --- a/protobuf/api/service.pb.go +++ b/protobuf/api/service.pb.go @@ -25,11 +25,27 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // The request's data for the `Create` API. type CreateServiceRequest struct { - // The service definition to use to create the Service. - Definition *types.Service `protobuf:"bytes,1,opt,name=definition,proto3" json:"definition,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + // Service's sid. + Sid string `protobuf:"bytes,1,opt,name=sid,proto3" json:"sid,omitempty"` + // Service's name. + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // Service's description. + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + // Configurations related to the service + Configuration *types.Service_Configuration `protobuf:"bytes,4,opt,name=configuration,proto3" json:"configuration,omitempty"` + // The list of tasks this service can execute. + Tasks []*types.Service_Task `protobuf:"bytes,5,rep,name=tasks,proto3" json:"tasks,omitempty"` + // The list of events this service can emit. + Events []*types.Service_Event `protobuf:"bytes,6,rep,name=events,proto3" json:"events,omitempty"` + // The container dependencies this service requires. + Dependencies []*types.Service_Dependency `protobuf:"bytes,7,rep,name=dependencies,proto3" json:"dependencies,omitempty"` + // Service's repository url. + Repository string `protobuf:"bytes,8,opt,name=repository,proto3" json:"repository,omitempty"` + // The hash id of service's source code on IPFS. + Source string `protobuf:"bytes,9,opt,name=source,proto3" json:"source,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *CreateServiceRequest) Reset() { *m = CreateServiceRequest{} } @@ -57,13 +73,69 @@ func (m *CreateServiceRequest) XXX_DiscardUnknown() { var xxx_messageInfo_CreateServiceRequest proto.InternalMessageInfo -func (m *CreateServiceRequest) GetDefinition() *types.Service { +func (m *CreateServiceRequest) GetSid() string { + if m != nil { + return m.Sid + } + return "" +} + +func (m *CreateServiceRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *CreateServiceRequest) GetDescription() string { if m != nil { - return m.Definition + return m.Description + } + return "" +} + +func (m *CreateServiceRequest) GetConfiguration() *types.Service_Configuration { + if m != nil { + return m.Configuration } return nil } +func (m *CreateServiceRequest) GetTasks() []*types.Service_Task { + if m != nil { + return m.Tasks + } + return nil +} + +func (m *CreateServiceRequest) GetEvents() []*types.Service_Event { + if m != nil { + return m.Events + } + return nil +} + +func (m *CreateServiceRequest) GetDependencies() []*types.Service_Dependency { + if m != nil { + return m.Dependencies + } + return nil +} + +func (m *CreateServiceRequest) GetRepository() string { + if m != nil { + return m.Repository + } + return "" +} + +func (m *CreateServiceRequest) GetSource() string { + if m != nil { + return m.Source + } + return "" +} + // The response's data for the `Create` API. type CreateServiceResponse struct { // The service's hash created. @@ -305,25 +377,34 @@ func init() { func init() { proto.RegisterFile("protobuf/api/service.proto", fileDescriptor_0615fe53b372bcb1) } var fileDescriptor_0615fe53b372bcb1 = []byte{ - // 280 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x4b, 0xc3, 0x30, - 0x14, 0xc7, 0x5b, 0x3a, 0xa6, 0x3e, 0x41, 0xf0, 0xd9, 0xb9, 0x1a, 0x3c, 0x8c, 0x5c, 0x94, 0x09, - 0x29, 0xcc, 0xa3, 0xa7, 0xa1, 0xb8, 0x8b, 0xa7, 0xf9, 0x09, 0x32, 0x7d, 0x63, 0x01, 0x69, 0x63, - 0x93, 0x09, 0x7e, 0x78, 0x41, 0x96, 0x66, 0xc3, 0x36, 0x39, 0x78, 0x2b, 0xef, 0xfd, 0xfa, 0x7b, - 0xfd, 0xff, 0x29, 0x30, 0xdd, 0xd4, 0xb6, 0x5e, 0x6d, 0xd7, 0xa5, 0xd4, 0xaa, 0x34, 0xd4, 0x7c, - 0xa9, 0x37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 0xee, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, - 0x96, 0x7f, 0x64, 0x89, 0x83, 0x02, 0x00, 0x00, + // 424 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6f, 0xd3, 0x40, + 0x10, 0xc5, 0xe3, 0x3a, 0x75, 0xdb, 0x09, 0x20, 0x98, 0xa6, 0xed, 0xd6, 0xaa, 0x50, 0xe4, 0x0b, + 0xa1, 0x20, 0x47, 0x0a, 0x47, 0xc4, 0xa1, 0xb4, 0xa8, 0x17, 0x4e, 0x86, 0x2f, 0xb0, 0x75, 0xa6, + 0x74, 0x55, 0xf0, 0x2e, 0x3b, 0x9b, 0x4a, 0xf9, 0xda, 0xdc, 0x91, 0x90, 0xd7, 0xdb, 0x2a, 0xfe, + 0x73, 0xe0, 0x36, 0x79, 0xef, 0x37, 0xb3, 0x3b, 0x2f, 0x6b, 0x48, 0x8d, 0xd5, 0x4e, 0xdf, 0xac, + 0x6f, 0x17, 0xd2, 0xa8, 0x05, 0x93, 0x7d, 0x50, 0x25, 0xe5, 0x5e, 0xc4, 0x58, 0x1a, 0x95, 0x9e, + 0x3d, 0x01, 0x6e, 0x63, 0x88, 0xdb, 0x48, 0xf6, 0x67, 0x07, 0xa6, 0x97, 0x96, 0xa4, 0xa3, 0x6f, + 0x8d, 0x5e, 0xd0, 0xef, 0x35, 0xb1, 0xc3, 0x97, 0x10, 0xb3, 0x5a, 0x89, 0x68, 0x16, 0xcd, 0x0f, + 0x8a, 0xba, 0x44, 0x84, 0x71, 0x25, 0x7f, 0x91, 0xd8, 0xf1, 0x92, 0xaf, 0x71, 0x06, 0x93, 0x15, + 0x71, 0x69, 0x95, 0x71, 0x4a, 0x57, 0x22, 0xf6, 0xd6, 0xb6, 0x84, 0x9f, 0xe1, 0x79, 0xa9, 0xab, + 0x5b, 0xf5, 0x63, 0x6d, 0xa5,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90, 0x34, 0xfb, 0xe3, 0x69, 0x2e, + 0x8d, 0xca, 0x87, 0x1e, 0x60, 0x9a, 0x0e, 0x59, 0x61, 0x9d, 0x51, 0x3d, 0xa2, 0xd9, 0x34, 0x8c, + 0x18, 0x8a, 0x28, 0x8c, 0x18, 0x4e, 0x64, 0x84, 0x0b, 0x88, 0xaf, 0xc9, 0xe1, 0xb1, 0x87, 0x7a, + 0xe9, 0xa4, 0x9d, 0x55, 0xb2, 0x11, 0x7e, 0x84, 0x71, 0x9d, 0x02, 0x9e, 0xf8, 0x8e, 0x7e, 0x4c, + 0xa9, 0xe8, 0x1b, 0x8f, 0xa7, 0xdd, 0x24, 0xfe, 0x7b, 0xfb, 0xf0, 0x2f, 0x00, 0x00, 0xff, 0xff, + 0x08, 0x1c, 0xaf, 0x2d, 0xb0, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/protobuf/api/service.proto b/protobuf/api/service.proto index a66b34979..d51460e33 100644 --- a/protobuf/api/service.proto +++ b/protobuf/api/service.proto @@ -28,8 +28,33 @@ service Service { // The request's data for the `Create` API. message CreateServiceRequest { - // The service definition to use to create the Service. - types.Service definition = 1; + // Service's sid. + string sid = 1; + + // Service's name. + string name = 2; + + // Service's description. + string description = 3; + + // Configurations related to the service + types.Service.Configuration configuration = 4; + + // The list of tasks this service can execute. + repeated types.Service.Task tasks = 5; + + // The list of events this service can emit. + repeated types.Service.Event events = 6; + + // The container dependencies this service requires. + repeated types.Service.Dependency dependencies = 7; + + // Service's repository url. + string repository = 8; + + // The hash id of service's source code on IPFS. + string source = 9; + } // The response's data for the `Create` API. diff --git a/server/grpc/api/event.go b/server/grpc/api/event.go index 7c08c5eac..9b55f6908 100644 --- a/server/grpc/api/event.go +++ b/server/grpc/api/event.go @@ -27,24 +27,20 @@ func NewEventServer(sdk *sdk.SDK) *EventServer { // Create creates a new event. func (s *EventServer) Create(ctx context.Context, req *api.CreateEventRequest) (*api.CreateEventResponse, error) { - if req.Event.Hash != "" { - return nil, errors.New("create event: hash not allowed") + instanceHash, err := hash.Decode(req.InstanceHash) + if err != nil { + return nil, fmt.Errorf("create event: instance %s", err) } - if req.Event.Key == "" { + if req.Key == "" { return nil, errors.New("create event: key missing") } - instanceHash, err := hash.Decode(req.Event.InstanceHash) - if err != nil { - return nil, fmt.Errorf("create event: instance %s", err) - } - var data map[string]interface{} - if err := json.Unmarshal([]byte(req.Event.Data), &data); err != nil { + if err := json.Unmarshal([]byte(req.Data), &data); err != nil { return nil, fmt.Errorf("create event: data %s", err) } - event, err := s.sdk.Event.Create(instanceHash, req.Event.Key, data) + event, err := s.sdk.Event.Create(instanceHash, req.Key, data) if err != nil { return nil, fmt.Errorf("create event: data %s", err) } diff --git a/server/grpc/api/service.go b/server/grpc/api/service.go index 0b4df5b1b..de3ba79cf 100644 --- a/server/grpc/api/service.go +++ b/server/grpc/api/service.go @@ -22,8 +22,18 @@ func NewServiceServer(sdk *sdk.SDK) *ServiceServer { } // Create creates a new service from definition. -func (s *ServiceServer) Create(ctx context.Context, request *protobuf_api.CreateServiceRequest) (*protobuf_api.CreateServiceResponse, error) { - definition := fromProtoService(request.Definition) +func (s *ServiceServer) Create(ctx context.Context, req *protobuf_api.CreateServiceRequest) (*protobuf_api.CreateServiceResponse, error) { + definition := fromProtoService(&types.Service{ + Sid: req.Sid, + Name: req.Name, + Description: req.Description, + Configuration: req.Configuration, + Tasks: req.Tasks, + Events: req.Events, + Dependencies: req.Dependencies, + Repository: req.Repository, + Source: req.Source, + }) srv, err := s.sdk.Service.Create(definition) if err != nil { return nil, err