Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 1 | include "reflection/reflection.fbs"; |
| 2 | |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 3 | namespace aos; |
| 4 | |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 5 | enum 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 | |
| 18 | table Connection { |
| 19 | // Node name to forward to. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 20 | name:string (id: 0); |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 21 | |
| 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 Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 26 | timestamp_logger:LoggerConfig = LOCAL_LOGGER (id: 1); |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 27 | |
| 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 Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 32 | timestamp_logger_nodes:[string] (id: 2); |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 33 | |
| 34 | // Priority to forward data with. |
Austin Schuh | a0bcd41 | 2023-04-07 20:09:00 -0700 | [diff] [blame^] | 35 | // 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 Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 44 | priority:ushort = 100 (id: 3); |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 45 | |
| 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 Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 51 | time_to_live:uint = 0 (id: 4); |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 52 | } |
| 53 | |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 54 | enum 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 Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 61 | // Table representing a channel. Channels are where data is published and |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 62 | // subscribed from. The tuple of name, type is the identifying information. |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 63 | table Channel { |
| 64 | // Name of the channel. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 65 | name:string (id: 0); |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 66 | // Type name of the flatbuffer. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 67 | type:string (id: 1); |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 68 | // Max frequency in messages/sec of the data published on this channel. |
Eric Schmiedeberg | ef44b8a | 2022-02-28 17:30:38 -0700 | [diff] [blame] | 69 | // The maximum number of messages that can be sent |
| 70 | // in a channel_storage_duration is |
| 71 | // frequency * channel_storage_duration (in seconds). |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 72 | frequency:int = 100 (id: 2); |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 73 | // Max size of the data being published. (This will hopefully be |
| 74 | // automatically computed in the future.) |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 75 | max_size:int = 1000 (id: 3); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 76 | |
Austin Schuh | 80c7fce | 2019-12-05 20:48:43 -0800 | [diff] [blame] | 77 | // Sets the maximum number of senders on a channel. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 78 | num_senders:int = 10 (id: 4); |
Austin Schuh | 80c7fce | 2019-12-05 20:48:43 -0800 | [diff] [blame] | 79 | // Sets the maximum number of watchers on a channel. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 80 | num_watchers:int = 10 (id: 5); |
Austin Schuh | 80c7fce | 2019-12-05 20:48:43 -0800 | [diff] [blame] | 81 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 82 | // The schema for the data sent on this channel. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 83 | schema:reflection.Schema (id: 6); |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 84 | |
| 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 Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 87 | source_node:string (id: 7); |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 88 | |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 89 | // The destination nodes for data sent on this channel. |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 90 | // This only needs to be populated if this message is getting forwarded. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 91 | destination_nodes:[Connection] (id: 8); |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 92 | |
| 93 | // What service is responsible for logging this channel: |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 94 | logger:LoggerConfig = LOCAL_LOGGER (id: 9); |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 95 | // 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 Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 99 | logger_nodes:[string] (id: 10); |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 100 | |
| 101 | // The way messages are read from shared memory for this channel. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 102 | read_method:ReadMethod = COPY (id: 11); |
Brian Silverman | 7716297 | 2020-08-12 19:52:40 -0700 | [diff] [blame] | 103 | |
| 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 Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 107 | num_readers:int (id: 12); |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 110 | // Table to support renaming channel names. |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 111 | table Map { |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 112 | // Channel to match with. If the name in here matches, the name is replaced |
Austin Schuh | f1fff28 | 2020-03-28 16:57:32 -0700 | [diff] [blame] | 113 | // with the name in rename. If the name ends in *, it will be treated like a |
| 114 | // wildcard. Anything with the same prefix will match, and anything matching |
| 115 | // the * will get preserved on rename. This supports moving subfolders. |
Austin Schuh | bca6cf0 | 2019-12-22 17:28:34 -0800 | [diff] [blame] | 116 | // Node specific matches are also supported. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 117 | match:Channel (id: 0); |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 118 | // The channel to merge in. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 119 | rename:Channel (id: 1); |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | // Application specific information. |
| 123 | table Application { |
| 124 | // Name of the application. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 125 | name:string (id: 0); |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 126 | |
| 127 | // Path of the executable relative to starter. If this field is unset, use |
| 128 | // name as the path. Not permitted to change while starter is running. |
| 129 | executable_name:string (id: 5); |
| 130 | |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 131 | // List of maps to apply for this specific application. Application specific |
| 132 | // maps are applied in reverse order, and before the global maps. |
| 133 | // For example |
| 134 | // "maps": [ { "match": { "name": "/foo" }, "rename": { "name": "/bar" } } ] |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 135 | // will make it so any channels named "/foo" actually go to "/bar" for just |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 136 | // this application. This is super handy for running an application twice |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 137 | // publishing to different channels, or for injecting a little application |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 138 | // to modify messages live for testing. |
| 139 | // |
| 140 | // "maps": [ |
| 141 | // { "match": { "name": "/foo" }, "rename": { "name": "/bar" } }, |
| 142 | // { "match": { "name": "/foo" }, "rename": { "name": "/baz" } } |
| 143 | // ] |
| 144 | // |
| 145 | // will map "/foo" to "/baz", even if there is a global list of maps. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 146 | maps:[Map] (id: 1); |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 147 | |
| 148 | // The node that this application will be started on. |
| 149 | // TODO(austin): Teach starter how to use this for starting applications. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 150 | nodes:[string] (id: 2); |
Brian Silverman | 2713ed5 | 2020-09-22 22:23:14 -0700 | [diff] [blame] | 151 | |
| 152 | // The user to run this application as. If this field is unset, run it as |
| 153 | // the current user of the application starter. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 154 | user:string (id: 3); |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 155 | |
| 156 | // List of arguments to be passed to application |
| 157 | args:[string] (id: 4); |
Austin Schuh | 5f79a5a | 2021-10-12 17:46:50 -0700 | [diff] [blame] | 158 | |
| 159 | // Indicates that application should be executed on boot. |
| 160 | autostart:bool = true (id: 6); |
James Kuszmaul | e7c7e58 | 2022-01-07 18:50:01 -0800 | [diff] [blame] | 161 | |
| 162 | // Indicates that application should automatically restart on failure. |
| 163 | autorestart:bool = true (id: 7); |
Austin Schuh | bbeb37e | 2022-08-17 16:19:27 -0700 | [diff] [blame] | 164 | |
| 165 | // If set, this is the memory limit to enforce in bytes for the application |
| 166 | // (and it's children) |
| 167 | memory_limit:uint64 = 0 (id: 8); |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | // Per node data and connection information. |
| 171 | table Node { |
| 172 | // Short name for the node. This provides a short hand to make it easy to |
| 173 | // setup forwarding rules as part of the channel setup. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 174 | name:string (id: 0); |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 175 | |
| 176 | // Hostname used to identify and connect to the node. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 177 | hostname:string (id: 1); |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 178 | // Port to serve forwarded data from. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 179 | port:ushort = 9971 (id: 2); |
Brian Silverman | aa2633f | 2020-02-17 21:04:14 -0800 | [diff] [blame] | 180 | |
| 181 | // An alternative to hostname which allows specifying multiple hostnames, |
| 182 | // any of which will match this node. |
| 183 | // |
| 184 | // Don't specify a hostname in multiple nodes in the same configuration. |
Austin Schuh | 38912b1 | 2020-10-03 18:23:31 -0700 | [diff] [blame] | 185 | hostnames:[string] (id: 3); |
Austin Schuh | d60967a | 2020-10-19 09:34:42 -0700 | [diff] [blame] | 186 | |
| 187 | // An arbitrary list of strings representing properties of each node. These |
| 188 | // can be used to store information about roles. |
| 189 | tags:[string] (id: 4); |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | // Overall configuration datastructure for the pubsub. |
| 193 | table Configuration { |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 194 | // List of channels. |
| 195 | channels:[Channel] (id: 0); |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 196 | // List of global maps. These are applied in reverse order. |
| 197 | maps:[Map] (id: 1); |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 198 | |
| 199 | // If present, this is the list of nodes in the system. If this is not |
| 200 | // present, AOS will be running in a single node configuration. |
| 201 | nodes:[Node] (id: 4); |
| 202 | |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 203 | // List of applications. |
| 204 | applications:[Application] (id: 2); |
| 205 | // List of imports. Imports are loaded first, and then this configuration |
| 206 | // is merged into them. |
| 207 | imports:[string] (id: 3); |
Austin Schuh | aa79e4e | 2019-12-29 20:43:32 -0800 | [diff] [blame] | 208 | |
| 209 | // Length of the channels in nanoseconds. Every channel will have enough |
| 210 | // data allocated so that if data is published at the configured frequency, |
Brian Silverman | 587da25 | 2020-01-01 17:00:47 -0800 | [diff] [blame] | 211 | // at least this many nanoseconds of messages will be available for fetchers. |
Austin Schuh | aa79e4e | 2019-12-29 20:43:32 -0800 | [diff] [blame] | 212 | channel_storage_duration:long = 2000000000 (id: 5); |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | root_type Configuration; |