Struct stitch::StitchClient
[−]
[src]
pub struct StitchClient { /* fields omitted */ }
Holds an inner representation of a stitch client. This type can be created on a separate thread and sent messages over a channel, or can be safely cloned many times on a single thread.
Methods
impl StitchClient
[src]
pub fn new<S>(handle: &Handle, client_id: u32, auth_token: S) -> Result<Self> where
S: Into<String>,
[src]
S: Into<String>,
Create a new stitch client.
pub fn client_id(&self) -> u32
[src]
Returns the client_id
.
pub fn upsert_record<T>(&self, data: T) -> UpsertRequest<T> where
T: Message + Serialize + 'static,
[src]
T: Message + Serialize + 'static,
Upserts a single Message
, as a future.
pub fn get_status(&self) -> Future<Response>
[src]
Returns the current status of the stitch api, as a future.
pub fn validate_batch<T>(&self, record: Vec<T>) -> Future<Chunk> where
T: Message + Serialize + 'static,
[src]
T: Message + Serialize + 'static,
Validates a batch of Messages
, as a future.
pub fn upsert_batch<T>(&self, record: Vec<T>) -> Future<Chunk> where
T: Message + Serialize + 'static,
[src]
T: Message + Serialize + 'static,
Upserts a batch of Messages
, as a future.
pub fn buffer_channel<T>(
&self,
batch_size: usize,
stream: Receiver<T>
) -> Future<()> where
T: Message + Serialize + 'static,
[src]
&self,
batch_size: usize,
stream: Receiver<T>
) -> Future<()> where
T: Message + Serialize + 'static,
Returns a future that represents a buffered stream,
represented by a futures::sync::mpsc::Receiver
.
The stream is chunked and each batch is sent to stitch.
Failures are logged and dropped.
Examples
ⓘThis example is not tested
extern crate futures; extern crate stitch; extern crate tokio_core; use std::thread; use futures::sync::mpsc::channel; use stitch::StitchClient; use tokio_core::reactor::Core; fn main() { let (mut tx, mut rx) = channel(10); let t = thread::spawn(move || { let mut core = Core::new().unwrap(); let client = StitchClient::new(&core.handle(), 1, "auth_token_1").unwrap(); core.run(client.buffer_channel(20, rx)).unwrap(); }); }
ⓘThis example is not tested
extern crate futures; extern crate stitch; extern crate tokio_core; use futures::sync::mpsc::channel; use stitch::StitchClient; use tokio_core::reactor::Core; fn main() { let mut core = Core::new().unwrap(); let client = StitchClient::new(&core.handle(), 1, "auth_token_1").unwrap(); let (mut tx, mut rx) = channel(10); core.run(client.buffer_channel(20, rx)).unwrap(); }
Trait Implementations
impl Clone for StitchClient
[src]
fn clone(&self) -> StitchClient
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more