Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 1 | #ifndef AOS_STARTER_STARTER_RPC_LIB_H_ |
| 2 | #define AOS_STARTER_STARTER_RPC_LIB_H_ |
| 3 | |
| 4 | #include <chrono> |
milind upadhyay | a87957a | 2021-03-06 20:46:30 -0800 | [diff] [blame^] | 5 | #include <optional> |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 6 | |
| 7 | #include "aos/configuration.h" |
| 8 | #include "aos/starter/starter_generated.h" |
| 9 | #include "aos/starter/starter_rpc_generated.h" |
| 10 | |
| 11 | namespace aos { |
| 12 | namespace starter { |
| 13 | |
| 14 | // Finds the status of an individual application within a starter status message |
| 15 | // Returns nullptr if no application found by the given name. |
| 16 | const aos::starter::ApplicationStatus *FindApplicationStatus( |
| 17 | const aos::starter::Status &status, std::string_view name); |
| 18 | |
| 19 | // Sends the given command to the application with the name name. Creates a |
| 20 | // temporary event loop from the provided config for sending the command and |
| 21 | // receiving back status messages. Returns true if the command executed |
| 22 | // successfully, or false otherwise. Returns false if the desired state was not |
| 23 | // achieved within timeout. |
| 24 | bool SendCommandBlocking(aos::starter::Command, std::string_view name, |
| 25 | const aos::Configuration *config, |
| 26 | std::chrono::milliseconds timeout); |
| 27 | |
| 28 | // Fetches the status of the application with the given name. Creates a |
| 29 | // temporary event loop from the provided config for fetching. Returns an empty |
| 30 | // flatbuffer if the application is not found. |
| 31 | const aos::FlatbufferDetachedBuffer<aos::starter::ApplicationStatus> GetStatus( |
| 32 | std::string_view name, const aos::Configuration *config); |
| 33 | |
Philipp Schrader | 0853749 | 2021-01-23 16:17:55 -0800 | [diff] [blame] | 34 | // Fetches the entire status message of starter. Creates a temporary event loop |
| 35 | // from the provided config for fetching. |
milind upadhyay | a87957a | 2021-03-06 20:46:30 -0800 | [diff] [blame^] | 36 | std::optional<const aos::FlatbufferVector<aos::starter::Status>> GetStarterStatus( |
Philipp Schrader | 0853749 | 2021-01-23 16:17:55 -0800 | [diff] [blame] | 37 | const aos::Configuration *config); |
| 38 | |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 39 | } // namespace starter |
| 40 | } // namespace aos |
| 41 | |
| 42 | #endif // AOS_STARTER_STARTER_RPC_LIB_H_ |