blob: 75951679b6762417447c1a01095057ee0956155e [file] [log] [blame]
Alex Perrycb7da4b2019-08-28 19:35:56 -07001include "reflection/reflection.fbs";
2
Austin Schuhcb108412019-10-13 16:09:54 -07003namespace aos;
4
Austin Schuh719946b2019-12-28 14:51:01 -08005enum LoggerConfig : ubyte {
6 // This data should be logged on this node.
7 LOCAL_LOGGER,
8 // This data should be logged on a remote node.
9 REMOTE_LOGGER,
10 // This data should not be logged.
11 NOT_LOGGED,
12 // This data should be logged both on this node and on the remote node.
13 // This is useful where you want to log a message on both the sender and
14 // receiver to create self-contained log files.
15 LOCAL_AND_REMOTE_LOGGER
16}
17
18table Connection {
19 // Node name to forward to.
Austin Schuh38912b12020-10-03 18:23:31 -070020 name:string (id: 0);
Austin Schuh719946b2019-12-28 14:51:01 -080021
22 // How the delivery timestamps for this connection should be logged. Do we
23 // log them with the local logger (i.e. the logger running on the node that
24 // this message is delivered to)? Do we log them on another node (a central
25 // logging node)? Do we log them in both places redundantly?
Austin Schuh38912b12020-10-03 18:23:31 -070026 timestamp_logger:LoggerConfig = LOCAL_LOGGER (id: 1);
Austin Schuh719946b2019-12-28 14:51:01 -080027
28 // If the corresponding delivery timestamps for this channel are logged
29 // remotely, which node should be responsible for logging the data. Note:
30 // for now, this can only be the source node. Empty implies the node this
31 // connection is connecting to (i.e. name).
Austin Schuh38912b12020-10-03 18:23:31 -070032 timestamp_logger_nodes:[string] (id: 2);
Austin Schuh719946b2019-12-28 14:51:01 -080033
34 // Priority to forward data with.
Austin Schuh38912b12020-10-03 18:23:31 -070035 priority:ushort = 100 (id: 3);
Austin Schuh719946b2019-12-28 14:51:01 -080036
37 // Time to live in nanoseconds before the message is dropped.
38 // A value of 0 means no timeout, i.e. reliable. When a client connects, the
39 // latest message from this channel will be sent regardless.
40 // TODO(austin): We can retry more than just the last message on reconnect
41 // if we want. This is an unlikely scenario though.
Austin Schuh38912b12020-10-03 18:23:31 -070042 time_to_live:uint = 0 (id: 4);
Austin Schuh719946b2019-12-28 14:51:01 -080043}
44
Brian Silverman77162972020-08-12 19:52:40 -070045enum ReadMethod : ubyte {
46 // Copy all the data out of shared memory into a local buffer for each reader.
47 COPY,
48 // Pin the data in shared memory and read directly from there.
49 PIN,
50}
51
Austin Schuh40485ed2019-10-26 21:51:44 -070052// Table representing a channel. Channels are where data is published and
Austin Schuhcb108412019-10-13 16:09:54 -070053// subscribed from. The tuple of name, type is the identifying information.
Austin Schuh40485ed2019-10-26 21:51:44 -070054table Channel {
55 // Name of the channel.
Austin Schuh38912b12020-10-03 18:23:31 -070056 name:string (id: 0);
Austin Schuhcb108412019-10-13 16:09:54 -070057 // Type name of the flatbuffer.
Austin Schuh38912b12020-10-03 18:23:31 -070058 type:string (id: 1);
Austin Schuh40485ed2019-10-26 21:51:44 -070059 // Max frequency in messages/sec of the data published on this channel.
Eric Schmiedebergef44b8a2022-02-28 17:30:38 -070060 // The maximum number of messages that can be sent
61 // in a channel_storage_duration is
62 // frequency * channel_storage_duration (in seconds).
Austin Schuh38912b12020-10-03 18:23:31 -070063 frequency:int = 100 (id: 2);
Austin Schuh719946b2019-12-28 14:51:01 -080064 // Max size of the data being published. (This will hopefully be
65 // automatically computed in the future.)
Austin Schuh38912b12020-10-03 18:23:31 -070066 max_size:int = 1000 (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -070067
Austin Schuh80c7fce2019-12-05 20:48:43 -080068 // Sets the maximum number of senders on a channel.
Austin Schuh38912b12020-10-03 18:23:31 -070069 num_senders:int = 10 (id: 4);
Austin Schuh80c7fce2019-12-05 20:48:43 -080070 // Sets the maximum number of watchers on a channel.
Austin Schuh38912b12020-10-03 18:23:31 -070071 num_watchers:int = 10 (id: 5);
Austin Schuh80c7fce2019-12-05 20:48:43 -080072
Alex Perrycb7da4b2019-08-28 19:35:56 -070073 // The schema for the data sent on this channel.
Austin Schuh38912b12020-10-03 18:23:31 -070074 schema:reflection.Schema (id: 6);
Austin Schuh217a9782019-12-21 23:02:50 -080075
76 // The source node name for the data sent on this channel.
77 // If nodes is populated below, this needs to also be populated.
Austin Schuh38912b12020-10-03 18:23:31 -070078 source_node:string (id: 7);
Austin Schuh217a9782019-12-21 23:02:50 -080079
Austin Schuh719946b2019-12-28 14:51:01 -080080 // The destination nodes for data sent on this channel.
Austin Schuh217a9782019-12-21 23:02:50 -080081 // This only needs to be populated if this message is getting forwarded.
Austin Schuh38912b12020-10-03 18:23:31 -070082 destination_nodes:[Connection] (id: 8);
Austin Schuh719946b2019-12-28 14:51:01 -080083
84 // What service is responsible for logging this channel:
Austin Schuh38912b12020-10-03 18:23:31 -070085 logger:LoggerConfig = LOCAL_LOGGER (id: 9);
Austin Schuh719946b2019-12-28 14:51:01 -080086 // If the channel is logged remotely, which node should be responsible for
87 // logging the data. Note: this requires that the data is forwarded to the
88 // node responsible for logging it. Empty implies the node this connection
89 // is connecting to (i.e. name).
Austin Schuh38912b12020-10-03 18:23:31 -070090 logger_nodes:[string] (id: 10);
Brian Silverman77162972020-08-12 19:52:40 -070091
92 // The way messages are read from shared memory for this channel.
Austin Schuh38912b12020-10-03 18:23:31 -070093 read_method:ReadMethod = COPY (id: 11);
Brian Silverman77162972020-08-12 19:52:40 -070094
95 // Sets the maximum number of senders on a channel.
96 //
97 // Currently, this must be set if and only if read_method is PIN.
Austin Schuh38912b12020-10-03 18:23:31 -070098 num_readers:int (id: 12);
Austin Schuhcb108412019-10-13 16:09:54 -070099}
100
Austin Schuh40485ed2019-10-26 21:51:44 -0700101// Table to support renaming channel names.
Austin Schuhcb108412019-10-13 16:09:54 -0700102table Map {
Austin Schuh40485ed2019-10-26 21:51:44 -0700103 // Channel to match with. If the name in here matches, the name is replaced
Austin Schuhf1fff282020-03-28 16:57:32 -0700104 // with the name in rename. If the name ends in *, it will be treated like a
105 // wildcard. Anything with the same prefix will match, and anything matching
106 // the * will get preserved on rename. This supports moving subfolders.
Austin Schuhbca6cf02019-12-22 17:28:34 -0800107 // Node specific matches are also supported.
Austin Schuh38912b12020-10-03 18:23:31 -0700108 match:Channel (id: 0);
Austin Schuh40485ed2019-10-26 21:51:44 -0700109 // The channel to merge in.
Austin Schuh38912b12020-10-03 18:23:31 -0700110 rename:Channel (id: 1);
Austin Schuhcb108412019-10-13 16:09:54 -0700111}
112
113// Application specific information.
114table Application {
115 // Name of the application.
Austin Schuh38912b12020-10-03 18:23:31 -0700116 name:string (id: 0);
Tyler Chatowa79419d2020-08-12 20:12:11 -0700117
118 // Path of the executable relative to starter. If this field is unset, use
119 // name as the path. Not permitted to change while starter is running.
120 executable_name:string (id: 5);
121
Austin Schuhcb108412019-10-13 16:09:54 -0700122 // List of maps to apply for this specific application. Application specific
123 // maps are applied in reverse order, and before the global maps.
124 // For example
125 // "maps": [ { "match": { "name": "/foo" }, "rename": { "name": "/bar" } } ]
Austin Schuh40485ed2019-10-26 21:51:44 -0700126 // will make it so any channels named "/foo" actually go to "/bar" for just
Austin Schuhcb108412019-10-13 16:09:54 -0700127 // this application. This is super handy for running an application twice
Austin Schuh40485ed2019-10-26 21:51:44 -0700128 // publishing to different channels, or for injecting a little application
Austin Schuhcb108412019-10-13 16:09:54 -0700129 // to modify messages live for testing.
130 //
131 // "maps": [
132 // { "match": { "name": "/foo" }, "rename": { "name": "/bar" } },
133 // { "match": { "name": "/foo" }, "rename": { "name": "/baz" } }
134 // ]
135 //
136 // will map "/foo" to "/baz", even if there is a global list of maps.
Austin Schuh38912b12020-10-03 18:23:31 -0700137 maps:[Map] (id: 1);
Austin Schuh217a9782019-12-21 23:02:50 -0800138
139 // The node that this application will be started on.
140 // TODO(austin): Teach starter how to use this for starting applications.
Austin Schuh38912b12020-10-03 18:23:31 -0700141 nodes:[string] (id: 2);
Brian Silverman2713ed52020-09-22 22:23:14 -0700142
143 // The user to run this application as. If this field is unset, run it as
144 // the current user of the application starter.
Austin Schuh38912b12020-10-03 18:23:31 -0700145 user:string (id: 3);
Tyler Chatowa79419d2020-08-12 20:12:11 -0700146
147 // List of arguments to be passed to application
148 args:[string] (id: 4);
Austin Schuh5f79a5a2021-10-12 17:46:50 -0700149
150 // Indicates that application should be executed on boot.
151 autostart:bool = true (id: 6);
James Kuszmaule7c7e582022-01-07 18:50:01 -0800152
153 // Indicates that application should automatically restart on failure.
154 autorestart:bool = true (id: 7);
Austin Schuh217a9782019-12-21 23:02:50 -0800155}
156
157// Per node data and connection information.
158table Node {
159 // Short name for the node. This provides a short hand to make it easy to
160 // setup forwarding rules as part of the channel setup.
Austin Schuh38912b12020-10-03 18:23:31 -0700161 name:string (id: 0);
Austin Schuh217a9782019-12-21 23:02:50 -0800162
163 // Hostname used to identify and connect to the node.
Austin Schuh38912b12020-10-03 18:23:31 -0700164 hostname:string (id: 1);
Austin Schuh217a9782019-12-21 23:02:50 -0800165 // Port to serve forwarded data from.
Austin Schuh38912b12020-10-03 18:23:31 -0700166 port:ushort = 9971 (id: 2);
Brian Silvermanaa2633f2020-02-17 21:04:14 -0800167
168 // An alternative to hostname which allows specifying multiple hostnames,
169 // any of which will match this node.
170 //
171 // Don't specify a hostname in multiple nodes in the same configuration.
Austin Schuh38912b12020-10-03 18:23:31 -0700172 hostnames:[string] (id: 3);
Austin Schuhd60967a2020-10-19 09:34:42 -0700173
174 // An arbitrary list of strings representing properties of each node. These
175 // can be used to store information about roles.
176 tags:[string] (id: 4);
Austin Schuhcb108412019-10-13 16:09:54 -0700177}
178
179// Overall configuration datastructure for the pubsub.
180table Configuration {
Austin Schuh40485ed2019-10-26 21:51:44 -0700181 // List of channels.
182 channels:[Channel] (id: 0);
Austin Schuhcb108412019-10-13 16:09:54 -0700183 // List of global maps. These are applied in reverse order.
184 maps:[Map] (id: 1);
Austin Schuh217a9782019-12-21 23:02:50 -0800185
186 // If present, this is the list of nodes in the system. If this is not
187 // present, AOS will be running in a single node configuration.
188 nodes:[Node] (id: 4);
189
Austin Schuhcb108412019-10-13 16:09:54 -0700190 // List of applications.
191 applications:[Application] (id: 2);
192 // List of imports. Imports are loaded first, and then this configuration
193 // is merged into them.
194 imports:[string] (id: 3);
Austin Schuhaa79e4e2019-12-29 20:43:32 -0800195
196 // Length of the channels in nanoseconds. Every channel will have enough
197 // data allocated so that if data is published at the configured frequency,
Brian Silverman587da252020-01-01 17:00:47 -0800198 // at least this many nanoseconds of messages will be available for fetchers.
Austin Schuhaa79e4e2019-12-29 20:43:32 -0800199 channel_storage_duration:long = 2000000000 (id: 5);
Austin Schuhcb108412019-10-13 16:09:54 -0700200}
201
202root_type Configuration;