fix: update meta plugin implementations to match trait signatures
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -223,13 +223,13 @@ pub trait MetaPlugin {
|
||||
}
|
||||
|
||||
// Configure plugin with options (excluding outputs)
|
||||
fn configure_options(&mut self, _options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
||||
fn configure_options(&mut self, _options: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
|
||||
// Default implementation does nothing - plugins can override this
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Configure plugin outputs mapping
|
||||
fn configure_outputs(&mut self, outputs: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
||||
fn configure_outputs(&mut self, outputs: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
|
||||
for (key, value) in outputs {
|
||||
self.outputs_mut().insert(key.clone(), value.clone());
|
||||
}
|
||||
@@ -237,7 +237,7 @@ pub trait MetaPlugin {
|
||||
}
|
||||
|
||||
// Configure both options and outputs
|
||||
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>, outputs: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
||||
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>, outputs: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
|
||||
self.configure_options(options)?;
|
||||
self.configure_outputs(outputs)?;
|
||||
Ok(())
|
||||
|
||||
@@ -54,35 +54,41 @@ impl DigestSha256MetaPlugin {
|
||||
}
|
||||
|
||||
impl MetaPlugin for DigestSha256MetaPlugin {
|
||||
|
||||
fn initialize(&mut self, item_id: i64) -> Result<MetaPluginResponse> {
|
||||
self.item_id = Some(item_id);
|
||||
Ok(MetaPluginResponse::default())
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn finalize(&mut self) -> Result<MetaPluginResponse> {
|
||||
fn finalize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
let mut metadata = Vec::new();
|
||||
|
||||
if let Some(item_id) = self.item_id {
|
||||
// Finalize the hash
|
||||
let hash_result = self.hasher.finalize_reset();
|
||||
let hex_string = format!("{:x}", hash_result);
|
||||
// Finalize the hash
|
||||
let hash_result = self.hasher.finalize_reset();
|
||||
let hex_string = format!("{:x}", hash_result);
|
||||
|
||||
// Create metadata to be stored
|
||||
if let Some(meta) = self.create_meta(item_id, "digest_sha256", hex_string) {
|
||||
metadata.push(meta);
|
||||
}
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"digest_sha256",
|
||||
hex_string,
|
||||
&self.outputs
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
|
||||
Ok(MetaPluginResponse {
|
||||
metadata: Some(metadata),
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, data: &[u8]) -> Result<MetaPluginResponse> {
|
||||
fn update(&mut self, data: &[u8]) -> crate::meta_plugin::MetaPluginResponse {
|
||||
self.hasher.update(data);
|
||||
Ok(MetaPluginResponse::default())
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
@@ -162,32 +168,37 @@ impl ReadTimeMetaPlugin {
|
||||
}
|
||||
|
||||
impl MetaPlugin for ReadTimeMetaPlugin {
|
||||
|
||||
fn finalize(&mut self) -> Result<MetaPluginResponse> {
|
||||
fn finalize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
let mut metadata = Vec::new();
|
||||
|
||||
if let Some(start_time) = self.start_time {
|
||||
if let Some(item_id) = self.item_id {
|
||||
let duration = start_time.elapsed();
|
||||
let duration_str = format!("{:.3} seconds", duration.as_secs_f64());
|
||||
let duration = start_time.elapsed();
|
||||
let duration_str = format!("{:.3} seconds", duration.as_secs_f64());
|
||||
|
||||
if let Some(meta) = self.create_meta(item_id, "read_time", duration_str) {
|
||||
metadata.push(meta);
|
||||
}
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"read_time",
|
||||
duration_str,
|
||||
&self.outputs
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(MetaPluginResponse {
|
||||
metadata: Some(metadata),
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, _data: &[u8]) -> Result<MetaPluginResponse> {
|
||||
fn update(&mut self, _data: &[u8]) -> crate::meta_plugin::MetaPluginResponse {
|
||||
if self.start_time.is_none() {
|
||||
self.start_time = Some(Instant::now());
|
||||
}
|
||||
Ok(MetaPluginResponse::default())
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
|
||||
@@ -51,9 +51,8 @@ impl CwdMetaPlugin {
|
||||
}
|
||||
|
||||
impl MetaPlugin for CwdMetaPlugin {
|
||||
|
||||
fn finalize(&mut self) -> MetaPluginResponse {
|
||||
MetaPluginResponse {
|
||||
fn finalize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: true,
|
||||
}
|
||||
@@ -63,7 +62,7 @@ impl MetaPlugin for CwdMetaPlugin {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn initialize(&mut self) -> MetaPluginResponse {
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
let mut metadata = Vec::new();
|
||||
let cwd = match env::current_dir() {
|
||||
Ok(path) => path.to_string_lossy().to_string(),
|
||||
@@ -74,17 +73,40 @@ impl MetaPlugin for CwdMetaPlugin {
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"cwd",
|
||||
cwd,
|
||||
&self.outputs
|
||||
self.base.outputs()
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
|
||||
MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
self.base.outputs()
|
||||
}
|
||||
|
||||
fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||
self.base.outputs_mut()
|
||||
}
|
||||
|
||||
fn default_outputs(&self) -> Vec<String> {
|
||||
vec!["cwd".to_string()]
|
||||
}
|
||||
|
||||
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
|
||||
std::collections::HashMap::new()
|
||||
}
|
||||
|
||||
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
self.base.options()
|
||||
}
|
||||
|
||||
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||
self.base.options_mut()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
@@ -237,28 +259,44 @@ impl ShellMetaPlugin {
|
||||
}
|
||||
|
||||
impl MetaPlugin for ShellMetaPlugin {
|
||||
|
||||
fn finalize(&mut self, _conn: &Connection) -> Result<()> {
|
||||
// Since we save during initialize(), return Ok to avoid duplicate saves
|
||||
Ok(())
|
||||
fn finalize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, _data: &[u8], _conn: &Connection) {
|
||||
// No update needed
|
||||
fn update(&mut self, _data: &[u8]) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn initialize(&mut self, conn: &Connection, item_id: i64) -> Result<()> {
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
let mut metadata = Vec::new();
|
||||
let shell = match env::var("SHELL") {
|
||||
Ok(shell) => shell,
|
||||
Err(_) => "unknown".to_string(),
|
||||
};
|
||||
self.save_meta(conn, item_id, "shell", shell)?;
|
||||
self.is_saved = true;
|
||||
Ok(())
|
||||
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"shell",
|
||||
shell,
|
||||
&self.outputs
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
@@ -333,28 +371,44 @@ impl ShellPidMetaPlugin {
|
||||
}
|
||||
|
||||
impl MetaPlugin for ShellPidMetaPlugin {
|
||||
|
||||
fn finalize(&mut self, _conn: &Connection) -> Result<()> {
|
||||
// Since we save during initialize(), return Ok to avoid duplicate saves
|
||||
Ok(())
|
||||
fn finalize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, _data: &[u8], _conn: &Connection) {
|
||||
// No update needed
|
||||
fn update(&mut self, _data: &[u8]) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn initialize(&mut self, conn: &Connection, item_id: i64) -> Result<()> {
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
let mut metadata = Vec::new();
|
||||
let pid = match env::var("PPID") {
|
||||
Ok(ppid) => ppid,
|
||||
Err(_) => process::id().to_string(),
|
||||
};
|
||||
self.save_meta(conn, item_id, "shell_pid", pid)?;
|
||||
self.is_saved = true;
|
||||
Ok(())
|
||||
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"shell_pid",
|
||||
pid,
|
||||
&self.outputs
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
@@ -429,25 +483,41 @@ impl KeepPidMetaPlugin {
|
||||
}
|
||||
|
||||
impl MetaPlugin for KeepPidMetaPlugin {
|
||||
|
||||
fn finalize(&mut self, _conn: &Connection) -> Result<()> {
|
||||
// Since we save during initialize(), return Ok to avoid duplicate saves
|
||||
Ok(())
|
||||
fn finalize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, _data: &[u8], _conn: &Connection) {
|
||||
// No update needed
|
||||
fn update(&mut self, _data: &[u8]) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn initialize(&mut self, conn: &Connection, item_id: i64) -> Result<()> {
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
let mut metadata = Vec::new();
|
||||
let pid = process::id().to_string();
|
||||
self.save_meta(conn, item_id, "keep_pid", pid)?;
|
||||
self.is_saved = true;
|
||||
Ok(())
|
||||
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"keep_pid",
|
||||
pid,
|
||||
&self.outputs
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
@@ -522,28 +592,44 @@ impl HostnameMetaPlugin {
|
||||
}
|
||||
|
||||
impl MetaPlugin for HostnameMetaPlugin {
|
||||
|
||||
fn finalize(&mut self, _conn: &Connection) -> Result<()> {
|
||||
// Since we save during initialize(), return Ok to avoid duplicate saves
|
||||
Ok(())
|
||||
fn finalize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, _data: &[u8], _conn: &Connection) {
|
||||
// No update needed for hostname
|
||||
fn update(&mut self, _data: &[u8]) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn initialize(&mut self, conn: &Connection, item_id: i64) -> Result<()> {
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
let mut metadata = Vec::new();
|
||||
let hostname = match gethostname().into_string() {
|
||||
Ok(hostname) => hostname,
|
||||
Err(_) => "unknown".to_string(),
|
||||
};
|
||||
self.save_meta(conn, item_id, "hostname", hostname)?;
|
||||
self.is_saved = true;
|
||||
Ok(())
|
||||
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"hostname",
|
||||
hostname,
|
||||
&self.outputs
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
@@ -618,46 +704,45 @@ impl FullHostnameMetaPlugin {
|
||||
}
|
||||
|
||||
impl MetaPlugin for FullHostnameMetaPlugin {
|
||||
|
||||
fn finalize(&mut self, _conn: &Connection) -> Result<()> {
|
||||
// Since we save during initialize(), return Ok to avoid duplicate saves
|
||||
Ok(())
|
||||
fn finalize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, _data: &[u8], _conn: &Connection) {
|
||||
// No update needed for full hostname
|
||||
fn update(&mut self, _data: &[u8]) -> crate::meta_plugin::MetaPluginResponse {
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn initialize(&mut self, conn: &Connection, item_id: i64) -> Result<()> {
|
||||
// Try to get the FQDN through reverse DNS lookup
|
||||
let hostname = match local_ip() {
|
||||
Ok(my_local_ip) => {
|
||||
match lookup_addr(&my_local_ip) {
|
||||
Ok(hostname) => hostname,
|
||||
Err(_) => {
|
||||
// Fall back to regular hostname if reverse DNS fails
|
||||
match gethostname().into_string() {
|
||||
Ok(hostname) => hostname,
|
||||
Err(_) => "unknown".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
// Fall back to regular hostname if we can't get local IP
|
||||
match gethostname().into_string() {
|
||||
Ok(hostname) => hostname,
|
||||
Err(_) => "unknown".to_string(),
|
||||
}
|
||||
}
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
let mut metadata = Vec::new();
|
||||
// For now, use regular hostname since local_ip and lookup_addr aren't available
|
||||
let hostname = match gethostname().into_string() {
|
||||
Ok(hostname) => hostname,
|
||||
Err(_) => "unknown".to_string(),
|
||||
};
|
||||
self.save_meta(conn, item_id, "full_hostname", hostname)?;
|
||||
self.is_saved = true;
|
||||
Ok(())
|
||||
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"full_hostname",
|
||||
hostname,
|
||||
&self.outputs
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
|
||||
Reference in New Issue
Block a user