Oracle support for the r2d2 connection pool

Overview

r2d2-oracle

Build Status Crates.io Crates.io unsafe forbidden

The documentation can be found on docs.rs.

Oracle support for the r2d2 connection pool. This fits in between the r2d2 connection manager and oracle database driver crates.

Usage

See the documentation of r2d2 for the details on how to use the connection pool.

use std::thread;
use r2d2_oracle::OracleConnectionManager;

fn main() {
    let manager = OracleConnectionManager::new("user", "password", "localhost");
    let pool = r2d2::Pool::builder()
         .max_size(15)
         .build(manager)
         .unwrap();
    
    for _ in 0..20 {
        let pool = pool.clone();
        thread::spawn(move || {
            let conn = pool.get().unwrap();
            // use the connection
            // it will be returned to the pool when it falls out of scope.
        });
    }
}

If you want to use chrono data types, enable the chrono feature:

[dependencies]
r2d2-oracle = { version = "0.2.0", features = ["chrono"] }

Changelog

For the changelog please see the dedicated CHANGELOG.md.

Current Status of the Crate & Roadmap to v1.0.0

This is the initial release of the crate and has not yet been proven in production. Nevertheless: the crate is very small so not many problems are expected. The precondition for releasing v1.0.0 is that both r2d2 and oracle have released their v1.0.0.

Build-time Requirements

The crate is tested against stable rust and rust 1.42.0 (which was the stable version at the time the crate has been built). It is possible that it works with older versions as well but this is not tested. Please see the details of the r2d2 and oracle crates about their requirements.

