From de8beb0df84428369de74092e97cca0c337d1f13 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Sat, 1 Jun 2024 03:35:53 +0200 Subject: [PATCH] New DODB API. --- Makefile | 4 ++-- shard.yml | 1 + src/storage.cr | 30 +++++++++++++++--------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index fd69515..6e34f25 100644 --- a/Makefile +++ b/Makefile @@ -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" diff --git a/shard.yml b/shard.yml index 36e7177..25e65ed 100644 --- a/shard.yml +++ b/shard.yml @@ -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 diff --git a/src/storage.cr b/src/storage.cr index fee984b..0dbf6ab 100644 --- a/src/storage.cr +++ b/src/storage.cr @@ -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