This month's update covers three new versions of MESG Core, V0.5 and V0.6 and V0.7, plus a new mesg-js v2.0.0. Check out all of the new features below:
Service ID
A new parameter SID
has been introduced in the service definition file.
Developer can know specify a unique ID to their services that will stay the same even if the service is deploy on another computer! No more nightmare of updating the Service’s ID after every deployment.
Example:
In the service definition file (mesg.yml
):
name: "Ethereum"
sid: "com.mesg.ethereum"
description: "Ethereum Service to interact with any Smart Contract"
And then, use the SID
in any command, API call or in the libraries. Eg:
mesg-core service start com.mesg.ethereum
Persistent volumes
Service’s volume are now persistent. It means that if you stop and start a service, it will still have access to its data before the stop.
Service’s developers have to set the persistent volume under the volumes
parameter in the service definition.
Example:
configuration:
volumes:
- /home/ethereum
Env variable in Services
Service’s definition files now accept env
variables!
Service developers can set the env
variable in configuration
and in dependencies
. Eg:
name: "Parity"
sid: "com.mesg.ethereum.parity.dev"
configuration:
env:
- MESG_ETH_ENDPOINT=http://parity:8545
dependencies:
parity:
image: parity/parity:v2.1.3
env:
- MESG_TEST=HELLO
Users can override the env variable’s values when deploying a service. Eg:
mesg-core service deploy https://github.com/mesg-foundation/service-ethereum --env MESG_ETH_ENDPOINT=http://parity:8546
Execution error
Execution have a new state “failed” that is used when unexpected errors occurred on the service side. Application can now be notified when executions failed and the service didn’t work as expected.
Advance data definition in service definition
Service’s definition now accepts three new ways to describe the service’s data.
Array
We introduced the parameter repeated
to specify arrays.
Each element of the array has the type define with the parameter type
.
tasks:
list:
outputs:
success:
data:
addresses:
type: String
repeated: true
{
"addresses": ["string1", "string2", "string3"]
}
Nested Object
Object definition can now be a lot more precise with the introduction of the parameter object
.object
parameter accept a map of keys / parameters.
tasks:
sign:
inputs:
transaction:
type: Object
object:
nonce:
type: Number
to:
type: String
value:
type: Number
gasLimit:
type: Number
gasPrice:
type: Number
{
"transaction": {
"nonce": 1,
"to": "0x1",
"value": 1000000000,
"gasLimit": 1000000,
"gasPrice": 21000000
}
}
Any
The type Any
has been added to accept any type of data. No verification is done when using this type.
tasks:
exec:
inputs:
data:
type: Any
More info in the docs: https://docs.mesg.com/guide/service/service-file.html 1
MESG-js v.2.0.0
A new version of the mesg-js
library has been released: v2.0.0
.
You can install it to your project with npm i -S mesg-js@latest
With this release we completely changed the high level application APIs. We removed the When-Then logic and now have much more flexible new 4 funcs.
Added funcs are:
listenEvent()
listenResult()
executeTask()
executeTaskAndWaitResult()
Please see the new application APIs here 1. And check the updated quick start tutorial 1 to see these new APIs in action.
With this release we also updated TS types to be more precise, introduced options to application()
constructor to configure Core’s endpoint and made some internal improvements.
Happy coding… 🙂
Refer to Github or the the complete changelogs of V0.5, V0.6 and V0.7.
To update to the latest version, follow the installation process on the documentation