Giter Club home page Giter Club logo

bygone-era's Introduction

Bygone-era

bygone-era logo

A simple Java application that uses Plain Jane JDBC to connect to a local Postgres instance; what's more, it also connects to a local ReadySet instance (via port 5433). Both ReadySet and Postgres can be run via a docker compose command.

To run everything, you need to have the following installed:

  1. Java version 21
  2. Gradle 8.5
  3. Docker Engine

The two files worth looking at are AppTest.java found in the app/src/test/java/io/readyset/bygone/ directory and the Employee.java file in the app/src/main/java/io/readyset/bygone/ directory. The former class drives the latter; what's more, there are only two queries present. One is a simple point query and the other does a three way join. Both queries are supported by ReadySet. There's a lot more that can be added to this project, but it's good enough for now to demonstrate simple JDBC reads.

Directions to spin-up bygone-era

  1. First, clone this repository and then change directories into bygone-era.

  2. Decompress the employees_data.sql.bz2 file by running:

    $ bunzip2 employees_data.sql.bz2
    

    Note, you may need to install bzip2.

  3. Next, run gradle composeUp, which will start two containers. One container is named postgres-primary and exposes port 5432 and the other cache. It's exposed on port 5434. The latter container depends on the primary instance starting up successfully. When Postgres starts up, it'll execute the employees_data.sql file, which will create a large employee-like database. Additionally, ReadySet will start up and snapshot this database (this might take 2-3 minutes).

  4. I'm lazy and am making this step manual for now: wait about a minute for ReadySet to snapshot. You can check the logs for ReadySet and look for the line that says streaming replication has started and then you know things are good go. Once ReadySet is ready, run gradle test.

  5. The previous step will run 4 JUnit tests successfully if Postgres and ReadySet are running. Shell into ReadySet via psql postgresql://postgres:hoodoo@localhost:5433/hoodoo and issue a show proxied queries command. You should see two cache-able queries. Cache them via the create cache from <cache_id> command.

  6. Rerun gradle test to verify that JDBC is going through ReadySet now!

  7. You can shut both Docker containers down via the gradle composeDown command.

References

  1. Employees database for Postgres
  2. Bitnami Docker distribution documentation
  3. Gradle Docker Compose plugin

bygone-era's People

Contributors

aglover avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.