diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-15 18:12:32 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-15 18:12:39 -0700 |
commit | 2b4d62b086802ece28f1288bd09cbf5f252c45d7 (patch) | |
tree | 6d82c1fe431c3456566eca7590e024e4c970d049 /rust/src/lib.rs | |
parent | 69e9497686a05c8b27d5496e5ff66664c785c25b (diff) | |
download | fatcat-2b4d62b086802ece28f1288bd09cbf5f252c45d7.tar.gz fatcat-2b4d62b086802ece28f1288bd09cbf5f252c45d7.zip |
progress on database lookup
Diffstat (limited to 'rust/src/lib.rs')
-rw-r--r-- | rust/src/lib.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 56364be0..196dee36 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -3,6 +3,7 @@ extern crate fatcat_api; extern crate chrono; #[macro_use] extern crate diesel; +extern crate uuid; extern crate dotenv; extern crate futures; #[macro_use] @@ -15,6 +16,7 @@ extern crate r2d2; pub mod api_server; pub mod database_schema; +pub mod database_models; mod errors { error_chain!{} @@ -31,6 +33,8 @@ use std::env; pub type ConnectionPool = r2d2::Pool<ConnectionManager<diesel::pg::PgConnection>>; +/// Establish a direct database connection. Not currently used, but could be helpful for +/// single-threaded tests or utilities. pub fn establish_connection() -> PgConnection { dotenv().ok(); @@ -38,7 +42,7 @@ pub fn establish_connection() -> PgConnection { PgConnection::establish(&database_url).expect(&format!("Error connecting to {}", database_url)) } -/// Instantiate a new server. +/// Instantiate a new API server with a pooled database connection pub fn server() -> Result<api_server::Server> { dotenv().ok(); let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set"); |