blob: bfac6a2599ebfa3e45c666dc194ce22a3c0ba485 [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.
Austin Schuh38912b12020-10-03 18:23:31 -070060 frequency:int = 100 (id: 2);
Austin Schuh719946b2019-12-28 14:51:01 -080061 // Max size of the data being published. (This will hopefully be
62 // automatically computed in the future.)
Austin Schuh38912b12020-10-03 18:23:31 -070063 max_size:int = 1000 (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -070064
Austin Schuh80c7fce2019-12-05 20:48:43 -080065 // Sets the maximum number of senders on a channel.
Austin Schuh38912b12020-10-03 18:23:31 -070066 num_senders:int = 10 (id: 4);
Austin Schuh80c7fce2019-12-05 20:48:43 -080067 // Sets the maximum number of watchers on a channel.
Austin Schuh38912b12020-10-03 18:23:31 -070068 num_watchers:int = 10 (id: 5);
Austin Schuh80c7fce2019-12-05 20:48:43 -080069
Alex Perrycb7da4b2019-08-28 19:35:56 -070070 // The schema for the data sent on this channel.
Austin Schuh38912b12020-10-03 18:23:31 -070071 schema:reflection.Schema (id: 6);
Austin Schuh217a9782019-12-21 23:02:50 -080072
73 // The source node name for the data sent on this channel.
74 // If nodes is populated below, this needs to also be populated.
Austin Schuh38912b12020-10-03 18:23:31 -070075 source_node:string (id: 7);
Austin Schuh217a9782019-12-21 23:02:50 -080076
Austin Schuh719946b2019-12-28 14:51:01 -080077 // The destination nodes for data sent on this channel.
Austin Schuh217a9782019-12-21 23:02:50 -080078 // This only needs to be populated if this message is getting forwarded.
Austin Schuh38912b12020-10-03 18:23:31 -070079 destination_nodes:[Connection] (id: 8);
Austin Schuh719946b2019-12-28 14:51:01 -080080
81 // What service is responsible for logging this channel:
Austin Schuh38912b12020-10-03 18:23:31 -070082 logger:LoggerConfig = LOCAL_LOGGER (id: 9);
Austin Schuh719946b2019-12-28 14:51:01 -080083 // If the channel is logged remotely, which node should be responsible for
84 // logging the data. Note: this requires that the data is forwarded to the
85 // node responsible for logging it. Empty implies the node this connection
86 // is connecting to (i.e. name).
Austin Schuh38912b12020-10-03 18:23:31 -070087 logger_nodes:[string] (id: 10);
Brian Silverman77162972020-08-12 19:52:40 -070088
89 // The way messages are read from shared memory for this channel.
Austin Schuh38912b12020-10-03 18:23:31 -070090 read_method:ReadMethod = COPY (id: 11);
Brian Silverman77162972020-08-12 19:52:40 -070091
92 // Sets the maximum number of senders on a channel.
93 //
94 // Currently, this must be set if and only if read_method is PIN.
Austin Schuh38912b12020-10-03 18:23:31 -070095 num_readers:int (id: 12);
Austin Schuhcb108412019-10-13 16:09:54 -070096}
97
Austin Schuh40485ed2019-10-26 21:51:44 -070098// Table to support renaming channel names.
Austin Schuhcb108412019-10-13 16:09:54 -070099table Map {
Austin Schuh40485ed2019-10-26 21:51:44 -0700100 // Channel to match with. If the name in here matches, the name is replaced
Austin Schuhf1fff282020-03-28 16:57:32 -0700101 // with the name in rename. If the name ends in *, it will be treated like a
102 // wildcard. Anything with the same prefix will match, and anything matching
103 // the * will get preserved on rename. This supports moving subfolders.
Austin Schuhbca6cf02019-12-22 17:28:34 -0800104 // Node specific matches are also supported.
Austin Schuh38912b12020-10-03 18:23:31 -0700105 match:Channel (id: 0);
Austin Schuh40485ed2019-10-26 21:51:44 -0700106 // The channel to merge in.
Austin Schuh38912b12020-10-03 18:23:31 -0700107 rename:Channel (id: 1);
Austin Schuhcb108412019-10-13 16:09:54 -0700108}
109
110// Application specific information.
111table Application {
112 // Name of the application.
Austin Schuh38912b12020-10-03 18:23:31 -0700113 name:string (id: 0);
Tyler Chatowa79419d2020-08-12 20:12:11 -0700114
115 // Path of the executable relative to starter. If this field is unset, use
116 // name as the path. Not permitted to change while starter is running.
117 executable_name:string (id: 5);
118
Austin Schuhcb108412019-10-13 16:09:54 -0700119 // List of maps to apply for this specific application. Application specific
120 // maps are applied in reverse order, and before the global maps.
121 // For example
122 // "maps": [ { "match": { "name": "/foo" }, "rename": { "name": "/bar" } } ]
Austin Schuh40485ed2019-10-26 21:51:44 -0700123 // will make it so any channels named "/foo" actually go to "/bar" for just
Austin Schuhcb108412019-10-13 16:09:54 -0700124 // this application. This is super handy for running an application twice
Austin Schuh40485ed2019-10-26 21:51:44 -0700125 // publishing to different channels, or for injecting a little application
Austin Schuhcb108412019-10-13 16:09:54 -0700126 // to modify messages live for testing.
127 //
128 // "maps": [
129 // { "match": { "name": "/foo" }, "rename": { "name": "/bar" } },
130 // { "match": { "name": "/foo" }, "rename": { "name": "/baz" } }
131 // ]
132 //
133 // will map "/foo" to "/baz", even if there is a global list of maps.
Austin Schuh38912b12020-10-03 18:23:31 -0700134 maps:[Map] (id: 1);
Austin Schuh217a9782019-12-21 23:02:50 -0800135
136 // The node that this application will be started on.
137 // TODO(austin): Teach starter how to use this for starting applications.
Austin Schuh38912b12020-10-03 18:23:31 -0700138 nodes:[string] (id: 2);
Brian Silverman2713ed52020-09-22 22:23:14 -0700139
140 // The user to run this application as. If this field is unset, run it as
141 // the current user of the application starter.
Austin Schuh38912b12020-10-03 18:23:31 -0700142 user:string (id: 3);
Tyler Chatowa79419d2020-08-12 20:12:11 -0700143
144 // List of arguments to be passed to application
145 args:[string] (id: 4);
Austin Schuh217a9782019-12-21 23:02:50 -0800146}
147
148// Per node data and connection information.
149table Node {
150 // Short name for the node. This provides a short hand to make it easy to
151 // setup forwarding rules as part of the channel setup.
Austin Schuh38912b12020-10-03 18:23:31 -0700152 name:string (id: 0);
Austin Schuh217a9782019-12-21 23:02:50 -0800153
154 // Hostname used to identify and connect to the node.
Austin Schuh38912b12020-10-03 18:23:31 -0700155 hostname:string (id: 1);
Austin Schuh217a9782019-12-21 23:02:50 -0800156 // Port to serve forwarded data from.
Austin Schuh38912b12020-10-03 18:23:31 -0700157 port:ushort = 9971 (id: 2);
Brian Silvermanaa2633f2020-02-17 21:04:14 -0800158
159 // An alternative to hostname which allows specifying multiple hostnames,
160 // any of which will match this node.
161 //
162 // Don't specify a hostname in multiple nodes in the same configuration.
Austin Schuh38912b12020-10-03 18:23:31 -0700163 hostnames:[string] (id: 3);
Austin Schuhd60967a2020-10-19 09:34:42 -0700164
165 // An arbitrary list of strings representing properties of each node. These
166 // can be used to store information about roles.
167 tags:[string] (id: 4);
Austin Schuhcb108412019-10-13 16:09:54 -0700168}
169
170// Overall configuration datastructure for the pubsub.
171table Configuration {
Austin Schuh40485ed2019-10-26 21:51:44 -0700172 // List of channels.
173 channels:[Channel] (id: 0);
Austin Schuhcb108412019-10-13 16:09:54 -0700174 // List of global maps. These are applied in reverse order.
175 maps:[Map] (id: 1);
Austin Schuh217a9782019-12-21 23:02:50 -0800176
177 // If present, this is the list of nodes in the system. If this is not
178 // present, AOS will be running in a single node configuration.
179 nodes:[Node] (id: 4);
180
Austin Schuhcb108412019-10-13 16:09:54 -0700181 // List of applications.
182 applications:[Application] (id: 2);
183 // List of imports. Imports are loaded first, and then this configuration
184 // is merged into them.
185 imports:[string] (id: 3);
Austin Schuhaa79e4e2019-12-29 20:43:32 -0800186
187 // Length of the channels in nanoseconds. Every channel will have enough
188 // data allocated so that if data is published at the configured frequency,
Brian Silverman587da252020-01-01 17:00:47 -0800189 // at least this many nanoseconds of messages will be available for fetchers.
Austin Schuhaa79e4e2019-12-29 20:43:32 -0800190 channel_storage_duration:long = 2000000000 (id: 5);
Austin Schuhcb108412019-10-13 16:09:54 -0700191}
192
193root_type Configuration;