Initial actoring
This commit is contained in:
parent
ecd5ee5eb0
commit
7d532d71dd
|
@ -0,0 +1,5 @@
|
|||
# sqlite_actor
|
||||
|
||||
Syndicate actor for accessing Xapian databases.
|
||||
|
||||
Provides a Xapian binding module at [src/xapian_actor/xapian.nim](./src/xapian_actor/xapian.nim).
|
|
@ -0,0 +1,4 @@
|
|||
include ../syndicate-nim/depends.tup
|
||||
NIM_FLAGS += --path:$(TUP_CWD)/../syndicate-nim/src
|
||||
|
||||
NIM_FLAGS += --backend:cpp
|
|
@ -0,0 +1,7 @@
|
|||
version 1 .
|
||||
|
||||
DatabaseInfo = <xapian @uuid string @path string> .
|
||||
|
||||
Document = <document @id int @data bytes> .
|
||||
|
||||
ValueSlots = {int: any ...:...} .
|
|
@ -0,0 +1,5 @@
|
|||
let
|
||||
syndicate = builtins.getFlake "syndicate";
|
||||
pkgs =
|
||||
import <nixpkgs> { overlays = builtins.attrValues syndicate.overlays; };
|
||||
in pkgs.xapian_actor
|
|
@ -0,0 +1,3 @@
|
|||
include_rules
|
||||
: xapian_actor.nim | ./xapian_actor/<protocol> $(SYNDICATE_PROTOCOL) |> !nim_bin |> {bin}
|
||||
: {bin} |> !assert_built |>
|
|
@ -0,0 +1,25 @@
|
|||
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
import preserves, syndicate
|
||||
import ./xapian_actor/[protocol, xapian]
|
||||
|
||||
type
|
||||
Value = Preserve[void]
|
||||
|
||||
type
|
||||
DatabaseArg {.preservesDictionary.} = object
|
||||
database: string
|
||||
DataspaceArg {.preservesDictionary.} = object
|
||||
dataspace: Ref
|
||||
|
||||
runActor("main") do (root: Ref; turn: var Turn):
|
||||
connectStdio(root, turn)
|
||||
during(turn, root, ?DatabaseArg) do (path: string):
|
||||
let db = initDatabase(path)
|
||||
during(turn, root, ?DataspaceArg) do (ds: Ref):
|
||||
discard publish(turn, ds, DatabaseInfo(uuid: db.uuid, path: path))
|
||||
|
||||
do:
|
||||
close(db)
|
||||
# close database on path retraction
|
|
@ -0,0 +1,2 @@
|
|||
include_rules
|
||||
: foreach ../../*.prs |> !preserves_schema_nim |> | ./<protocol>
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
import
|
||||
preserves, std/tables
|
||||
|
||||
type
|
||||
Document* {.preservesRecord: "document".} = object
|
||||
`id`*: BiggestInt
|
||||
`data`*: seq[byte]
|
||||
|
||||
ValueSlots* = Table[BiggestInt, Preserve[void]]
|
||||
DatabaseInfo* {.preservesRecord: "xapian".} = object
|
||||
`uuid`*: string
|
||||
`path`*: string
|
||||
|
||||
proc `$`*(x: Document | ValueSlots | DatabaseInfo): string =
|
||||
`$`(toPreserve(x))
|
||||
|
||||
proc encode*(x: Document | ValueSlots | DatabaseInfo): seq[byte] =
|
||||
encode(toPreserve(x))
|
|
@ -1,4 +1,4 @@
|
|||
# SPDX-FileCopyrightText: 2022 Emery Hemingway
|
||||
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
|
@ -1,12 +1,9 @@
|
|||
# Package
|
||||
|
||||
version = "20220421"
|
||||
author = "Emery Hemingway"
|
||||
description = "Xapian library wrapper"
|
||||
license = "GPL-2.0-or-later"
|
||||
backend = "cpp"
|
||||
bin = @["xapian_actor"]
|
||||
description = "Syndicate actor for accessing Xapian databases"
|
||||
license = "Unlicense"
|
||||
srcDir = "src"
|
||||
version = "20220421"
|
||||
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 1.6.4"
|
||||
requires "nim >= 1.6.4", "syndicate >= 20230609"
|
||||
|
|
Loading…
Reference in New Issue