This is an automated email from the ASF dual-hosted git repository. davisp pushed a commit to branch ensure-view-build-progress in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 7aa1806fc052c9e770e00596fa53f25cc6dbfb43 Author: Paul J. Davis <[email protected]> AuthorDate: Fri Nov 13 14:08:52 2020 -0600 Allow snapshots through fabric2_fdb:transactional --- src/fabric/src/fabric2_fdb.erl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl index aa2bade..1690f2f 100644 --- a/src/fabric/src/fabric2_fdb.erl +++ b/src/fabric/src/fabric2_fdb.erl @@ -18,6 +18,8 @@ transactional/3, transactional/2, + with_snapshot/2, + create/2, open/2, ensure_current/1, @@ -150,6 +152,11 @@ transactional(#{tx := undefined} = Db, Fun) -> transactional(Db#{reopen => true}, Fun) end) end; +transactional(#{tx := {erlfdb_snapshot, _}} = Db, Fun) -> + DbName = maps:get(name, Db, undefined), + with_span(Fun, #{'db.name' => DbName}, fun() -> + Fun(Db) + end); transactional(#{tx := {erlfdb_transaction, _}} = Db, Fun) -> DbName = maps:get(name, Db, undefined), @@ -183,6 +190,14 @@ do_transaction(Fun, LayerPrefix) when is_function(Fun, 1) -> end. +with_snapshot(#{tx := {erlfdb_transaction, _} = Tx} = TxDb, Fun) -> + SSDb = TxDb#{tx := erlfdb:snapshot(Tx)}, + Fun(SSDb); + +with_snapshot(#{tx := {erlfdb_snapshot, _}} = SSDb, Fun) -> + Fun(SSDb). + + create(#{} = Db0, Options) -> #{ name := DbName, @@ -1865,6 +1880,8 @@ get_db_handle() -> end. +require_transaction(#{tx := {erlfdb_snapshot, _}} = _Db) -> + ok; require_transaction(#{tx := {erlfdb_transaction, _}} = _Db) -> ok; require_transaction(#{} = _Db) ->
