From 2b4d62b086802ece28f1288bd09cbf5f252c45d7 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 15 May 2018 18:12:32 -0700 Subject: progress on database lookup --- rust/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'rust/src/lib.rs') 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>; +/// 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 { dotenv().ok(); let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set"); -- cgit v1.2.3