Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
klauswuestefeld committed Nov 7, 2024
1 parent 84f6e66 commit 8bcf26f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/prevayler_clj_aws/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@
(read-object s3-sdk-cli bucket v2-path unmarshal-from-in)
{:partkey 0})))

(defn- save-snapshot! [s3-cli s3-sdk-cli bucket snapshot-path snapshot]
#_(util/aws-invoke s3-cli {:op :PutObject
:request {:Bucket bucket
:Key snapshot-path
:Body (marshal snapshot)}})
(defn- save-snapshot! [s3-sdk-cli bucket snapshot-path snapshot]
(try
(let [v2-path (snapshot-v2-path snapshot-path)
temp-file (java.io.File/createTempFile "snapshot" "")] ; We use an intermediary file to easily determine the length of the stream. Otherwise, to determine its length, Amazon's SDK would buffer the entire stream in RAM, defeating our purpose.
Expand Down Expand Up @@ -152,7 +148,7 @@
(println "Saving snapshot to bucket...")
; Since s3 update is atomic, if saving snapshot fails next prevayler will pick the previous state
; and restore events from the previous partkey
(save-snapshot! s3-client s3-sdk-cli s3-bucket snapshot-path {:state @state-atom
(save-snapshot! s3-sdk-cli s3-bucket snapshot-path {:state @state-atom
:partkey (inc @snapshot-index-atom)})
(println "Snapshot done.")
(swap! snapshot-index-atom inc)
Expand Down

0 comments on commit 8bcf26f

Please sign in to comment.