From 1f099d6bd2da0dd47c177946a096dc14854cd518 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Thu, 28 Mar 2024 13:48:30 +0000 Subject: [PATCH] Move actors with shared libraries out of syndesizer --- README.md | 135 +++++++++++++++---------- src/{syndesizer => }/postgre_actor.nim | 3 +- src/{syndesizer => }/sqlite_actor.nim | 2 +- src/syndesizer.nim | 18 +--- src/{syndesizer => }/xslt_actor.nim | 2 +- syndicate_utils.nimble | 2 +- 6 files changed, 87 insertions(+), 75 deletions(-) rename src/{syndesizer => }/postgre_actor.nim (99%) rename src/{syndesizer => }/sqlite_actor.nim (99%) rename src/{syndesizer => }/xslt_actor.nim (99%) diff --git a/README.md b/README.md index bbf90a3..f0b22bf 100644 --- a/README.md +++ b/README.md @@ -124,38 +124,6 @@ let ?ds = dataspace ] ``` -### PostgreSQL - -Readonly access to PostgreSQL databases. Asserts rows as records in response to SQL query assertions. Dynamic updates are not implemented. - -Can be disabled by passing `--define:withPostgre=no` to the Nim compiler. - -``` -# Configuration example -> - -let ?sqlspace = dataspace - -? ?cap> [ - $cap -] - -let ?tuplespace = dataspace - -$sqlspace - -$tuplespace ? [?id ?name] [ - $log ! }> -] -``` - ### Pulse proxy A proxy actor that passes assertions and messages to a configured capability but only asserts observations on a a periodic pulse. @@ -226,28 +194,6 @@ Examples: ] ``` -### XSLT processor - -Perform XML stylesheet transformations. For a given textual XSLT stylesheet and a textual XML document generate an abstract XML document in Preserves form. Inputs may be XML text or paths to XML files. - -``` -# Configuration example -let ?ds = dataspace -$ds [ - ? [ - ? [ - $log ! - ] - ] -] - -> -? ?cap> $cap [ - - -] -``` - --- ## mintsturdyref @@ -301,11 +247,70 @@ Sample Syndicate server script: A utility that sends messages to `$SYNDICATE_ROUTE`. +## PostgreSQL + +Readonly access to PostgreSQL databases. Asserts rows as records in response to SQL query assertions. Dynamic updates are not implemented. + +Can be disabled by passing `--define:withPostgre=no` to the Nim compiler. + +``` +# Configuration example +> + +let ?sqlspace = dataspace + +? ?cap> [ + $cap +] + +let ?tuplespace = dataspace + +$sqlspace + +$tuplespace ? [?id ?name] [ + $log ! }> +] +``` + ## preserve_process_environment This utility serializes it's process environment to Preserves and prints it to stdout. It can be used to feed the environment variables of a nested child of the Syndicate server back to the server. For example, to retreive the environmental variables that a desktop manager passed on to its children. +## SQLite + +Readonly access to SQLite databases. Asserts rows as records in response to SQL query assertions. Dynamic updates are not implemented. + +Can be disabled by passing `--define:withSqlite=no` to the Nim compiler. + +``` +# Configuration example +> + +let ?sqlspace = dataspace + +? ?cap> [ + $cap +] + +let ?tuplespace = dataspace + +$sqlspace + +$tuplespace ? [?id ?name] [ + $log ! }> +] +``` ## syndump @@ -316,3 +321,25 @@ Example # Print patterns in use, filter down with AWK to only the published patterns. $ FS=':' syndump '' | awk -F : '/^+/ { print $2 }' ``` + +## XSLT processor + +Perform XML stylesheet transformations. For a given textual XSLT stylesheet and a textual XML document generate an abstract XML document in Preserves form. Inputs may be XML text or paths to XML files. + +``` +# Configuration example +let ?ds = dataspace +$ds [ + ? [ + ? [ + $log ! + ] + ] +] + +> +? ?cap> $cap [ + + +] +``` diff --git a/src/syndesizer/postgre_actor.nim b/src/postgre_actor.nim similarity index 99% rename from src/syndesizer/postgre_actor.nim rename to src/postgre_actor.nim index 10010b9..e320bfe 100644 --- a/src/syndesizer/postgre_actor.nim +++ b/src/postgre_actor.nim @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Unlicense import preserves, syndicate -import ../schema/[config, sql] +import ./schema/[config, sql] {.passL: "-lpq".} @@ -126,6 +126,7 @@ proc spawnPostgreActor*(turn: var Turn; root: Cap): Actor {.discardable.} = when isMainModule: import syndicate/relays + runActor("main") do (turn: var Turn): resolveEnvironment(turn) do (turn: var Turn; ds: Cap): spawnPostgreActor(turn, ds) diff --git a/src/syndesizer/sqlite_actor.nim b/src/sqlite_actor.nim similarity index 99% rename from src/syndesizer/sqlite_actor.nim rename to src/sqlite_actor.nim index 785c01f..26205d5 100644 --- a/src/syndesizer/sqlite_actor.nim +++ b/src/sqlite_actor.nim @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Unlicense import preserves, syndicate -import ../schema/[config, sql] +import ./schema/[config, sql] # Avoid Sqlite3 from the standard library because it is # only held together by wishful thinking and dlload. diff --git a/src/syndesizer.nim b/src/syndesizer.nim index 68470ef..3e9a740 100644 --- a/src/syndesizer.nim +++ b/src/syndesizer.nim @@ -5,10 +5,6 @@ import syndicate, syndicate/relays, syndicate/drivers/timers -const - withPostgre* {.booldefine.}: bool = true - withSqlite* {.booldefine.}: bool = true - import ./syndesizer/[ base64_decoder, cache_actor, @@ -16,14 +12,7 @@ import ./syndesizer/[ json_socket_translator, json_translator, pulses, - xml_translator, - xslt_actor] - -when withPostgre: - import ./syndesizer/postgre_actor - -when withSqlite: - import ./syndesizer/sqlite_actor + xml_translator] runActor("syndesizer") do (turn: var Turn): resolveEnvironment(turn) do (turn: var Turn; ds: Cap): @@ -35,8 +24,3 @@ runActor("syndesizer") do (turn: var Turn): discard spawnJsonStdioTranslator(turn, ds) discard spawnPulseActor(turn, ds) discard spawnXmlTranslator(turn, ds) - discard spawnXsltActor(turn, ds) - when withPostgre: - discard spawnPostgreActor(turn, ds) - when withSqlite: - discard spawnSqliteActor(turn, ds) diff --git a/src/syndesizer/xslt_actor.nim b/src/xslt_actor.nim similarity index 99% rename from src/syndesizer/xslt_actor.nim rename to src/xslt_actor.nim index 3b7a12d..8b81879 100644 --- a/src/syndesizer/xslt_actor.nim +++ b/src/xslt_actor.nim @@ -3,7 +3,7 @@ import std/[os, strutils] import preserves, syndicate -import ../schema/[assertions, config] +import ./schema/[assertions, config] {.passC: staticExec("pkg-config --cflags libxslt").} {.passL: staticExec("pkg-config --libs libxslt").} diff --git a/syndicate_utils.nimble b/syndicate_utils.nimble index 87175d2..c2fbfe9 100644 --- a/syndicate_utils.nimble +++ b/syndicate_utils.nimble @@ -5,7 +5,7 @@ author = "Emery Hemingway" description = "Utilites for Syndicated Actors and Synit" license = "unlicense" srcDir = "src" -bin = @["mintsturdyref", "mount_actor", "msg", "preserve_process_environment", "rofi_script_actor", "syndesizer", "syndump"] +bin = @["mintsturdyref", "mount_actor", "msg", "postgre_actor", "preserve_process_environment", "rofi_script_actor", "sqlite_actor", "syndesizer", "syndump", "xslt_actor"] # Dependencies