| 1 | use netdata_plugin_protocol::{ |
| 2 | ConfigDeclaration, DynCfgCmds, DynCfgSourceType, DynCfgStatus, DynCfgType, HttpAccess, |
| 3 | }; |
| 4 | use netdata_plugin_protocol::{Message, MessageWriter}; |
| 5 | |
| 6 | #[tokio::main] |
| 7 | async fn main() { |
| 8 | // Create a sample ConfigDeclaration |
| 9 | let config_declaration = ConfigDeclaration { |
| 10 | id: "go.d:nginx".to_string(), |
| 11 | status: DynCfgStatus::Accepted, |
| 12 | type_: DynCfgType::Template, |
| 13 | path: "/collectors".to_string(), |
| 14 | source_type: DynCfgSourceType::Internal, |
| 15 | source: "whatever internal source".to_string(), |
| 16 | cmds: DynCfgCmds::SCHEMA | DynCfgCmds::ADD | DynCfgCmds::ENABLE | DynCfgCmds::DISABLE, |
| 17 | view_access: HttpAccess::empty(), |
| 18 | edit_access: HttpAccess::empty(), |
| 19 | }; |
| 20 | |
| 21 | // Create message from the config declaration |
| 22 | let message = Message::ConfigDeclaration(Box::new(config_declaration)); |
| 23 | |
| 24 | // Create message writer for stdout |
| 25 | let stdout = tokio::io::stdout(); |
| 26 | let mut writer = MessageWriter::new(stdout); |
| 27 | |
| 28 | // Send the message to stdout |
| 29 | match writer.send(message).await { |
| 30 | Ok(()) => { |
| 31 | // Message sent successfully |
| 32 | } |
| 33 | Err(e) => { |
| 34 | eprintln!("Error sending message: {}", e); |
| 35 | } |
| 36 | } |
| 37 | } |