Add event loop application starter
New application starter reads a configuration file with the list of
applications and their properties (arguments, binary name, etc.) and
manages starting and restarting them. The status of applications are
reported on an event loop channel and they can be controlled with a
separate starter_cmd tool.
Change-Id: I7691840be38dc28887e48efcdff7926590710eb7
diff --git a/aos/starter/starter_rpc_lib.h b/aos/starter/starter_rpc_lib.h
new file mode 100644
index 0000000..57c9e6b
--- /dev/null
+++ b/aos/starter/starter_rpc_lib.h
@@ -0,0 +1,36 @@
+#ifndef AOS_STARTER_STARTER_RPC_LIB_H_
+#define AOS_STARTER_STARTER_RPC_LIB_H_
+
+#include <chrono>
+
+#include "aos/configuration.h"
+#include "aos/starter/starter_generated.h"
+#include "aos/starter/starter_rpc_generated.h"
+
+namespace aos {
+namespace starter {
+
+// Finds the status of an individual application within a starter status message
+// Returns nullptr if no application found by the given name.
+const aos::starter::ApplicationStatus *FindApplicationStatus(
+ const aos::starter::Status &status, std::string_view name);
+
+// Sends the given command to the application with the name name. Creates a
+// temporary event loop from the provided config for sending the command and
+// receiving back status messages. Returns true if the command executed
+// successfully, or false otherwise. Returns false if the desired state was not
+// achieved within timeout.
+bool SendCommandBlocking(aos::starter::Command, std::string_view name,
+ const aos::Configuration *config,
+ std::chrono::milliseconds timeout);
+
+// Fetches the status of the application with the given name. Creates a
+// temporary event loop from the provided config for fetching. Returns an empty
+// flatbuffer if the application is not found.
+const aos::FlatbufferDetachedBuffer<aos::starter::ApplicationStatus> GetStatus(
+ std::string_view name, const aos::Configuration *config);
+
+} // namespace starter
+} // namespace aos
+
+#endif // AOS_STARTER_STARTER_RPC_LIB_H_