Comments
  • Add

    Add "chrono" feature

    rust-oracle crate provides a feature that adds various trait implementations for the chrono crate that are particularly useful when working with dates. This PR adds chrono feature that enables the chrono feature in rust-oracle

    opened by LokiVKlokeNaAndoke 7
  • Loosen version requirement?

    Loosen version requirement?

    Would it be possible to change the oracle version listed in Cargo.toml to just "0.3"? It would be nice to be able to pull in new patch versions without having to wait for this library to update.

    opened by mlh758 5
  • Sharing the R2D2 Connection Pool Within the App

    Sharing the R2D2 Connection Pool Within the App

    I need to create a DB connection pool in main.rs upon initilization of the app, keep the pool active forever and let it be used from within the functions that need an Oracle connection. The examples on the web stay mostly within a web framework (like Actix) scope and utilize the frameworks' capabilities to share some kind of global state or data.

    In my use case, I don't use a web framework and my functions are in fact "workers" with a standardized API running infinitely and handling some jobs by polling tasks from a workflow engine (each on a separate thread). Some of those functions need a Postgres connection, others Oracle, some both, and some do not make a DB connection at all, so passing pools as a parameter is not a good option.

    For Postgres connections, I create the pool with SQLx crate and I use the once_cell crate to share from main.rs to other files. What do you think is the best way of sharing a R2D2 tool for this case?

    Thanks a lot!

    opened by IdemenB 2
  • Implement review feedback

    Implement review feedback

    this implements the review feedback given by @kubo in kubo/rust-oracle#15

    the only thing missing is the simplified has_broken implementation. i'll wait for @kubo to check if he can provide an API in his crate which internally uses oracle's OCI_ATTR_SERVER_STATUS.

    @kubo: could you please review this PR? thanks!

    opened by rursprung 2
  • travis: run test+clippy with $FEATURES

    travis: run test+clippy with $FEATURES

    without this test and clippy would be executed without the feature flag also in the build path with the feature flag and would thus not actually test the path with the feature flag.

    opened by rursprung 1
  • Upgrade to GitHub-native Dependabot

    Upgrade to GitHub-native Dependabot

    Dependabot Preview will be shut down on August 3rd, 2021. In order to keep getting Dependabot updates, please merge this PR and migrate to GitHub-native Dependabot before then.

    Dependabot has been fully integrated into GitHub, so you no longer have to install and manage a separate app. This pull request migrates your configuration from Dependabot.com to a config file, using the new syntax. When merged, we'll swap out dependabot-preview (me) for a new dependabot app, and you'll be all set!

    With this change, you'll now use the Dependabot page in GitHub, rather than the Dependabot dashboard, to monitor your version updates, and you'll configure Dependabot through the new config file rather than a UI.

    If you've got any questions or feedback for us, please let us know by creating an issue in the dependabot/dependabot-core repository.

    Learn more about migrating to GitHub-native Dependabot

    Please note that regular @dependabot commands do not work on this pull request.

    dependencies 
    opened by dependabot-preview[bot] 0
  • Update oracle requirement from 0.4.0 to 0.5.1

    Update oracle requirement from 0.4.0 to 0.5.1

    Updates the requirements on oracle to permit the latest version.

    Changelog

    Sourced from oracle's changelog.

    Change Log

    0.5.0 (2021-04-18)

    • Add [Batch DML][Batch] feature (GH-29[])
    • Implement FromStr for Version.
    • Add OracleType::Json variant. (Note: JSON data type has not been supported yet.)

    0.4.0 (2021-03-07)

    Changes:

    • Based on ODPI-C 4.1.0
    • The return value of [DbError.offset()][] was changed from u16 to u32.

    0.3.3 (2020-10-25)

    Changes:

    • Add new methods [Connection.call_timeout()][] and [Connection.set_call_timeout()][]

    0.3.2 (2019-11-14)

    Changes:

    • Fix SEGV while getting Object type's FLOAT data type attributes. (GH-19[])

    • Add workaround to use with tracing-core. (GH-18[])

    0.3.1 (2019-10-05)

    Changes:

    • Add a new method [Connection.status()][] and a new enum [ConnStatus][] to get the status of the connection.

    0.3.0 (2019-10-02)

    Incompatible changes:

    • Remove ConnParam enum and add Connector struct to use builder pattern.
      • The fourth argument of Connection::connect was removed.
        From:
        let conn = Connection::connect(username, password, connect_string, &[])?;
        
        To:
        let conn = Connection::connect(username, password, connect_string)?;
        

    ... (truncated)

    Commits
    • 9415d4b Fix documents and bump version to 0.5.1.
    • 3816ec1 Bump version to 0.5.0.
    • c2af039 make BatchBindIndex public
    • 65447bb Impl FromStr for Version, add tests for Version
    • 7cb9986 Check Oracle versions in tests
    • 95553cd Fix doc comments
    • 0f62963 Rename Batch.bind to Batch.set and add Batch.set_type.
    • ad88116 Add OracleType::Json (JSON data type has not been supported yet.)
    • 2fb0d92 Change tests in doc comments
    • b9413db Fix links in doc comments
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)
    dependencies 
    opened by dependabot-preview[bot] 0
  • update minimum rust requirement to 1.42.0

    update minimum rust requirement to 1.42.0

    with commit efe65cc i introduced the usage of the matches! macro. what i didn't realise was that this had only been introduced with rust 1.42.0. sorry!

    lession learnt: go through a pull request even for simple things - this ensures that the full test matrix is executed! (because i of course didn't try to compile with 1.38.0 locally...).

    i presume that nobody will be using an old rust version anymore, so it's probably save enough to just bump the minimum requirement. if somebody is still using 1.38.0 .. < 1.42.0 you can stay on 0.3.x until you can upgrade your compiler.

    opened by rursprung 0
  • Update oracle requirement from 0.3.1 to 0.4.0

    Update oracle requirement from 0.3.1 to 0.4.0

    Updates the requirements on oracle to permit the latest version.

    Changelog

    Sourced from oracle's changelog.

    0.4.0 (2021-03-07)

    Changes:

    • Based on ODPI-C 4.1.0
    • The return value of [DbError.offset()][] was changed from u16 to u32.

    0.3.3 (2020-10-25)

    Changes:

    • Add new methods [Connection.call_timeout()][] and [Connection.set_call_timeout()][]

    0.3.2 (2019-11-14)

    Changes:

    • Fix SEGV while getting Object type's FLOAT data type attributes. (GH-19[])

    • Add workaround to use with tracing-core. (GH-18[])

    0.3.1 (2019-10-05)

    Changes:

    • Add a new method [Connection.status()][] and a new enum [ConnStatus][] to get the status of the connection.

    0.3.0 (2019-10-02)

    Incompatible changes:

    • Remove ConnParam enum and add Connector struct to use builder pattern.
      • The fourth argument of Connection::connect was removed.
        From:
        let conn = Connection::connect(username, password, connect_string, &[])?;
        
        To:
        let conn = Connection::connect(username, password, connect_string)?;
        
      • Use Connector to use additional parameters.
        From:
        let conn = Connection::connect(username, password, connect_string, &[ConnParam::Sysdba])?;
        
        To:
        let conn = Connector::new(username, password, connect_string).privilege(Privilege::Sysdba).connect()?;
        

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Note: This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

    You can always request more updates by clicking Bump now in your Dependabot dashboard.

    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)
    dependencies 
    opened by dependabot-preview[bot] 0
Releases(v0.5.0)
Owner
Ralph Ursprung
Ralph Ursprung
r2d2-cypher is a r2d2 connection pool for rusted-cypher

