{"id":20754505,"url":"https://github.com/atlassian-labs/db-replica","last_synced_at":"2025-04-28T16:29:38.941Z","repository":{"id":38843796,"uuid":"318680248","full_name":"atlassian-labs/db-replica","owner":"atlassian-labs","description":"Automatically chooses between database connections to read-write main or read-only replica","archived":false,"fork":false,"pushed_at":"2024-06-13T13:48:11.000Z","size":1546,"stargazers_count":10,"open_issues_count":8,"forks_count":12,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-30T11:23:18.780Z","etag":null,"topics":["jdbc","replica","replication","sql"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atlassian-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null}},"created_at":"2020-12-05T02:01:33.000Z","updated_at":"2024-04-07T17:33:12.000Z","dependencies_parsed_at":"2023-01-19T16:45:58.584Z","dependency_job_id":"a97caa6e-e7d6-4923-9da5-47ac16c98f7c","html_url":"https://github.com/atlassian-labs/db-replica","commit_stats":null,"previous_names":[],"tags_count":110,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atlassian-labs%2Fdb-replica","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atlassian-labs%2Fdb-replica/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atlassian-labs%2Fdb-replica/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atlassian-labs%2Fdb-replica/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atlassian-labs","download_url":"https://codeload.github.com/atlassian-labs/db-replica/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251345558,"owners_count":21574735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jdbc","replica","replication","sql"],"created_at":"2024-11-17T09:18:05.677Z","updated_at":"2025-04-28T16:29:38.926Z","avatar_url":"https://github.com/atlassian-labs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# db-replica\n![CI](https://github.com/atlassian-labs/db-replica/workflows/CI/badge.svg)\n[![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square)](LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](CONTRIBUTING.md)\n\nUsing database replicas unlocks horizontal scalability. Some replica designs force replicas to be read-only.\nRead-only queries can be sent to the replica, while others have to go to the main DB.\nThe `db-replica` API automatically routes the queries to the correct node.\nIt integrates at the `java.sql.Connection` level, so you don't have to hunt down hundreds of queries manually.\n\n![High level overview](docs/high-level-overview.png \"High level overview\")\n\n## Features\n\n- [Automatic switching between main and replica databases](docs/switching-between-main-and-replica.md).\n- [Configurable consistency model](docs/consistency.md).\n- [Configurable main/replica split instrumentation](docs/split-instrumentation.md).\n\n## Usage\n\nThe library is [not available via Maven Central Repository](https://github.com/atlassian-labs/db-replica/issues/18) yet. It can be accessed via\n[Atlassian Maven proxy](https://developer.atlassian.com/server/framework/atlassian-sdk/atlassian-maven-repositories-2818705/#atlassian-maven-proxy-).\n\n```java\nimport com.atlassian.db.replica.api.*;\nimport java.sql.*;\nimport java.time.*;\n\nclass Example {\n\n    private final ReplicaConsistency consistency = new PessimisticPropagationConsistency.Builder().build();\n\n    ResultSet queryReplicaOrMain(String sql) {\n        try (ConnectionProvider connectionProvider = new PostgresConnectionProvider()) {\n            Connection connection = DualConnection.builder(connectionProvider, consistency).build();\n            return connection.prepareStatement(sql).executeQuery();\n        }\n    }\n}\n```\n\n## Installation\n\nMaven:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.atlassian.db.replica\u003c/groupId\u003e\n    \u003cartifactId\u003edb-replica\u003c/artifactId\u003e\n    \u003cversion\u003e2.9.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Documentation\n\nSee Javadoc of classes in the `api` and `spi` packages.\nSee [DualConnection states UML](docs/dual-connection-states.md).\nSee [how to release the library](docs/release/releasing.md).\n\n## Tests\n\nRun all checks: `./gradlew build`\nRun just the unit tests: `./gradlew test`\nRun mutation tests: `./gradlew pitest`\n\n## Contributions\n\nPlease see [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\n## License\n\nApache 2.0 licensed, see [LICENSE](LICENSE) file.\n\n[![With ❤️ from Atlassian][cheers img]](https://www.atlassian.com)\n\n[cheers img]: https://raw.githubusercontent.com/atlassian-internal/oss-assets/master/banner-cheers-light.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatlassian-labs%2Fdb-replica","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatlassian-labs%2Fdb-replica","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatlassian-labs%2Fdb-replica/lists"}