Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tx commands for service, process, execution and runner modules #1798

Merged
merged 2 commits into from
May 5, 2020

Conversation

NicolasMahe
Copy link
Member

@NicolasMahe NicolasMahe commented Apr 26, 2020

Add write commands for all modules

The commands service create, process create, execution create and execution update require the data to be passed as JSON because of the complexity of the data.
It makes them hard to use as the JSON is also complicated to write.
@antho1404 do you have a suggestion to improve this issue? Should I make a simple version based on flags but that can only fill the root keys?

Example of use:

go run ./cmd/mesg-cli tx service create  --from engine2 --chain-id "mesg-dev-chain" -b block --gas-prices=1.0atto '{"sid":"emit-event-interval","name":"Service Emit Event Interval","description":"Emits events on regular intervals","repository":"https://github.com/liteflow-services/emit-event-interval","configuration":{},"dependencies":[],"tasks":[],"events":[{"key":"every_1_second","name":"Every 1 second","description":"Emits an event every 1 second","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_2_seconds","name":"Every 2 seconds","description":"Emits an event every 2 seconds","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_5_seconds","name":"Every 5 seconds","description":"Emits an event every 5 seconds","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_10_seconds","name":"Every 10 seconds","description":"Emits an event every 10 seconds","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_30_seconds","name":"Every 30 seconds","description":"Emits an event every 30 seconds","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_1_minute","name":"Every 1 minute","description":"Emits an event every 1 minute","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_2_minutes","name":"Every 2 minutes","description":"Emits an event every 2 minutes","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_5_minutes","name":"Every 5 minutes","description":"Emits an event every 5 minutes","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_10_minutes","name":"Every 10 minutes","description":"Emits an event every 10 minutes","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_30_minutes","name":"Every 30 minutes","description":"Emits an event every 30 minutes","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_1_hour","name":"Every 1 hour","description":"Emits an event every 1 hour","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_2_hours","name":"Every 2 hours","description":"Emits an event every 2 hours","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_6_hours","name":"Every 6 hours","description":"Emits an event every 6 hours","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_12_hours","name":"Every 12 hours","description":"Emits an event every 12 hours","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]},{"key":"every_24_hours","name":"Every 24 hours","description":"Emits an event every 24 hours","data":[{"key":"timestamp","name":"Timestamp (ms)","description":"The timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC","type":"Number","object":[]}]}],"source":"QmPNUbFGZa5hvVCf1CAjFLfv5ZTykgpkU6sYXYXAEMzQMH"}'

go run ./cmd/mesg-cli tx runner create SERVICE_HASH --from engine2 --chain-id "mesg-dev-chain" -b block --gas-prices=1.0atto
go run ./cmd/mesg-cli tx runner delete RUNNER_HASH --from engine2 --chain-id "mesg-dev-chain" -b block --gas-prices=1.0atto

# TODO: add the args
go run ./cmd/mesg-cli tx process create --from engine --chain-id "mesg-dev-chain" -b block --gas-prices=1.0atto '{"name":"webhook","nodes":[{"key":"node-0","Type":{"type":"mesg.types.Process_Node_Event_","value":{"event":{"instanceHash":"8dD91Yx9N7kywn8MtQ9PxReWpdjpeGgSMvZsgWcnG27y","eventKey":"every_10_seconds"}}}},{"key":"node-1-inputs","Type":{"type":"mesg.types.Process_Node_Map_","value":{"map":[{"Key":"data","Value":{"Value":{"type":"mesg.types.Process_Node_Map_Output_Map_","value":{"map":[{"Key":"foo","Value":{"Value":{"type":"mesg.types.Process_Node_Map_Output_StringConst","value":{"string_const":"bar"}}}}]}}}},{"Key":"url","Value":{"Value":{"type":"mesg.types.Process_Node_Map_Output_StringConst","value":{"string_const":"https://webhook.site/ad536a28-4b19-4562-a756-f20027e25c5a"}}}}]}}},{"key":"node-1","Type":{"type":"mesg.types.Process_Node_Task_","value":{"task":{"instanceHash":"HVso8L6QtToBNomhDvnfobygr6YAtmXRAqdkJsw9s36e","taskKey":"call"}}}}],"edges":[{"src":"node-0","dst":"node-1-inputs"},{"src":"node-1-inputs","dst":"node-1"}]}'

