Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a log for each transfer transaction #133

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scalardb/src/scalardb/transfer.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns scalardb.transfer
(:require [clojure.core.reducers :as r]
[clojure.tools.logging :refer [warn]]
[clojure.tools.logging :refer [info warn]]
[jepsen
[client :as client]
[checker :as checker]
Expand Down Expand Up @@ -86,6 +86,7 @@

(defn- tx-transfer
[tx from to amount]
(info "Transferring" amount "from" from "to" to "by tx" (.getId tx))
(let [fromResult (.get tx (prepare-get from))
toResult (.get tx (prepare-get to))]
(->> (calc-new-balance fromResult (- amount))
Expand Down
2 changes: 2 additions & 0 deletions scalardb/test/scalardb/transfer_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
(def mock-transaction
(reify
DistributedTransaction
(^String getId [_] "dummy-tx-id")
(^Optional get [_ ^Get g] (mock-get g))
(^void put [_ ^Put p] (mock-put p))
(^void commit [_] (swap! commit-count inc))))
Expand All @@ -65,6 +66,7 @@
(def mock-transaction-throws-exception
(reify
DistributedTransaction
(^String getId [_] "dummy-tx-id")
(^Optional get [_ ^Get _] (throw (CrudException. "get failed" nil)))
(^void put [_ ^Put _] (throw (CrudException. "put failed" nil)))
(^void commit [_] (throw (CommitException. "commit failed" nil)))))
Expand Down
Loading