mesg-foundation / engine

Build apps or autonomous workflows with reusable, shareable integrations connecting any service, app, blockchain or decentralized network.
https://mesg.com/
Apache License 2.0
130 stars 13 forks source link

Update protobuf struct CreateXXXRequest #1111

Closed NicolasMahe closed 5 years ago

NicolasMahe commented 5 years ago

Currently the protobuf struct CreateServiceRequest is accepting a definition.Service as first parameter. This is not the best as the data send to CreateServiceRequest are not exactly a definition.Service, the hash should not be present as it is calculated by the Engine, it makes the API a bit confusing. Also, we cannot pass directly the output of the command mesg-cli service:compile as it needs to be inside the key definition in CreateServiceRequest.

My suggestion is to update CreateServiceRequest to:

message CreateServiceRequest {
  string sid = 1;                                      // Service's sid.
  string name = 2;                                     // Service's name.
  string description = 3;                              // Service's description.
  definition.Configuration configuration = 4;          // Configurations related to the service
  repeated definition.Task tasks = 5;                  // The list of tasks this service can execute.
  repeated definition.Event events = 6;                // The list of events this service can emit.
  repeated definition.Dependency dependencies = 7;     // The container dependencies this service requires.
  string repository = 8;                               // Service's repository url.
  string source = 9;                                   // The hash id of service's source code on IPFS.
}

Make sure that other CreateXXXRequest messages are following the same pattern.

NicolasMahe commented 5 years ago

Be careful to also check the data (like https://github.com/mesg-foundation/engine/pull/1112)

krhubert commented 5 years ago

We can also check id hash is set and return an error od not empty

NicolasMahe commented 5 years ago

We can also check id hash is set and return an error od not empty

Yeah sure

But let's not do it now. Let's first implement Cosmos and see what constraint it provides and then adapt the API again.

krhubert commented 5 years ago

Also we can do the same strategy for Filters. Just use data type for a filter, eg:

In every of this palce, we're going to redifine a message type, instead of using one defined in definition.

antho1404 commented 5 years ago

Let's implement that. To summarize: