blob: 152016a94cc8d835e16b045c003642d8facf17e0 [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>
5
6#include "aos/configuration.h"
7#include "aos/starter/starter_generated.h"
8#include "aos/starter/starter_rpc_generated.h"
9
10namespace aos {
11namespace 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.
15const 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.
23bool 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.
30const aos::FlatbufferDetachedBuffer<aos::starter::ApplicationStatus> GetStatus(
31 std::string_view name, const aos::Configuration *config);
32
Philipp Schrader08537492021-01-23 16:17:55 -080033// Fetches the entire status message of starter. Creates a temporary event loop
34// from the provided config for fetching.
35const aos::FlatbufferVector<aos::starter::Status> GetStarterStatus(
36 const aos::Configuration *config);
37
Tyler Chatowa79419d2020-08-12 20:12:11 -070038} // namespace starter
39} // namespace aos
40
41#endif // AOS_STARTER_STARTER_RPC_LIB_H_