file_source/
lib.rs

1#![deny(warnings)]
2#![deny(clippy::all)]
3
4#[macro_use]
5extern crate scan_fmt;
6
7pub mod buffer;
8mod checkpointer;
9mod file_server;
10mod file_watcher;
11mod fingerprinter;
12mod internal_events;
13mod metadata_ext;
14pub mod paths_provider;
15
16pub use self::{
17    checkpointer::{Checkpointer, CheckpointsView, CHECKPOINT_FILE_NAME},
18    file_server::{calculate_ignore_before, FileServer, Line, Shutdown as FileServerShutdown},
19    fingerprinter::{FileFingerprint, FingerprintStrategy, Fingerprinter},
20    internal_events::FileSourceInternalEvents,
21};
22use vector_config::configurable_component;
23
24pub type FilePosition = u64;
25
26#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
27pub enum ReadFrom {
28    #[default]
29    Beginning,
30    End,
31    Checkpoint(FilePosition),
32}
33
34/// File position to use when reading a new file.
35#[configurable_component]
36#[derive(Copy, Clone, Debug, PartialEq, Eq)]
37#[serde(rename_all = "snake_case")]
38pub enum ReadFromConfig {
39    /// Read from the beginning of the file.
40    Beginning,
41
42    /// Start reading from the current end of the file.
43    End,
44}
45
46impl From<ReadFromConfig> for ReadFrom {
47    fn from(rfc: ReadFromConfig) -> Self {
48        match rfc {
49            ReadFromConfig::Beginning => ReadFrom::Beginning,
50            ReadFromConfig::End => ReadFrom::End,
51        }
52    }
53}