Compare commits
3 Commits
15b26d9d63
...
8f4d69401a
Author | SHA1 | Date |
---|---|---|
Emery Hemingway | 8f4d69401a | |
Emery Hemingway | ac917e6769 | |
Emery Hemingway | f20f54d8e6 |
136
README.md
136
README.md
|
@ -123,38 +123,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.
|
||||
|
@ -225,28 +193,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
|
||||
|
@ -325,7 +271,89 @@ Example script:
|
|||
]
|
||||
```
|
||||
|
||||
## 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> }>
|
||||
]
|
||||
```
|
||||
|
||||
## 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 }>
|
||||
]
|
||||
```
|
||||
|
|
3
Tupfile
3
Tupfile
|
@ -1,2 +1,3 @@
|
|||
include_rules
|
||||
: lock.json |> !nim_cfg |> | ./<lock>
|
||||
: |> !nim_lk |> {lockfile}
|
||||
: {lockfile} |> !nim_cfg |> | ./<lock>
|
||||
|
|
|
@ -26,6 +26,10 @@ UnixAddress = <unix @path string>.
|
|||
|
||||
SocketAddress = TcpAddress / UnixAddress .
|
||||
|
||||
HttpDriverArguments = <http-driver {
|
||||
dataspace: #:any
|
||||
}>.
|
||||
|
||||
JsonSocketTranslatorArguments = <json-socket-translator {
|
||||
dataspace: #:any
|
||||
socket: SocketAddress
|
||||
|
|
10
default.nix
10
default.nix
|
@ -1,10 +0,0 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
pkgs.buildNimPackage {
|
||||
name = "syndicate_utils";
|
||||
propagatedNativeBuildInputs = [ pkgs.pkg-config ];
|
||||
propagatedBuildInputs =
|
||||
[ pkgs.postgresql pkgs.sqlite pkgs.libxml2 pkgs.libxslt ];
|
||||
lockFile = ./lock.json;
|
||||
src = pkgs.lib.sources.cleanSource ./.;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
pkgs.buildNimPackage {
|
||||
name = "syndicate_utils";
|
||||
propagatedNativeBuildInputs =
|
||||
builtins.attrValues { inherit (pkgs) pkg-config solo5; };
|
||||
propagatedBuildInputs = builtins.attrValues {
|
||||
inherit (pkgs) getdns postgresql solo5 sqlite libxml2 libxslt;
|
||||
};
|
||||
lockFile = ./lock.json;
|
||||
}
|
|
@ -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)
|
|
@ -50,6 +50,12 @@ type
|
|||
XsltArguments* {.preservesRecord: "xslt".} = object
|
||||
`field0`*: XsltArgumentsField0
|
||||
|
||||
HttpDriverArgumentsField0* {.preservesDictionary.} = object
|
||||
`dataspace`* {.preservesEmbedded.}: EmbeddedRef
|
||||
|
||||
HttpDriverArguments* {.preservesRecord: "http-driver".} = object
|
||||
`field0`*: HttpDriverArgumentsField0
|
||||
|
||||
WebhooksArgumentsField0* {.preservesDictionary.} = object
|
||||
`endpoints`*: Table[seq[string], EmbeddedRef]
|
||||
`listen`*: Tcp
|
||||
|
@ -116,6 +122,7 @@ proc `$`*(x: WebsocketArguments | JsonTranslatorArguments | SocketAddress |
|
|||
JsonTranslatorConnected |
|
||||
JsonSocketTranslatorArguments |
|
||||
XsltArguments |
|
||||
HttpDriverArguments |
|
||||
WebhooksArguments |
|
||||
FileSystemUsageArguments |
|
||||
SqliteArguments |
|
||||
|
@ -134,6 +141,7 @@ proc encode*(x: WebsocketArguments | JsonTranslatorArguments | SocketAddress |
|
|||
JsonTranslatorConnected |
|
||||
JsonSocketTranslatorArguments |
|
||||
XsltArguments |
|
||||
HttpDriverArguments |
|
||||
WebhooksArguments |
|
||||
FileSystemUsageArguments |
|
||||
SqliteArguments |
|
||||
|
|
|
@ -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.
|
|
@ -5,25 +5,15 @@
|
|||
|
||||
import syndicate, syndicate/relays, syndicate/drivers/timers
|
||||
|
||||
const
|
||||
withPostgre* {.booldefine.}: bool = true
|
||||
withSqlite* {.booldefine.}: bool = true
|
||||
|
||||
import ./syndesizer/[
|
||||
base64_decoder,
|
||||
cache_actor,
|
||||
file_system_usage,
|
||||
http_driver,
|
||||
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):
|
||||
|
@ -31,12 +21,8 @@ runActor("syndesizer") do (turn: var Turn):
|
|||
discard spawnBase64Decoder(turn, ds)
|
||||
discard spawnCacheActor(turn, ds)
|
||||
discard spawnFileSystemUsageActor(turn, ds)
|
||||
discard spawnHttpDriver(turn, ds)
|
||||
discard spawnJsonSocketTranslator(turn, ds)
|
||||
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)
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
## Thin wrapper over `syndicate/drivers/http_driver`.
|
||||
|
||||
import pkg/preserves, pkg/syndicate
|
||||
import pkg/syndicate/drivers/http_driver
|
||||
import pkg/taps
|
||||
import ../schema/config
|
||||
|
||||
proc spawnHttpDriver*(turn: var Turn; ds: Cap): Actor {.discardable.}=
|
||||
http_driver.spawnHttpDriver(turn, ds)
|
||||
during(turn, ds, ?:HttpDriverArguments) do (ds: Cap):
|
||||
http_driver.spawnHttpDriver(turn, ds)
|
||||
|
||||
when isMainModule:
|
||||
import syndicate/relays
|
||||
|
||||
when defined(solo5):
|
||||
import solo5
|
||||
acquireDevices([("eth0", netBasic)], netAcquireHook)
|
||||
|
||||
proc envRoute: Route =
|
||||
var pr = parsePreserves $solo5_start_info.cmdline
|
||||
if result.fromPreserves pr:
|
||||
return
|
||||
elif pr.isSequence:
|
||||
for e in pr:
|
||||
if result.fromPreserves e:
|
||||
return
|
||||
quit("failed to parse command line for route to Syndicate gatekeeper")
|
||||
|
||||
runActor("main") do (turn: var Turn):
|
||||
let ds = newDataspace(turn)
|
||||
spawnRelays(turn, ds)
|
||||
resolve(turn, ds, envRoute(), spawnHttpDriver)
|
||||
|
||||
else:
|
||||
|
||||
runActor("main") do (turn: var Turn):
|
||||
resolveEnvironment(turn) do (turn: var Turn; ds: Cap):
|
||||
spawnHttpDriver(turn, ds)
|
|
@ -0,0 +1,2 @@
|
|||
define:ipv6Enabled
|
||||
include:"std/assertions"
|
|
@ -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").}
|
|
@ -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"]
|
||||
bin = @["mintsturdyref", "mount_actor", "msg", "postgre_actor", "preserve_process_environment", "rofi_script_actor", "sqlite_actor", "syndesizer", "xslt_actor"]
|
||||
|
||||
|
||||
# Dependencies
|
||||
|
|
Loading…
Reference in New Issue