go run ./cmd/mesg-cli tx process delete --from ACCOUNT --chain-id "mesg-dev-chain" -b block --gas-prices=1.0atto 9hFpz4Mq5KBfwVzKSoCEr3hFC1DFicEkMx13Uyr7oKWj

go run ./cmd/mesg-cli tx execution create --from engine --chain-id "mesg-dev-chain" -b block --gas-prices=1.0atto --yes '{"taskKey":"call","eventHash":"9hFpz4Mq5KBfwVzKSoCEr3hFC1DFicEkMx13Uyr7oKWj","executorHash":"8xdAhmoXcYtMobe6xwjMboDGPhqE7iMjY1iJ2WjbLwVS","price":"10000atto"}'

go run ./cmd/mesg-cli tx execution update --from engine --chain-id "mesg-dev-chain" -b block --gas-prices=1.0atto --yes '{"hash":"9hFpz4Mq5KBfwVzKSoCEr3hFC1DFicEkMx13Uyr7oKWj","executor":"mesgXXX","result":""}'

@NicolasMahe NicolasMahe changed the title Add write commands for all modules Add tx commands for service, process, execution and runner Apr 26, 2020
@NicolasMahe NicolasMahe changed the title Add tx commands for service, process, execution and runner Add tx commands for service, process, execution and runner modules Apr 26, 2020
@NicolasMahe NicolasMahe marked this pull request as draft April 27, 2020 07:48
@antho1404
Copy link
Member

I would definitely not go with flags as it will be really complex/impossible for services/processes.
Instead, just the JSON in argument or as a file will be more than enough.
I would also normalize that and have this for the runner as well even if it can be simplified but instead of

go run ./cmd/mesg-cli tx runner create BFBCRiRqD8VEU1qPC47WMXPYK5qGJCw6cbX3H2cekdU7 --from engine -b block

I would have

go run ./cmd/mesg-cli tx runner create '{"serviceHash": "BFBCRiRqD8VEU1qPC47WMXPYK5qGJCw6cbX3H2cekdU7"}' --from engine -b block

@NicolasMahe NicolasMahe marked this pull request as ready for review May 1, 2020 09:11
@NicolasMahe
Copy link
Member Author

I would definitely not go with flags as it will be really complex/impossible for services/processes.
Instead, just the JSON in argument or as a file will be more than enough.
I would also normalize that and have this for the runner as well even if it can be simplified but instead of

go run ./cmd/mesg-cli tx runner create BFBCRiRqD8VEU1qPC47WMXPYK5qGJCw6cbX3H2cekdU7 --from engine -b block

I would have

go run ./cmd/mesg-cli tx runner create '{"serviceHash": "BFBCRiRqD8VEU1qPC47WMXPYK5qGJCw6cbX3H2cekdU7"}' --from engine -b block

Only the command runner create, delete and process delete are not using the JSON definition.
The reason is all other cosmos commands are using args and flags, I don't want to do something different except if I don't have a choice.

@NicolasMahe NicolasMahe added this to the next milestone May 1, 2020
@NicolasMahe NicolasMahe self-assigned this May 1, 2020
@NicolasMahe NicolasMahe requested a review from antho1404 May 1, 2020 10:32
@NicolasMahe NicolasMahe added the release:add Pull requests that add something label May 3, 2020
@antho1404 antho1404 merged commit 6431f8e into dev May 5, 2020
@antho1404 antho1404 deleted the feature/write-commands branch May 5, 2020 07:36
@NicolasMahe NicolasMahe mentioned this pull request May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:add Pull requests that add something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants