pub struct FileBacklog { /* private fields */ }
Expand description
Implementations§
Source§impl FileBacklog
impl FileBacklog
Sourcepub fn new<P: AsRef<Path>>(dir: P) -> Result<Self, InfluxError>
pub fn new<P: AsRef<Path>>(dir: P) -> Result<Self, InfluxError>
Construct file based backlog by providing a directory to write Record files to.
Examples found in repository?
examples/simple.rs (line 19)
16fn main() -> Result<(), InfluxError>
17{
18 let creds = Credentials::from_basic("testuser", "testpasswd");
19 let backlog = FileBacklog::new("./ignore/backlog")?;
20
21 let mut client = Client::build("http://127.0.0.1:8086".into(), creds)
22 .backlog(backlog)
23 .finish()?;
24
25 let mut rec = Record::new("org", "bucket")
26 .precision(Precision::Milliseconds);
27
28 loop
29 {
30 rec.measurement("sensor1")
31 .tag("floor", "second")
32 .tag("exposure", "west")
33 .field("temp", 123)
34 .field("brightness", 500);
35
36 rec.measurement("sensor2")
37 .tag("floor", "second")
38 .tag("exposure", "east")
39 .field("temp", 321)
40 .field("brightness", 999);
41
42 if let Err(e) = client.write(&rec) {
43 eprintln!("{}", e);
44 }
45
46 sleep(Duration::from_secs(1));
47 }
48}
Trait Implementations§
Source§impl Backlog for FileBacklog
impl Backlog for FileBacklog
Source§fn read_pending(&mut self) -> Result<Vec<Record>, InfluxError>
fn read_pending(&mut self) -> Result<Vec<Record>, InfluxError>
Return any pending records that sits in backlog and requires to be commited.
Source§fn write_pending(&mut self, record: &Record) -> Result<(), InfluxError>
fn write_pending(&mut self, record: &Record) -> Result<(), InfluxError>
Write records that could not be commited, so they get written into backlog for future processing.
Source§fn truncate_pending(&mut self, record: &Record) -> Result<(), InfluxError>
fn truncate_pending(&mut self, record: &Record) -> Result<(), InfluxError>
Empty backlog from pending records. This gets called once all pending records have been
successfully commited.
Auto Trait Implementations§
impl Freeze for FileBacklog
impl RefUnwindSafe for FileBacklog
impl Send for FileBacklog
impl Sync for FileBacklog
impl Unpin for FileBacklog
impl UnwindSafe for FileBacklog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more