blob: 0b42f5b6df2bfe1fcdfd374a408e42e4c3d4783b [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 Schuha0bcd412023-04-07 20:09:00 -070035 // The priority value in SCTP_SS_PRIO is used to determine the order in which
36 // data from different streams is transmitted. Lower priority values indicate
37 // higher priority in sending the data. When the SCTP stack has to choose
38 // which stream's data to send next, it will select the data from the stream
39 // with the highest priority (i.e., the lowest priority value). If two or
40 // more streams have the same priority, SCTP_SS_PRIO falls back to a
41 // round-robin scheduling between these streams. Note that this does not
42 // reserve any potion of the bandwidth. It is only used to determine which
43 // message to send when the system is ready to send a message.
Austin Schuh38912b12020-10-03 18:23:31 -070044 priority:ushort = 100 (id: 3);
Austin Schuh719946b2019-12-28 14:51:01 -080045
46 // Time to live in nanoseconds before the message is dropped.
47 // A value of 0 means no timeout, i.e. reliable. When a client connects, the
48 // latest message from this channel will be sent regardless.
49 // TODO(austin): We can retry more than just the last message on reconnect
50 // if we want. This is an unlikely scenario though.
Austin Schuh38912b12020-10-03 18:23:31 -070051 time_to_live:uint = 0 (id: 4);
Austin Schuh719946b2019-12-28 14:51:01 -080052}
53
Brian Silverman77162972020-08-12 19:52:40 -070054enum ReadMethod : ubyte {
55 // Copy all the data out of shared memory into a local buffer for each reader.
56 COPY,
57 // Pin the data in shared memory and read directly from there.
58 PIN,
59}
60
Austin Schuh40485ed2019-10-26 21:51:44 -070061// Table representing a channel. Channels are where data is published and
Austin Schuhcb108412019-10-13 16:09:54 -070062// subscribed from. The tuple of name, type is the identifying information.
Austin Schuh40485ed2019-10-26 21:51:44 -070063table Channel {
64 // Name of the channel.
Austin Schuh38912b12020-10-03 18:23:31 -070065 name:string (id: 0);
Austin Schuhcb108412019-10-13 16:09:54 -070066 // Type name of the flatbuffer.
Austin Schuh38912b12020-10-03 18:23:31 -070067 type:string (id: 1);
Austin Schuh40485ed2019-10-26 21:51:44 -070068 // Max frequency in messages/sec of the data published on this channel.
Eric Schmiedebergef44b8a2022-02-28 17:30:38 -070069 // The maximum number of messages that can be sent
70 // in a channel_storage_duration is
71 // frequency * channel_storage_duration (in seconds).
Austin Schuh38912b12020-10-03 18:23:31 -070072 frequency:int = 100 (id: 2);
Austin Schuh719946b2019-12-28 14:51:01 -080073 // Max size of the data being published. (This will hopefully be
74 // automatically computed in the future.)
Austin Schuh38912b12020-10-03 18:23:31 -070075 max_size:int = 1000 (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -070076
Austin Schuh80c7fce2019-12-05 20:48:43 -080077 // Sets the maximum number of senders on a channel.
Austin Schuh38912b12020-10-03 18:23:31 -070078 num_senders:int = 10 (id: 4);
Austin Schuh80c7fce2019-12-05 20:48:43 -080079 // Sets the maximum number of watchers on a channel.
Austin Schuh38912b12020-10-03 18:23:31 -070080 num_watchers:int = 10 (id: 5);
Austin Schuh80c7fce2019-12-05 20:48:43 -080081
Alex Perrycb7da4b2019-08-28 19:35:56 -070082 // The schema for the data sent on this channel.
Austin Schuh38912b12020-10-03 18:23:31 -070083 schema:reflection.Schema (id: 6);
Austin Schuh217a9782019-12-21 23:02:50 -080084
85 // The source node name for the data sent on this channel.
86 // If nodes is populated below, this needs to also be populated.
Austin Schuh38912b12020-10-03 18:23:31 -070087 source_node:string (id: 7);
Austin Schuh217a9782019-12-21 23:02:50 -080088
Austin Schuh719946b2019-12-28 14:51:01 -080089 // The destination nodes for data sent on this channel.
Austin Schuh217a9782019-12-21 23:02:50 -080090 // This only needs to be populated if this message is getting forwarded.
Austin Schuh38912b12020-10-03 18:23:31 -070091 destination_nodes:[Connection] (id: 8);
Austin Schuh719946b2019-12-28 14:51:01 -080092
93 // What service is responsible for logging this channel:
Austin Schuh38912b12020-10-03 18:23:31 -070094 logger:LoggerConfig = LOCAL_LOGGER (id: 9);
Austin Schuh719946b2019-12-28 14:51:01 -080095 // If the channel is logged remotely, which node should be responsible for
96 // logging the data. Note: this requires that the data is forwarded to the
97 // node responsible for logging it. Empty implies the node this connection
98 // is connecting to (i.e. name).
Austin Schuh38912b12020-10-03 18:23:31 -070099 logger_nodes:[string] (id: 10);
Brian Silverman77162972020-08-12 19:52:40 -0700100
101 // The way messages are read from shared memory for this channel.
Austin Schuh38912b12020-10-03 18:23:31 -0700102 read_method:ReadMethod = COPY (id: 11);
Brian Silverman77162972020-08-12 19:52:40 -0700103
104 // Sets the maximum number of senders on a channel.
105 //
106 // Currently, this must be set if and only if read_method is PIN.
Austin Schuh38912b12020-10-03 18:23:31 -0700107 num_readers:int (id: 12);
Austin Schuhdda6db72023-06-21 17:02:34 -0700108
109 // Length of this channel in nanoseconds. This overrides
110 // channel_storage_duration below in Configuration for just this channel.
111 channel_storage_duration:long = 2000000000 (id: 13);
Austin Schuhcb108412019-10-13 16:09:54 -0700112}
113
Austin Schuh40485ed2019-10-26 21:51:44 -0700114// Table to support renaming channel names.
Austin Schuhcb108412019-10-13 16:09:54 -0700115table Map {
Austin Schuh40485ed2019-10-26 21:51:44 -0700116 // Channel to match with. If the name in here matches, the name is replaced
Austin Schuhf1fff282020-03-28 16:57:32 -0700117 // with the name in rename. If the name ends in *, it will be treated like a
118 // wildcard. Anything with the same prefix will match, and anything matching
119 // the * will get preserved on rename. This supports moving subfolders.
Austin Schuhbca6cf02019-12-22 17:28:34 -0800120 // Node specific matches are also supported.
Austin Schuh38912b12020-10-03 18:23:31 -0700121 match:Channel (id: 0);
Austin Schuh40485ed2019-10-26 21:51:44 -0700122 // The channel to merge in.
Austin Schuh38912b12020-10-03 18:23:31 -0700123 rename:Channel (id: 1);
Austin Schuhcb108412019-10-13 16:09:54 -0700124}
125
126// Application specific information.
127table Application {
128 // Name of the application.
Austin Schuh38912b12020-10-03 18:23:31 -0700129 name:string (id: 0);
Tyler Chatowa79419d2020-08-12 20:12:11 -0700130
131 // Path of the executable relative to starter. If this field is unset, use
132 // name as the path. Not permitted to change while starter is running.
133 executable_name:string (id: 5);
134
Austin Schuhcb108412019-10-13 16:09:54 -0700135 // List of maps to apply for this specific application. Application specific
136 // maps are applied in reverse order, and before the global maps.
137 // For example
138 // "maps": [ { "match": { "name": "/foo" }, "rename": { "name": "/bar" } } ]
Austin Schuh40485ed2019-10-26 21:51:44 -0700139 // will make it so any channels named "/foo" actually go to "/bar" for just
Austin Schuhcb108412019-10-13 16:09:54 -0700140 // this application. This is super handy for running an application twice
Austin Schuh40485ed2019-10-26 21:51:44 -0700141 // publishing to different channels, or for injecting a little application
Austin Schuhcb108412019-10-13 16:09:54 -0700142 // to modify messages live for testing.
143 //
144 // "maps": [
145 // { "match": { "name": "/foo" }, "rename": { "name": "/bar" } },
146 // { "match": { "name": "/foo" }, "rename": { "name": "/baz" } }
147 // ]
148 //
149 // will map "/foo" to "/baz", even if there is a global list of maps.
Austin Schuh38912b12020-10-03 18:23:31 -0700150 maps:[Map] (id: 1);
Austin Schuh217a9782019-12-21 23:02:50 -0800151
152 // The node that this application will be started on.
153 // TODO(austin): Teach starter how to use this for starting applications.
Austin Schuh38912b12020-10-03 18:23:31 -0700154 nodes:[string] (id: 2);
Brian Silverman2713ed52020-09-22 22:23:14 -0700155
156 // The user to run this application as. If this field is unset, run it as
157 // the current user of the application starter.
Austin Schuh38912b12020-10-03 18:23:31 -0700158 user:string (id: 3);
Tyler Chatowa79419d2020-08-12 20:12:11 -0700159
160 // List of arguments to be passed to application
161 args:[string] (id: 4);
Austin Schuh5f79a5a2021-10-12 17:46:50 -0700162
163 // Indicates that application should be executed on boot.
164 autostart:bool = true (id: 6);
James Kuszmaule7c7e582022-01-07 18:50:01 -0800165
166 // Indicates that application should automatically restart on failure.
167 autorestart:bool = true (id: 7);
Austin Schuhbbeb37e2022-08-17 16:19:27 -0700168
169 // If set, this is the memory limit to enforce in bytes for the application
170 // (and it's children)
171 memory_limit:uint64 = 0 (id: 8);
Austin Schuh217a9782019-12-21 23:02:50 -0800172}
173
174// Per node data and connection information.
175table Node {
176 // Short name for the node. This provides a short hand to make it easy to
177 // setup forwarding rules as part of the channel setup.
Austin Schuh38912b12020-10-03 18:23:31 -0700178 name:string (id: 0);
Austin Schuh217a9782019-12-21 23:02:50 -0800179
180 // Hostname used to identify and connect to the node.
Austin Schuh38912b12020-10-03 18:23:31 -0700181 hostname:string (id: 1);
Austin Schuh217a9782019-12-21 23:02:50 -0800182 // Port to serve forwarded data from.
Austin Schuh38912b12020-10-03 18:23:31 -0700183 port:ushort = 9971 (id: 2);
Brian Silvermanaa2633f2020-02-17 21:04:14 -0800184
185 // An alternative to hostname which allows specifying multiple hostnames,
186 // any of which will match this node.
187 //
188 // Don't specify a hostname in multiple nodes in the same configuration.
Austin Schuh38912b12020-10-03 18:23:31 -0700189 hostnames:[string] (id: 3);
Austin Schuhd60967a2020-10-19 09:34:42 -0700190
191 // An arbitrary list of strings representing properties of each node. These
192 // can be used to store information about roles.
193 tags:[string] (id: 4);
Austin Schuhcb108412019-10-13 16:09:54 -0700194}
195
196// Overall configuration datastructure for the pubsub.
197table Configuration {
Austin Schuh40485ed2019-10-26 21:51:44 -0700198 // List of channels.
199 channels:[Channel] (id: 0);
Austin Schuhcb108412019-10-13 16:09:54 -0700200 // List of global maps. These are applied in reverse order.
201 maps:[Map] (id: 1);
Austin Schuh217a9782019-12-21 23:02:50 -0800202
203 // If present, this is the list of nodes in the system. If this is not
204 // present, AOS will be running in a single node configuration.
205 nodes:[Node] (id: 4);
206
Austin Schuhcb108412019-10-13 16:09:54 -0700207 // List of applications.
208 applications:[Application] (id: 2);
209 // List of imports. Imports are loaded first, and then this configuration
210 // is merged into them.
211 imports:[string] (id: 3);
Austin Schuhaa79e4e2019-12-29 20:43:32 -0800212
213 // Length of the channels in nanoseconds. Every channel will have enough
214 // data allocated so that if data is published at the configured frequency,
Brian Silverman587da252020-01-01 17:00:47 -0800215 // at least this many nanoseconds of messages will be available for fetchers.
Austin Schuhaa79e4e2019-12-29 20:43:32 -0800216 channel_storage_duration:long = 2000000000 (id: 5);
Austin Schuhcb108412019-10-13 16:09:54 -0700217}
218
219root_type Configuration;