blob: 57c9e6b0361b54de9784746c697a39242bd2ab6c [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
33} // namespace starter
34} // namespace aos
35
36#endif // AOS_STARTER_STARTER_RPC_LIB_H_