r2d2-cypher is a r2d2 connection pool for rusted-cypher

Markus Kohlhase 10 Oct 16, 2021
LDAP support for the r2d2 connection pool

r2d2-ldap LDAP support for the r2d2 connection pool Install Add this to your Cargo.toml: [dependencies] r2d2-ldap = "0.1.1" Basic Usage use std::threa

Aitor Ruano 2 Nov 7, 2020
rust-mysql-simple support library for the r2d2 connection pool

r2d2-mysql rust-mysql-simple support library for the r2d2 connection pool.

outersky 44 Nov 1, 2022
Memcached support for the r2d2 connection pool (Rust)

Memcached support for the r2d2 connection pool (Rust)

川田 恵氏 (Kawada Keishi a.k.a megumish) 4 Jul 12, 2022
rust-postgres support library for the r2d2 connection pool

r2d2-postgres Documentation rust-postgres support library for the r2d2 connection pool. Example use std::thread; use r2d2_postgres::{postgres::NoTls,

Steven Fackler 128 Dec 26, 2022
ODBC adapter for r2d2 connection pool

ODBC adapter for r2d2 connection pool

Konstantin V. Salikhov 9 Nov 3, 2021
Skytable rust client support library for the bb8 connection pool

bb8-skytable Skytable rust client support library for the bb8 connection pool. Heavily based on bb8-redis Basic usage example use bb8_skytable::{

null 3 Sep 18, 2021
A generic connection pool for Rust

r2d2 A generic connection pool for Rust. Documentation Opening a new database connection every time one is needed is both inefficient and can lead to

Steven Fackler 1.2k Jan 8, 2023
Quick Pool: High Performance Rust Async Resource Pool

Quick Pool High Performance Rust Async Resource Pool Usage DBCP Database Backend Adapter Version PostgreSQL tokio-postgres qp-postgres Example use asy

Seungjae Park 13 Aug 23, 2022
This is an Oracle database driver for Rust based on ODPI-C

Rust-oracle This is an Oracle database driver for Rust based on ODPI-C. Change Log See ChangeLog.md. Build-time Requirements C compiler. See Compile-t

Kubo Takehiro 138 Dec 23, 2022
Streaming Network Overlay Connection Arbitration Tunnel

SNOCAT Streaming Network Overlay Connection Arbitration Tunnel snocat is a framework for forwarding streams across authenticated, encrypted QUIC tunne

Microsoft 52 Nov 16, 2022
Diesel async connection implementation

A async interface for diesel Diesel gets rid of the boilerplate for database interaction and eliminates runtime errors without sacrificing performance

Georg Semmler 293 Dec 26, 2022
Lightweight async Redis client with connection pooling written in pure Rust and 100% memory safe

redi-rs (or redirs) redi-rs is a Lightweight Redis client with connection pooling written in Rust and 100% memory safe redi-rs is a Redis client writt

Oğuz Türkay 4 May 20, 2023
An async executor based on the Win32 thread pool API

wae An async executor based on the Win32 thread pool API use futures::channel::oneshot; #[wae::main] async fn main() { let (tx, rx) = oneshot::ch

Raphaël Thériault 10 Dec 10, 2021
This represents staked SOL, and can be sold for wSOL in the wSOL/stSOL Liquidity Pool

This represents staked SOL, and can be sold for wSOL in the wSOL/stSOL Liquidity Pool (paying a fee to skip the unstaking cool-down period). The value of your stSOL holdings is automatically incremented each epoch when staking rewards are paid.

null 2 Jun 4, 2022
A lock-free, append-only atomic pool.

A lock-free, append-only atomic pool. This library implements an atomic, append-only collection of items, where individual items can be acquired and r

Jon Gjengset 64 Oct 24, 2022
High-performance, lock-free local and concurrent object memory pool with automated allocation, cleanup, and verification.

Opool: Fast lock-free concurrent and local object pool Opool is a high-performance Rust library that offers a concurrent and local object pool impleme

Khashayar Fereidani 8 Jun 3, 2023
PgBouncer rewritten in Rust, with sharding, load balancing and failover support

PgCat Meow. PgBouncer rewritten in Rust, with sharding, load balancing and failover support. Alpha: don't use in production just yet. Local developmen

Lev Kokotov 1.2k Jan 7, 2023
Simple and flexible queue implementation for Rust with support for multiple backends (Redis, RabbitMQ, SQS, etc.)

Omniqueue Omniqueue is an abstraction layer over queue backends for Rust. It includes support for RabbitMQ, Redis streams, and SQS out of the box. The

Svix 8 May 26, 2023