New DODB API.

This commit is contained in:
Philippe PITTOLI 2024-06-01 03:35:53 +02:00
parent 7bee53d625
commit de8beb0df8
3 changed files with 18 additions and 17 deletions

View File

@ -11,7 +11,7 @@ endif
# No idea why, but I need that to run applications. Ignore that.
#LD_P ?= LD_PRELOAD=/usr/local/lib/libipc.so.0
OPTS ?= --progress
OPTS ?= --progress --no-debug
Q ?= @
@ -108,4 +108,4 @@ wipe-db:
rm -r $(DBDIR)
release:
make build-server OPTS="--release --progress"
make build-server OPTS="--release --progress --no-debug"

View File

@ -11,6 +11,7 @@ dependencies:
ipc:
git: https://git.baguette.netlib.re/Baguette/ipc.cr
dodb:
branch: master
git: https://git.baguette.netlib.re/Baguette/dodb.cr
authd:
git: https://git.baguette.netlib.re/Baguette/authd

View File

@ -7,18 +7,18 @@ require "./service.cr"
require "dodb"
class DNSManager::Storage
getter domains : DODB::CachedDataBase(Domain)
getter domains_by_name : DODB::CachedIndex(Domain)
getter domains_by_share_key : DODB::CachedIndex(Domain)
getter domains_by_transfer_key : DODB::CachedIndex(Domain)
getter domains_by_owners : DODB::Tags(Domain)
getter domains : DODB::Storage::Cached(Domain)
getter domains_by_name : DODB::Trigger::IndexCached(Domain)
getter domains_by_share_key : DODB::Trigger::IndexCached(Domain)
getter domains_by_transfer_key : DODB::Trigger::IndexCached(Domain)
getter domains_by_owners : DODB::Trigger::Tags(Domain)
getter zones : DODB::CachedDataBase(Zone)
getter zones_by_domain : DODB::CachedIndex(Zone)
getter zones : DODB::Storage::Cached(Zone)
getter zones_by_domain : DODB::Trigger::IndexCached(Zone)
getter tokens : DODB::CachedDataBase(Token)
getter tokens_by_uuid : DODB::CachedIndex(Token)
getter tokens_by_domain : DODB::Partition(Token)
getter tokens : DODB::Storage::Cached(Token)
getter tokens_by_uuid : DODB::Trigger::IndexCached(Token)
getter tokens_by_domain : DODB::Trigger::Partition(Token)
getter root : String
getter zonefiledir : String
@ -32,16 +32,16 @@ class DNSManager::Storage
end
def initialize(@root : String, reindex : Bool = false)
@domains = DODB::CachedDataBase(Domain).new "#{@root}/domains"
@domains = DODB::Storage::Cached(Domain).new "#{@root}/domains"
@domains_by_name = @domains.new_index "name", &.name
@domains_by_share_key = @domains.new_nilable_index "share-key", do |d|
@domains_by_share_key = @domains.new_index "share-key", do |d|
if k = d.share_key
k
else
DODB.no_index
end
end
@domains_by_transfer_key = @domains.new_nilable_index "transfer-key", do |d|
@domains_by_transfer_key = @domains.new_index "transfer-key", do |d|
if k = d.transfer_key
k
else
@ -49,9 +49,9 @@ class DNSManager::Storage
end
end
@domains_by_owners = @domains.new_tags "owners", &.owners.map &.to_s
@zones = DODB::CachedDataBase(Zone).new "#{@root}/zones"
@zones = DODB::Storage::Cached(Zone).new "#{@root}/zones"
@zones_by_domain = @zones.new_index "domain", &.domain
@tokens = DODB::CachedDataBase(Token).new "#{@root}/tokens"
@tokens = DODB::Storage::Cached(Token).new "#{@root}/tokens"
@tokens_by_uuid = @tokens.new_index "uuid", &.uuid
@tokens_by_domain = @tokens.new_partition "domain", &.domain