vector/enrichment_tables/
mod.rs1use std::path::PathBuf;
3
4use enum_dispatch::enum_dispatch;
5use vector_lib::configurable::configurable_component;
6pub use vector_lib::enrichment::{Condition, IndexHandle, Table};
7
8use crate::config::{
9 ComponentKey, EnrichmentTableConfig, GenerateConfig, GlobalOptions, SinkConfig, SourceConfig,
10};
11
12pub mod file;
13
14#[cfg(feature = "enrichment-tables-memory")]
15pub mod memory;
16
17#[cfg(feature = "enrichment-tables-geoip")]
18pub mod geoip;
19
20#[cfg(feature = "enrichment-tables-mmdb")]
21pub mod mmdb;
22
23#[configurable_component(global_option("enrichment_tables"))]
39#[derive(Clone, Debug)]
40#[serde(tag = "type", rename_all = "snake_case")]
41#[enum_dispatch(EnrichmentTableConfig)]
42#[configurable(metadata(
43 docs::enum_tag_description = "enrichment table type",
44 docs::common = false,
45 docs::required = false,
46))]
47pub enum EnrichmentTables {
48 File(file::FileConfig),
50
51 #[cfg(feature = "enrichment-tables-memory")]
54 Memory(memory::MemoryConfig),
55
56 #[cfg(feature = "enrichment-tables-geoip")]
61 Geoip(geoip::GeoipConfig),
62
63 #[cfg(feature = "enrichment-tables-mmdb")]
67 Mmdb(mmdb::MmdbConfig),
68}
69
70impl GenerateConfig for EnrichmentTables {
71 fn generate_config() -> toml::Value {
72 toml::Value::try_from(Self::File(file::FileConfig {
73 file: file::FileSettings {
74 path: "path/to/file".into(),
75 encoding: file::Encoding::default(),
76 },
77 schema: Default::default(),
78 }))
79 .unwrap()
80 }
81}
82
83impl EnrichmentTables {
84 pub fn files_to_watch(&self) -> Vec<&PathBuf> {
86 match self {
87 EnrichmentTables::File(file_config) => vec![&file_config.file.path],
88 #[cfg(feature = "enrichment-tables-memory")]
89 EnrichmentTables::Memory(_) => vec![],
90 #[cfg(feature = "enrichment-tables-geoip")]
91 EnrichmentTables::Geoip(geoip_config) => vec![&geoip_config.path],
92 #[cfg(feature = "enrichment-tables-mmdb")]
93 EnrichmentTables::Mmdb(mmdb_config) => vec![&mmdb_config.path],
94 }
95 }
96}