GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - atlassian-labs/db-replica: Automatically chooses between database connections to read-write main or read-only replica

BranchesTags
Open more actions menu

Latest commit

 

History

334 Commits
334 Commits

Folders and files

NameName
Last commit message
Last commit date
.atlassian
.atlassian
 
 
.github/workflows
.github/workflows
 
 
docs
docs
 
 
gradle
gradle
 
 
src
src
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.sdkmanrc
.sdkmanrc
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODEOWNERS
CODEOWNERS
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle.kts
build.gradle.kts
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle.kts
settings.gradle.kts
 
 

Repository files navigation

db-replica

CI license PRs Welcome

Using database replicas unlocks horizontal scalability. Some replica designs force replicas to be read-only. Read-only queries can be sent to the replica, while others have to go to the main DB. The db-replica API automatically routes the queries to the correct node. It integrates at the java.sql.Connection level, so you don't have to hunt down hundreds of queries manually.

High level overview

Features

  • Automatic switching between main and replica databases.
  • Configurable consistency model.
  • Configurable main/replica split instrumentation.

Usage

The library is not available via Maven Central Repository yet. It can be accessed via Atlassian Maven proxy.

import com.atlassian.db.replica.api.*;
import java.sql.*;
import java.time.*;

class Example {

    private final ReplicaConsistency consistency = new PessimisticPropagationConsistency.Builder().build();

    ResultSet queryReplicaOrMain(String sql) {
        try (ConnectionProvider connectionProvider = new PostgresConnectionProvider()) {
            Connection connection = DualConnection.builder(connectionProvider, consistency).build();
            return connection.prepareStatement(sql).executeQuery();
        }
    }
}

Installation

Maven:

<dependency>
    <groupId>com.atlassian.db.replica</groupId>
    <artifactId>db-replica</artifactId>
    <version>2.9.0</version>
</dependency>

Documentation

See Javadoc of classes in the api and spi packages. See DualConnection states UML. See how to release the library.

Tests

Run all checks: ./gradlew build Run just the unit tests: ./gradlew test Run mutation tests: ./gradlew pitest

Contributions

Please see CONTRIBUTING.md for details.

License

Apache 2.0 licensed, see LICENSE file.

With ❤️ from Atlassian

About

Automatically chooses between database connections to read-write main or read-only replica

Topics

jdbcreplicareplicationsql

Resources

Readme
Apache-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing
Activity
Custom properties

Stars

10 stars

Watchers

7 watching

Forks

10 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.