Skip to content

Instantly share code, notes, and snippets.

@AlexPikalov
Created December 29, 2016 15:57
Show Gist options
  • Save AlexPikalov/a202c593b143a4a86f3532c3debed87a to your computer and use it in GitHub Desktop.
Save AlexPikalov/a202c593b143a4a86f3532c3debed87a to your computer and use it in GitHub Desktop.
CDRS session
use cdrs::client::{CDRS, Credentials, Session};
use cdrs::{error as cdrs_error};
use cdrs::authenticators::{Authenticator, PasswordAuthenticator};
use cdrs::compression::Compression;
fn main() {
let addr = "127.0.0.1:9042";
let authenticator = PasswordAuthenticator::new("user", "password");
let mut session = new_session(addr, authenticator).unwrap();
// ... work with session
session.end();
}
// Creates new session with server of addres `addr` using provided authenticator
fn new_session<A: Authenticator>(addr: &str, authenticator: A) -> cdrs_error::Result<Session<A>> {
let cdrs = CDRS::new(addr, authenticator);
// establish session without compression so far
return cdrs.start(Compression::None);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment