Skip to content

Commit

Permalink
Change type of uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
marcmo committed Aug 30, 2020
1 parent 3dd8a57 commit 1e78e2f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
24 changes: 12 additions & 12 deletions north/src/command_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,47 +40,47 @@ pub async fn process(
reply: sync::Sender<Vec<u8>>,
) -> Result<()> {
debug!("Processing command: {:X?}", command);
match parse_from_bytes::<api::Command>(&command) {
match parse_from_bytes::<api::Request>(&command) {
Ok(_) => (),
Err(e) => debug!("Could not parse from bytes: {}", e),
}
let command = parse_from_bytes::<api::Command>(&command)?;
let command = parse_from_bytes::<api::Request>(&command)?;
info!("Running command:\'{}\'", command.get_description());

let start_timestamp = time::Instant::now();
let response: Result<api::Response> = 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 {
None
};
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 {
None
};
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 {
None
};
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 {
Expand Down Expand Up @@ -136,7 +136,7 @@ async fn ps(state: &State) -> Result<api::Response> {
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"))]
{
Expand Down
2 changes: 1 addition & 1 deletion north_api/src/proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
16 changes: 8 additions & 8 deletions north_api/src/proto/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3979,7 +3979,7 @@ pub struct ProcessInfo {
shared: ::std::option::Option<u64>,
text: ::std::option::Option<u64>,
data: ::std::option::Option<u64>,
uptime: ::std::option::Option<i64>,
uptime: ::std::option::Option<u64>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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);
},
_ => {
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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\
Expand Down

0 comments on commit 1e78e2f

Please sign in to comment.