Move actors with shared libraries out of syndesizer

This commit is contained in:
Emery Hemingway 2024-03-28 13:48:30 +00:00
parent 920cd28c89
commit 1f099d6bd2
6 changed files with 87 additions and 75 deletions

135
README.md
View File

@ -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
<require-service <daemon syndesizer>>
let ?sqlspace = dataspace
? <service-object <daemon syndesizer> ?cap> [
$cap <postgre {
dataspace: $sqlspace
connection: [
["host" "example.com"]
["dbname" "foobar"]
["user" "hackme"]
]
}>
]
let ?tuplespace = dataspace
$sqlspace <query "SELECT id, name FROM stuff" $tuplespace>
$tuplespace ? [?id ?name] [
$log ! <log "-" { row: <example-row $id $name> }>
]
```
### 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 [
? <xslt-transform "/stylesheet.xls" "/doc.xml" ?output> [
? <xml-translation ?text $output> [
$log ! <log "-" { xslt-output: $text }>
]
]
]
<require-service <daemon syndesizer>>
? <service-object <daemon syndesizer> ?cap> $cap [
<xml-translator { dataspace: $ds }>
<xslt { dataspace: $ds }>
]
```
---
## 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
<require-service <daemon postgre_actor>>
let ?sqlspace = dataspace
? <service-object <daemon postgre_actor> ?cap> [
$cap <postgre {
dataspace: $sqlspace
connection: [
["host" "example.com"]
["dbname" "foobar"]
["user" "hackme"]
]
}>
]
let ?tuplespace = dataspace
$sqlspace <query "SELECT id, name FROM stuff" $tuplespace>
$tuplespace ? [?id ?name] [
$log ! <log "-" { row: <example-row $id $name> }>
]
```
## 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
<require-service <daemon sqlite_actor>>
let ?sqlspace = dataspace
? <service-object <daemon sqlite_actor> ?cap> [
$cap <sqlite {
dataspace: $sqlspace
database: "/var/db/example.db"
}>
]
let ?tuplespace = dataspace
$sqlspace <query "SELECT id, name FROM stuff" $tuplespace>
$tuplespace ? [?id ?name] [
$log ! <log "-" { row: <example-row $id $name> }>
]
```
## syndump
@ -316,3 +321,25 @@ Example
# Print patterns in use, filter down with AWK to only the published patterns.
$ FS=':' syndump '<Observe ? _>' | 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 [
? <xslt-transform "/stylesheet.xls" "/doc.xml" ?output> [
? <xml-translation ?text $output> [
$log ! <log "-" { xslt-output: $text }>
]
]
]
<require-service <daemon xslt_actor>>
? <service-object <daemon xslt_actor> ?cap> $cap [
<xml-translator { dataspace: $ds }>
<xslt { dataspace: $ds }>
]
```

View File

@ -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)

View File

@ -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.

View File

@ -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)

View File

@ -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").}

View File

@ -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