joshprzybyszewski / cribbage

A cribbage scorer and game
MIT License
2 stars 1 forks source link

Using DynamoDB as an option for persistence #101

Closed joshprzybyszewski closed 2 years ago

joshprzybyszewski commented 3 years ago

What broke / What you're adding

We have an in-memory DB, mysql DB, and mongodb DB. Unfornuately, in-memory is ephemeral, mysql is stood up in RDS and we pay for uptime, and I don't like mongodb. So let's add a DB that is pay-as-you-use and can store our games for us in aws.

How you did it

Add another set of services to talk to dynamodb using the AWS go sdk v2 (v1 is deprecated or something). Also, stand up a local dynamodb instance in docker-compose so that you can test locally.

How to test it and how to try to break it

  1. Run make dockerbuild
  2. In the docker-compose, change the image of cribbage-server to image: cribbage:latest.
  3. go to localhost:18080 and start playing a game
  4. tear down the dynamodb container (using ctop) and notice that your games are all borked.
codecov[bot] commented 3 years ago

Codecov Report

Merging #101 (22040cd) into master (a775d02) will increase coverage by 1.12%. The diff coverage is 76.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #101      +/-   ##
==========================================
+ Coverage   69.35%   70.47%   +1.12%     
==========================================
  Files          80       86       +6     
  Lines        3455     3948     +493     
==========================================
+ Hits         2396     2782     +386     
- Misses        835      894      +59     
- Partials      224      272      +48     
Impacted Files Coverage Δ
server/setup.go 0.00% <0.00%> (ø)
...r/persistence/dynamo/dynamo_service_interaction.go 69.60% <69.60%> (ø)
server/persistence/dynamo/dynamo_service_player.go 71.07% <71.07%> (ø)
server/persistence/dynamo/dynamo_service_game.go 79.20% <79.20%> (ø)
server/persistence/dynamo/dynamodb.go 79.55% <79.55%> (ø)
server/persistence/dynamo/dynamo_utils.go 90.48% <90.48%> (ø)
server/dbutils.go 62.96% <100.00%> (+0.70%) :arrow_up:
server/interaction/npc.go 89.09% <100.00%> (+0.20%) :arrow_up:
server/persistence/dynamo/utils.go 100.00% <100.00%> (ø)
server/persistence/mysql/games.go 71.30% <0.00%> (+0.87%) :arrow_up:
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a775d02...22040cd. Read the comment docs.

cszczepaniak commented 3 years ago

Finally finished my first pass

cszczepaniak commented 3 years ago

Just one outstanding discussion I'd like to finish up before I go for a QA

joshprzybyszewski commented 2 years ago

@cszczepaniak I think I've found a better way to express condition expressions that meets our needs without adding more complexity. let me know what you think.

cszczepaniak commented 2 years ago

QA +1 I was able to get the local docker stack up and running with dynamo I was able to register two people, start a game, make some moves, then restart the go server and see the games still be there and in the correct state. I killed dynamo and saw that I couldn't login or register a player. It seems we have a timeout of 30s for dynamo requests, so we may want to tweak that later, because the user sees it as an unresponsive webpage. Nonetheless, that's a follow up, and everything with dynamo seems peachy image