Browse Source

Different transport addresses, incl tcp unix and stdio

main
Tony Garnock-Jones 2 months ago
parent
commit
d0f690f79b
  1. 28
      syndicate.sh

28
syndicate.sh

@ -11,19 +11,37 @@ declare -A ds_retraction_handlers
ds_project() {
# cargo install preserves-tools
echo "$1" | preserves-tool convert --indent=no --select "$2"
local input="$1"
local selector="$2"
shift 2
echo "$input" | preserves-tool convert --indent=no --select "$selector" "$@"
}
ds_connect_stdio() {
eval "$1"
exec 5<&0 6>&1
ds_flush
ds_mainloop
}
ds_connect() {
local addr=$1
case $(ds_project "$addr" ".^") in
tcp) nc_args="$(ds_project "$addr" ". 0" --output-format=unquoted) $(ds_project "$addr" ". 1")";;
unix) nc_args="-U $(ds_project "$addr" ". 0" --output-format=unquoted)";;
stdio) ds_connect_stdio "$2"; return;;
*) echo "ds_connect: address '$addr' not supported"; return 1;;
esac
local f=$(mktemp -u /tmp/ds.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)
mkfifo $f
trap "rm -f $f" 2 EXIT RETURN
{
eval "$1"
eval "$2"
ds_flush
ds_mainloop
} 5< <(nc -U ./sock <$f) 6>$f
} 5< <(nc $nc_args <$f) 6>$f
}
ds_send() {
@ -139,7 +157,9 @@ demo() {
fi
}
ds_object bootk demo_ds_resolved
ds_connect 'ds_assert "#![1 0]" "<resolve <ref \"syndicate\" [] #x\"a6480df5306611ddd0d3882b546e1977\"> $bootk>"'
ds_connect \
'<unix "./sock">' \
'ds_assert "#![1 0]" "<resolve <ref \"syndicate\" [] #x\"a6480df5306611ddd0d3882b546e1977\"> $bootk>"'
}
demo

Loading…
Cancel
Save