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

Create Getters on service's maps #349

Closed NicolasMahe closed 6 years ago

NicolasMahe commented 6 years ago

I saw in quite a lot of files this boring piece of code to access value of maps and return an error if not found: https://github.com/mesg-foundation/core/blob/bd84ad1d54eadfb8aa2bd79ac0c7c68f775f9c03/execution/complete.go#L13-L19

I suggest to create getters that will return the expected data and the error if not found. We should have getters for:

@mesg-foundation/core what do you think?

ilgooz commented 6 years ago

This validations also shouldn't be made in Complete(). We should first check data for execution and only then call Complete() with valid data in the api handlers. Passing an invalid data to Complete() doesn't make much sense.

event and execution packages needs to be more agnostic and only do their own jobs.