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> |
| 5 | |
| 6 | #include "aos/configuration.h" |
| 7 | #include "aos/starter/starter_generated.h" |
| 8 | #include "aos/starter/starter_rpc_generated.h" |
| 9 | |
| 10 | namespace aos { |
| 11 | namespace starter { |
| 12 | |
| 13 | // Finds the status of an individual application within a starter status message |
| 14 | // Returns nullptr if no application found by the given name. |
| 15 | const aos::starter::ApplicationStatus *FindApplicationStatus( |
| 16 | const aos::starter::Status &status, std::string_view name); |
| 17 | |
| 18 | // Sends the given command to the application with the name name. Creates a |
| 19 | // temporary event loop from the provided config for sending the command and |
| 20 | // receiving back status messages. Returns true if the command executed |
| 21 | // successfully, or false otherwise. Returns false if the desired state was not |
| 22 | // achieved within timeout. |
| 23 | bool SendCommandBlocking(aos::starter::Command, std::string_view name, |
| 24 | const aos::Configuration *config, |
| 25 | std::chrono::milliseconds timeout); |
| 26 | |
| 27 | // Fetches the status of the application with the given name. Creates a |
| 28 | // temporary event loop from the provided config for fetching. Returns an empty |
| 29 | // flatbuffer if the application is not found. |
| 30 | const aos::FlatbufferDetachedBuffer<aos::starter::ApplicationStatus> GetStatus( |
| 31 | std::string_view name, const aos::Configuration *config); |
| 32 | |
| 33 | } // namespace starter |
| 34 | } // namespace aos |
| 35 | |
| 36 | #endif // AOS_STARTER_STARTER_RPC_LIB_H_ |