blob: 24c757e1dadbb2add5e5548ac4fc723e3147fe60 [file] [log] [blame]
Tyler Chatowa79419d2020-08-12 20:12:11 -07001#ifndef AOS_STARTER_STARTER_RPC_LIB_H_
2#define AOS_STARTER_STARTER_RPC_LIB_H_
3
4#include <chrono>
milind upadhyaya87957a2021-03-06 20:46:30 -08005#include <optional>
Tyler Chatowa79419d2020-08-12 20:12:11 -07006
7#include "aos/configuration.h"
8#include "aos/starter/starter_generated.h"
9#include "aos/starter/starter_rpc_generated.h"
10
11namespace aos {
12namespace 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.
16const 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.
24bool 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.
31const aos::FlatbufferDetachedBuffer<aos::starter::ApplicationStatus> GetStatus(
32 std::string_view name, const aos::Configuration *config);
33
Philipp Schrader08537492021-01-23 16:17:55 -080034// Fetches the entire status message of starter. Creates a temporary event loop
35// from the provided config for fetching.
milind upadhyaya87957a2021-03-06 20:46:30 -080036std::optional<const aos::FlatbufferVector<aos::starter::Status>> GetStarterStatus(
Philipp Schrader08537492021-01-23 16:17:55 -080037 const aos::Configuration *config);
38
Tyler Chatowa79419d2020-08-12 20:12:11 -070039} // namespace starter
40} // namespace aos
41
42#endif // AOS_STARTER_STARTER_RPC_LIB_H_