Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
renatillas committed Jan 25, 2025
1 parent a7f598d commit 783b790
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 36 deletions.
3 changes: 1 addition & 2 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "eventsourcing_postgres"
version = "5.1.0"
version = "5.1.1"

# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
Expand All @@ -20,5 +20,4 @@ gleam_json = ">= 2.3.0 and < 3.0.0"
[dev-dependencies]
gleeunit = ">= 1.2.0 and < 2.0.0"
birdie = ">= 1.2.5 and < 2.0.0"
pprint = ">= 1.0.4 and < 2.0.0"
gleam_otp = ">= 0.16.1 and < 1.0.0"
3 changes: 0 additions & 3 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ packages = [
{ name = "edit_distance", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "edit_distance", source = "hex", outer_checksum = "A1E485C69A70210223E46E63985FA1008B8B2DDA9848B7897469171B29020C05" },
{ name = "eventsourcing", version = "6.1.0", build_tools = ["gleam"], requirements = ["birl", "gleam_stdlib"], otp_app = "eventsourcing", source = "hex", outer_checksum = "3E2C164F72F4BCE01BBDE9E930D905104A46D25C28A0C403D1D1B57B8B74BD40" },
{ name = "filepath", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "67A6D15FB39EEB69DD31F8C145BB5A421790581BD6AA14B33D64D5A55DBD6587" },
{ name = "glam", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glam", source = "hex", outer_checksum = "66EC3BCD632E51EED029678F8DF419659C1E57B1A93D874C5131FE220DFAD2B2" },
{ name = "glance", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "glexer"], otp_app = "glance", source = "hex", outer_checksum = "784CE3B5658CF589B2E811031992FDADDFA9C7FD2A51F1140EE019F121D6D0EB" },
{ name = "gleam_community_ansi", version = "1.4.2", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_regexp", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "479DEDC748D08B310C9FEB9C4CBEC46B95C874F7F4F2844304D6D20CA78A8BB5" },
{ name = "gleam_community_colour", version = "1.4.1", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "386CB9B01B33371538672EEA8A6375A0A0ADEF41F17C86DDCB81C92AD00DA610" },
Expand All @@ -26,7 +25,6 @@ packages = [
{ name = "pg_types", version = "0.4.0", build_tools = ["rebar3"], requirements = [], otp_app = "pg_types", source = "hex", outer_checksum = "B02EFA785CAECECF9702C681C80A9CA12A39F9161A846CE17B01FB20AEEED7EB" },
{ name = "pgo", version = "0.14.0", build_tools = ["rebar3"], requirements = ["backoff", "opentelemetry_api", "pg_types"], otp_app = "pgo", source = "hex", outer_checksum = "71016C22599936E042DC0012EE4589D24C71427D266292F775EBF201D97DF9C9" },
{ name = "pog", version = "3.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "pgo"], otp_app = "pog", source = "hex", outer_checksum = "63152DADEBAE3150C81E9612909974C3C38F3E35B41F252798069A2FD117308E" },
{ name = "pprint", version = "1.0.4", build_tools = ["gleam"], requirements = ["glam", "gleam_stdlib"], otp_app = "pprint", source = "hex", outer_checksum = "C310A98BDC0995644847C3C8702DE19656D6BCD638B2A8A358B97824379ECAA1" },
{ name = "ranger", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "ranger", source = "hex", outer_checksum = "C8988E8F8CDBD3E7F4D8F2E663EF76490390899C2B2885A6432E942495B3E854" },
{ name = "rank", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "rank", source = "hex", outer_checksum = "5660E361F0E49CBB714CC57CC4C89C63415D8986F05B2DA0C719D5642FAD91C9" },
{ name = "simplifile", version = "2.2.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0DFABEF7DC7A9E2FF4BB27B108034E60C81BEBFCB7AB816B9E7E18ED4503ACD8" },
Expand All @@ -41,4 +39,3 @@ gleam_otp = { version = ">= 0.16.1 and < 1.0.0" }
gleam_stdlib = { version = ">= 0.52.0 and < 2.0.0" }
gleeunit = { version = ">= 1.2.0 and < 2.0.0" }
pog = { version = ">= 3.2.0 and < 4.0.0" }
pprint = { version = ">= 1.0.4 and < 2.0.0" }
39 changes: 8 additions & 31 deletions src/eventsourcing_postgres.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import gleam/pair
import gleam/result
import gleam/string
import pog
import pprint

// CONSTANTS ----

Expand Down Expand Up @@ -127,36 +126,14 @@ pub fn new(
eventstore:,
load_events: fn(postgres_store, tx, aggregate_id, start_from) {
load_events(postgres_store, tx, aggregate_id, start_from)
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to load events: " <> string.inspect(error),
)
})
},
commit_events: fn(tx, aggregate_id, events, metadata) {
commit_events(eventstore, tx, aggregate_id, events, metadata)
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to commit events: " <> string.inspect(error),
)
})
},
load_snapshot: fn(tx, aggregate_id) {
load_snapshot(eventstore, tx, aggregate_id)
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to load snapshot: " <> string.inspect(error),
)
})
},
save_snapshot: fn(tx, snapshot) {
save_snapshot(eventstore, tx, snapshot)
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to save snapshot: " <> string.inspect(error),
)
})
},
save_snapshot: fn(tx, snapshot) { save_snapshot(eventstore, tx, snapshot) },
execute_transaction: execute_in_transaction(db),
load_aggregate_transaction: execute_in_transaction(db),
get_latest_snapshot_transaction: execute_in_transaction(db),
Expand All @@ -178,7 +155,7 @@ fn load_events(
|> pog.execute(tx)
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to set isolation level: " <> pprint.format(error),
"Failed to set isolation level: " <> string.inspect(error),
)
}),
)
Expand Down Expand Up @@ -216,7 +193,7 @@ fn load_events(
|> result.map(fn(response) { response.rows })
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to query events: " <> pprint.format(error),
"Failed to query events: " <> string.inspect(error),
)
})
}
Expand Down Expand Up @@ -353,7 +330,7 @@ fn persist_events(
|> result.map(fn(_) { Nil })
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to insert events: " <> pprint.format(error),
"Failed to insert events: " <> string.inspect(error),
)
})
}
Expand Down Expand Up @@ -407,7 +384,7 @@ fn load_snapshot(
})
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to load snapshot: " <> pprint.format(error),
"Failed to load snapshot: " <> string.inspect(error),
)
})
}
Expand All @@ -430,7 +407,7 @@ fn save_snapshot(
|> result.map(fn(_) { Nil })
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to save snapshot: " <> pprint.format(pprint.format(error)),
"Failed to save snapshot: " <> string.inspect(error),
)
})
}
Expand All @@ -443,7 +420,7 @@ pub fn create_snapshot_table(
|> result.map(fn(_) { Nil })
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to create snapshot table: " <> pprint.format(error),
"Failed to create snapshot table: " <> string.inspect(error),
)
})
}
Expand All @@ -456,7 +433,7 @@ pub fn create_event_table(
|> result.map(fn(_) { Nil })
|> result.map_error(fn(error) {
eventsourcing.EventStoreError(
"Failed to create snapshot table: " <> pprint.format(error),
"Failed to create snapshot table: " <> string.inspect(error),
)
})
}
Expand Down

0 comments on commit 783b790

Please sign in to comment.