From 1e78e2f71c1b2fec30256759d0f2eeaa90918ddd Mon Sep 17 00:00:00 2001 From: Oliver Mueller Date: Wed, 26 Aug 2020 10:33:54 +0200 Subject: [PATCH] Change type of uptime --- north/src/command_processor.rs | 24 ++++++++++++------------ north_api/src/proto/api.proto | 2 +- north_api/src/proto/api.rs | 16 ++++++++-------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/north/src/command_processor.rs b/north/src/command_processor.rs index 95bae321f..869eb344a 100644 --- a/north/src/command_processor.rs +++ b/north/src/command_processor.rs @@ -40,18 +40,18 @@ pub async fn process( reply: sync::Sender>, ) -> Result<()> { debug!("Processing command: {:X?}", command); - match parse_from_bytes::(&command) { + match parse_from_bytes::(&command) { Ok(_) => (), Err(e) => debug!("Could not parse from bytes: {}", e), } - let command = parse_from_bytes::(&command)?; + let command = parse_from_bytes::(&command)?; info!("Running command:\'{}\'", command.get_description()); let start_timestamp = time::Instant::now(); let response: Result = match command.instruction { - Some(api::Command_oneof_instruction::list_containers(_)) => list(state).await, - Some(api::Command_oneof_instruction::running_containers(_)) => ps(state).await, - Some(api::Command_oneof_instruction::start_container(ref id)) => { + Some(api::Request_oneof_instruction::list_containers(_)) => list(state).await, + Some(api::Request_oneof_instruction::running_containers(_)) => ps(state).await, + Some(api::Request_oneof_instruction::start_container(ref id)) => { let regex = if id.has_regex() { Some(id.get_regex()) } else { @@ -59,7 +59,7 @@ pub async fn process( }; start(state, regex).await } - Some(api::Command_oneof_instruction::stop_container(ref id)) => { + Some(api::Request_oneof_instruction::stop_container(ref id)) => { let regex = if id.has_regex() { Some(id.get_regex()) } else { @@ -67,7 +67,7 @@ pub async fn process( }; stop(state, regex).await } - Some(api::Command_oneof_instruction::uninstall_container(ref id)) => { + Some(api::Request_oneof_instruction::uninstall_container(ref id)) => { let regex = if id.has_regex() { Some(id.get_regex()) } else { @@ -75,12 +75,12 @@ pub async fn process( }; uninstall(state, regex).await } - Some(api::Command_oneof_instruction::update(ref dir)) => { + Some(api::Request_oneof_instruction::update(ref dir)) => { update(state, dir.get_update_dir()).await } - Some(api::Command_oneof_instruction::shutdown(_)) => shutdown(state).await, - Some(api::Command_oneof_instruction::get_settings(_)) => settings().await, - Some(api::Command_oneof_instruction::get_versions(_)) => versions(state).await, + Some(api::Request_oneof_instruction::shutdown(_)) => shutdown(state).await, + Some(api::Request_oneof_instruction::get_settings(_)) => settings().await, + Some(api::Request_oneof_instruction::get_versions(_)) => versions(state).await, _ => Err(anyhow!("Unknown command: {:?}", command)), }; match response { @@ -136,7 +136,7 @@ async fn ps(state: &State) -> Result { process_info.set_name(app.name().to_string()); process_info.set_pid(context.process().pid()); process_info.set_version(app.version().to_string()); - process_info.set_uptime(context.uptime().as_nanos() as i64); + process_info.set_uptime(context.uptime().as_nanos() as u64); #[cfg(any(target_os = "android", target_os = "linux"))] { diff --git a/north_api/src/proto/api.proto b/north_api/src/proto/api.proto index d57c0b750..6e1128e8a 100644 --- a/north_api/src/proto/api.proto +++ b/north_api/src/proto/api.proto @@ -86,7 +86,7 @@ message ProcessInfo { optional uint64 shared = 6; // in byte optional uint64 text = 7; // in byte optional uint64 data = 8; // in byte - optional int64 uptime = 9; // in us + optional uint64 uptime = 9; // in us } message ProcessList { repeated ProcessInfo processes = 1; } diff --git a/north_api/src/proto/api.rs b/north_api/src/proto/api.rs index 7345b477c..92970010f 100644 --- a/north_api/src/proto/api.rs +++ b/north_api/src/proto/api.rs @@ -3979,7 +3979,7 @@ pub struct ProcessInfo { shared: ::std::option::Option, text: ::std::option::Option, data: ::std::option::Option, - uptime: ::std::option::Option, + uptime: ::std::option::Option, // special fields pub unknown_fields: ::protobuf::UnknownFields, pub cached_size: ::protobuf::CachedSize, @@ -4182,10 +4182,10 @@ impl ProcessInfo { self.data = ::std::option::Option::Some(v); } - // optional int64 uptime = 9; + // optional uint64 uptime = 9; - pub fn get_uptime(&self) -> i64 { + pub fn get_uptime(&self) -> u64 { self.uptime.unwrap_or(0) } pub fn clear_uptime(&mut self) { @@ -4197,7 +4197,7 @@ impl ProcessInfo { } // Param is passed by value, moved - pub fn set_uptime(&mut self, v: i64) { + pub fn set_uptime(&mut self, v: u64) { self.uptime = ::std::option::Option::Some(v); } } @@ -4272,7 +4272,7 @@ impl ::protobuf::Message for ProcessInfo { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } - let tmp = is.read_int64()?; + let tmp = is.read_uint64()?; self.uptime = ::std::option::Option::Some(tmp); }, _ => { @@ -4345,7 +4345,7 @@ impl ::protobuf::Message for ProcessInfo { os.write_uint64(8, v)?; } if let Some(v) = self.uptime { - os.write_int64(9, v)?; + os.write_uint64(9, v)?; } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) @@ -4425,7 +4425,7 @@ impl ::protobuf::Message for ProcessInfo { |m: &ProcessInfo| { &m.data }, |m: &mut ProcessInfo| { &mut m.data }, )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( "uptime", |m: &ProcessInfo| { &m.uptime }, |m: &mut ProcessInfo| { &mut m.uptime }, @@ -6812,7 +6812,7 @@ static file_descriptor_proto_data: &'static [u8] = b"\ zeB\0\x12\x1c\n\x08resident\x18\x05\x20\x01(\x04R\x08residentB\0\x12\x18\ \n\x06shared\x18\x06\x20\x01(\x04R\x06sharedB\0\x12\x14\n\x04text\x18\ \x07\x20\x01(\x04R\x04textB\0\x12\x14\n\x04data\x18\x08\x20\x01(\x04R\ - \x04dataB\0\x12\x18\n\x06uptime\x18\t\x20\x01(\x03R\x06uptimeB\0\"+\n\ + \x04dataB\0\x12\x18\n\x06uptime\x18\t\x20\x01(\x04R\x06uptimeB\0\"+\n\ \x04Type\x12\x07\n\x03APP\x10\0\x12\x0c\n\x08RESOURCE\x10\x01\x12\n\n\ \x06SYSTEM\x10\x02\x1a\0:\0\"C\n\x0bProcessList\x122\n\tprocesses\x18\ \x01\x20\x03(\x0b2\x12.north.ProcessInfoR\tprocessesB\0:\0\"I\n\rContain\