exec: protocol design draft v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 05 Jan 2020 16:28:53 +0100
branchv_0
changeset 0 4d5b3eda7be1
child 1 fd9a33a86532
exec: protocol design draft
.hgignore
exec/Makefile
exec/messages.csv
exec/protocol.csv
exec/protocol.sh
exec/protocol.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Sun Jan 05 16:28:53 2020 +0100
@@ -0,0 +1,7 @@
+syntax: glob
+
+*~
+
+syntax: regexp
+
+^exec/protocol\.(pdf|png|svg)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/exec/Makefile	Sun Jan 05 16:28:53 2020 +0100
@@ -0,0 +1,14 @@
+.PHONY: all display display-messages display-protocol
+
+all: protocol.pdf
+
+protocol.pdf: messages.csv protocol.csv protocol.sh
+	./protocol.sh
+
+display: display-messages display-protocol
+
+display-messages:
+	cat messages.csv | relpipe-in-csv "messages" | relpipe-out-tabular
+
+display-protocol:
+	cat protocol.csv | relpipe-in-csv "protocol" | relpipe-out-tabular
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/exec/messages.csv	Sun Jan 05 16:28:53 2020 +0100
@@ -0,0 +1,21 @@
+code,message,sender,parameter_1,parameter_2,parameter_3,parameter_4
+100,VERSION_SUPPORTED,executor,version,,,
+101,WAITING_FOR_VERSION,executor,,,,
+102,VERSION_ACCEPTED,process,version,,,
+103,RELATION_START,executor,name,,,
+104,INPUT_ATTRIBUTE_METADATA,executor,name,type,,
+105,OUTPUT_ATTRIBUTE_ALIAS,executor,name,,,
+106,OPTION,executor,name,type,value,
+107,COMPLETION_REQUEST,executor,what,value,,
+108,COMPLETION,process,value,,,
+109,COMPLETION_END,process,,,,
+110,WAITING_FOR_OUTPUT_ATTRIBUTES,executor,,,,
+111,OUTPUT_ATTRIBUTE_METADATA,process,name,type,,
+112,WAITING_FOR_RECORDS,process,,,,
+113,INPUT_ATTRIBUTE,executor,index,value,isNull,
+114,WAITING_FOR_OUTPUT_ATTRIBUTE,executor,,,,
+115,OUTPUT_ATTRIBUTE,process,value,isNull,,
+116,PROCESS_ERROR,process,code,message,,
+117,EXECUTOR_ERROR,executor,code,message,,
+118,EXECUTOR_WARNING,executor,code,message,,
+119,RELATION_END,executor,,,,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/exec/protocol.csv	Sun Jan 05 16:28:53 2020 +0100
@@ -0,0 +1,29 @@
+/,to,label
+start,VERSION_SUPPORTED,
+VERSION_SUPPORTED,WAITING_FOR_VERSION,
+VERSION_SUPPORTED,VERSION_SUPPORTED,+
+WAITING_FOR_VERSION,VERSION_ACCEPTED,
+VERSION_ACCEPTED,RELATION_START,
+RELATION_START,INPUT_ATTRIBUTE_METADATA,
+INPUT_ATTRIBUTE_METADATA,INPUT_ATTRIBUTE_METADATA,*
+INPUT_ATTRIBUTE_METADATA,OUTPUT_ATTRIBUTE_ALIAS,
+OUTPUT_ATTRIBUTE_ALIAS,OUTPUT_ATTRIBUTE_ALIAS,*
+OUTPUT_ATTRIBUTE_ALIAS,OPTION,
+OPTION,OPTION,*
+OPTION,WAITING_FOR_OUTPUT_ATTRIBUTES,
+OPTION,COMPLETION_REQUEST,
+COMPLETION_REQUEST,COMPLETION,
+COMPLETION,COMPLETION,*
+COMPLETION,COMPLETION_END,
+COMPLETION_END,end,
+WAITING_FOR_OUTPUT_ATTRIBUTES,OUTPUT_ATTRIBUTE_METADATA,
+OUTPUT_ATTRIBUTE_METADATA,OUTPUT_ATTRIBUTE_METADATA,*
+OUTPUT_ATTRIBUTE_METADATA,WAITING_FOR_RECORDS,
+WAITING_FOR_RECORDS,RELATION_END,
+WAITING_FOR_RECORDS,INPUT_ATTRIBUTE,
+INPUT_ATTRIBUTE,INPUT_ATTRIBUTE,*
+INPUT_ATTRIBUTE,WAITING_FOR_OUTPUT_ATTRIBUTE,
+WAITING_FOR_OUTPUT_ATTRIBUTE,OUTPUT_ATTRIBUTE,
+OUTPUT_ATTRIBUTE,OUTPUT_ATTRIBUTE,*
+OUTPUT_ATTRIBUTE,WAITING_FOR_RECORDS,
+RELATION_END,end,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/exec/protocol.sh	Sun Jan 05 16:28:53 2020 +0100
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+read_nullbyte() { for v in "$@"; do export "$v"; read -r -d '' "$v"; done }
+
+# Warning: this script is unsafe and certain characters (which are perfectly legal in CSV values) might cause invalid DOT (GraphViz) streams. (you have been warned)
+
+nodes() {
+	cat messages.csv \
+		| relpipe-in-csv \
+		| relpipe-tr-cut '.*' 'message|sender' \
+		| relpipe-tr-sed '.*' 'sender' 'executor' 'coral' \
+		| relpipe-tr-sed '.*' 'sender' 'process'  'gold2' \
+		| relpipe-out-nullbyte \
+		| while read_nullbyte message color; do echo "$message[style=\"filled,rounded\", fillcolor=$color];"; done
+	echo;
+}
+
+edges() {
+	cat protocol.csv \
+		| relpipe-in-csv \
+		| relpipe-out-nullbyte \
+		| while read_nullbyte from to label; do echo "$from -> $to [label=\"  $label\"];"; done
+}
+
+header() {
+	echo "digraph G {
+#rankdir=LR;
+node[shape=box, style=rounded, fontname=Ubuntu];
+start[shape=doublecircle];
+end[shape=doublecircle];
+";
+}
+
+footer() {
+	echo "}";
+}
+
+( header; nodes; edges; footer ) | dot -Tpdf > protocol.pdf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/exec/protocol.txt	Sun Jan 05 16:28:53 2020 +0100
@@ -0,0 +1,9 @@
+messages.csv:
+ - list of message types and their parameters
+
+protocol.csv:
+ - list of allowed responses / interactions
+ - label + = message can repeat but will be sent at least once
+ - label * = message can repeat but can be also completely skipped
+ - error message can be sent as a response to any message and terminates the process
+ - warning message can be sent as a response to any message, but does not affect the workflow (just causes e.g. printing a warning to STDERR)