Syndicate API update

This commit is contained in:
Emery Hemingway 2023-04-10 10:29:22 -05:00
parent 4b3c8cfa98
commit 1ce129fd56
8 changed files with 12 additions and 14 deletions

2
.envrc Normal file
View File

@ -0,0 +1,2 @@
source_env ..
use flake syndicate#syndicate_utils

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/.direnv
http_translator
json_translator
msg

2
Tuprules.tup Normal file
View File

@ -0,0 +1,2 @@
include ../syndicate-nim/depends.tup
NIM_FLAGS += --path:$(TUP_CWD)/../syndicate-nim/src

View File

@ -1,5 +1,2 @@
include_rules
modules += json_socket_translator.nim
modules += json_translator.nim
modules += msg.nim
: foreach $(modules) | $(SYNDICATE_PROTOCOL) ./<schema> |> !nim_bin |>
: foreach *.nim | $(SYNDICATE_PROTOCOL) ./<schema> |> !nim_bin |>

View File

@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: ☭ 2022 Emery Hemingway
# SPDX-FileCopyrightText: ☭ Emery Hemingway
# SPDX-License-Identifier: Unlicense
import std/[asyncdispatch, asynchttpserver, sets, strutils, tables, uri]
import std/[asyncdispatch, asynchttpserver, strutils, tables, uri]
import preserves
import syndicate, syndicate/actors
@ -74,7 +74,7 @@ bootDataspace("main") do (ds: Ref; turn: var Turn):
let rHandle = publish(turn, entity, http_protocol.Request(
handle: rId,
`method`: Method.GET,
headers: req.headers.table,
headers: req.headers.table[],
path: path,
body: req.body))

View File

@ -17,7 +17,7 @@ bootDataspace("main") do (ds: Ref; turn: var Turn):
buffered = false)
waitFor connectUnix(socket, socketPath)
onMessage(turn, ds, recordPattern(label, ?1, grab())) do (data: Assertion):
onMessage(turn, ds, recordPattern(label, ?toPreserve(1), grab())) do (data: Assertion):
var js: JsonNode
if fromPreserve(js, data):
asyncCheck socket.send($js & "\n")

View File

@ -9,13 +9,9 @@ proc unixSocketPath: string =
if result == "":
result = getEnv("XDG_RUNTIME_DIR", "/run/user/1000") / "dataspace"
proc mintCap: SturdyRef =
var key: array[16, byte]
mint(key, toPreserve("syndicate", Ref))
bootDataspace("main") do (root: Ref; turn: var Turn):
let label = getAppFilename().extractFilename
connectUnix(turn, unixSocketPath(), mintCap()) do (turn: var Turn; ds: Ref):
connectUnix(turn, unixSocketPath(), capabilities.mint()) do (turn: var Turn; ds: Ref):
var a = initRecord[Ref](label, commandLineParams().toPreserve(Ref))
message(turn, ds, a)

View File

@ -1,6 +1,6 @@
# Package
version = "20230301"
version = "20230410"
author = "Emery Hemingway"
description = "Utilites for Syndicated Actors and Synit"
license = "unlicense"