Skip to content

Commit

Permalink
Add a log for each transfer transaction (#133)
Browse files Browse the repository at this point in the history
* add a log for each transfer transaction

* fix tests
  • Loading branch information
yito88 authored Nov 26, 2024
1 parent 1949e3e commit 3cff45b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
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

0 comments on commit 3cff45b

Please sign in to comment.