blob: 7d6de8739c208aa3b409e8743690281f0658130f [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
milind upadhyay4272f382021-04-07 18:03:08 -070019// Checks if the name is an executable name and if it is, it returns that
20// application's name, otherwise returns name as given
21std::string_view FindApplication(const std::string_view &name,
22 const aos::Configuration *config);
23
Tyler Chatowa79419d2020-08-12 20:12:11 -070024// Sends the given command to the application with the name name. Creates a
25// temporary event loop from the provided config for sending the command and
26// receiving back status messages. Returns true if the command executed
27// successfully, or false otherwise. Returns false if the desired state was not
28// achieved within timeout.
29bool SendCommandBlocking(aos::starter::Command, std::string_view name,
30 const aos::Configuration *config,
31 std::chrono::milliseconds timeout);
32
33// Fetches the status of the application with the given name. Creates a
34// temporary event loop from the provided config for fetching. Returns an empty
35// flatbuffer if the application is not found.
36const aos::FlatbufferDetachedBuffer<aos::starter::ApplicationStatus> GetStatus(
37 std::string_view name, const aos::Configuration *config);
38
Philipp Schrader08537492021-01-23 16:17:55 -080039// Fetches the entire status message of starter. Creates a temporary event loop
40// from the provided config for fetching.
milind upadhyay4272f382021-04-07 18:03:08 -070041std::optional<const aos::FlatbufferVector<aos::starter::Status>>
42GetStarterStatus(const aos::Configuration *config);
Philipp Schrader08537492021-01-23 16:17:55 -080043
Tyler Chatowa79419d2020-08-12 20:12:11 -070044} // namespace starter
45} // namespace aos
46
47#endif // AOS_STARTER_STARTER_RPC_LIB_H_