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

ServiceSDK create function should accept another struct than service.Service #1147

Closed NicolasMahe closed 5 years ago

NicolasMahe commented 5 years ago

Related to https://github.com/mesg-foundation/engine/pull/1141#discussion_r299009817

The ServiceSDK create function should accept another struct than service.Service. It doesn't make sense to create a resource by passing the already created struct to the function that create it. It makes validation harder by having to make compatibility with fields that should be field only after real creation (eg: hash).

As there is too many parameters to pass to the service.create function, a nice new struct should be created.

The function fromProtoService functions in service api should be replaced by a function that convert the proto definition to this new service.create struct.

krhubert commented 5 years ago

There is more option to discuss:

I've also put a low priority, as this one is not blocking us.

ilgooz commented 5 years ago

I think protobuf types should be only available inside the gRPC server. SDK shouldn't be aware of protobuf and gRPC. If Engine exposes other types of APIs in future, SDK shouldn't be affected by this.