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

Service interface #252

Closed NicolasMahe closed 6 years ago

NicolasMahe commented 6 years ago

Proposal

The goal is to allow developer to change services without changing anything in their app (expect the service ids). Services should have the same events and tasks definition in the mesg.yml.

Solution

Explicitly declare a service interface

Similar to class interface. The mesg.yml could have a new parameter interface containing the list of interface the service implements.

interfaces:
  - erc20
  - database

This interface could have their definition in a dedicated files: erc20.yml, database.yml or in a dedicated repository on github.

Pro

Easy to know a service implement a service interface. Easy for the developer of the service to know if its service implement the interface

Con

Have to create a new system of service definition with validation function and stuff... Have to either register the interface in the central database, or add the interface definition file to the service folder.

Implicitly implement a service interface

Similar to interface and struct in golang, or ERC20 contract on Ethereum. No need to declare an interface in the code or in mesg.yml.

Pro

More flexible. No reference.

Con

Harder to know if the service is really implementing the same events and tasks.


Related in a way to https://github.com/mesg-foundation/core/issues/176

antho1404 commented 6 years ago

Really interesting, I see many use cases for that but i'm just worried how to share these interfaces and if it's too complicated to share, it might not be used.

Developers can "just" follow a guideline to be compatible and interchangeable. We really need to think to a way to share these interfaces.

medium pro con
File easy to implement and clear link to the interface in the mesg.yml with ./my-interface.yml really not easy to share and so might be really complicated to re-use
GitHub (or similar) really easy to share and we could have the path in the mesg.yml file like github.com/org/repo#interfaceA centralized and hard to deal with versions or updates of the interfaces
IPFS (or similar) easy to do versions and can choose a fixed version or latest with the IPNS bad to share and use because the interface would be a hash so not really user-friendly

In the end if we have service composition, the interface system would just be useful only for the application developer (to be able to switch from one service to another) but this can be done without interface, just by comparing and matching the different services and we can also have a "similar services" features to help users to switch from one service to another

NicolasMahe commented 6 years ago

Moved to the forum https://forum.mesg.com/t/service-interface/24