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. |
| 20 | name:string; |
| 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? |
| 26 | timestamp_logger:LoggerConfig = LOCAL_LOGGER; |
| 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 | da40e47 | 2020-03-28 15:15:29 -0700 | [diff] [blame^] | 32 | timestamp_logger_nodes:[string]; |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 33 | |
| 34 | // Priority to forward data with. |
| 35 | priority:ushort = 100; |
| 36 | |
| 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. |
| 42 | time_to_live:uint = 0; |
| 43 | } |
| 44 | |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 45 | // Table representing a channel. Channels are where data is published and |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 46 | // subscribed from. The tuple of name, type is the identifying information. |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 47 | table Channel { |
| 48 | // Name of the channel. |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 49 | name:string; |
| 50 | // Type name of the flatbuffer. |
| 51 | type:string; |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 52 | // Max frequency in messages/sec of the data published on this channel. |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 53 | frequency:int = 100; |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 54 | // Max size of the data being published. (This will hopefully be |
| 55 | // automatically computed in the future.) |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 56 | max_size:int = 1000; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 57 | |
Austin Schuh | 80c7fce | 2019-12-05 20:48:43 -0800 | [diff] [blame] | 58 | // Sets the maximum number of senders on a channel. |
| 59 | num_senders:int = 10; |
| 60 | // Sets the maximum number of watchers on a channel. |
| 61 | num_watchers:int = 10; |
| 62 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 63 | // The schema for the data sent on this channel. |
| 64 | schema:reflection.Schema; |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 65 | |
| 66 | // The source node name for the data sent on this channel. |
| 67 | // If nodes is populated below, this needs to also be populated. |
| 68 | source_node:string; |
| 69 | |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 70 | // The destination nodes for data sent on this channel. |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 71 | // This only needs to be populated if this message is getting forwarded. |
Austin Schuh | 719946b | 2019-12-28 14:51:01 -0800 | [diff] [blame] | 72 | destination_nodes:[Connection]; |
| 73 | |
| 74 | // What service is responsible for logging this channel: |
| 75 | logger:LoggerConfig = LOCAL_LOGGER; |
| 76 | // If the channel is logged remotely, which node should be responsible for |
| 77 | // logging the data. Note: this requires that the data is forwarded to the |
| 78 | // node responsible for logging it. Empty implies the node this connection |
| 79 | // is connecting to (i.e. name). |
Austin Schuh | da40e47 | 2020-03-28 15:15:29 -0700 | [diff] [blame^] | 80 | logger_nodes:[string]; |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 83 | // Table to support renaming channel names. |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 84 | table Map { |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 85 | // Channel to match with. If the name in here matches, the name is replaced |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 86 | // with the name in rename. |
Austin Schuh | bca6cf0 | 2019-12-22 17:28:34 -0800 | [diff] [blame] | 87 | // Node specific matches are also supported. |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 88 | match:Channel; |
| 89 | // The channel to merge in. |
| 90 | rename:Channel; |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | // Application specific information. |
| 94 | table Application { |
| 95 | // Name of the application. |
| 96 | name:string; |
| 97 | // List of maps to apply for this specific application. Application specific |
| 98 | // maps are applied in reverse order, and before the global maps. |
| 99 | // For example |
| 100 | // "maps": [ { "match": { "name": "/foo" }, "rename": { "name": "/bar" } } ] |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 101 | // 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] | 102 | // this application. This is super handy for running an application twice |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 103 | // publishing to different channels, or for injecting a little application |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 104 | // to modify messages live for testing. |
| 105 | // |
| 106 | // "maps": [ |
| 107 | // { "match": { "name": "/foo" }, "rename": { "name": "/bar" } }, |
| 108 | // { "match": { "name": "/foo" }, "rename": { "name": "/baz" } } |
| 109 | // ] |
| 110 | // |
| 111 | // will map "/foo" to "/baz", even if there is a global list of maps. |
| 112 | maps:[Map]; |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 113 | |
| 114 | // The node that this application will be started on. |
| 115 | // TODO(austin): Teach starter how to use this for starting applications. |
| 116 | node:string; |
| 117 | } |
| 118 | |
| 119 | // Per node data and connection information. |
| 120 | table Node { |
| 121 | // Short name for the node. This provides a short hand to make it easy to |
| 122 | // setup forwarding rules as part of the channel setup. |
| 123 | name:string; |
| 124 | |
| 125 | // Hostname used to identify and connect to the node. |
| 126 | hostname:string; |
| 127 | // Port to serve forwarded data from. |
| 128 | port:ushort = 9971; |
Brian Silverman | aa2633f | 2020-02-17 21:04:14 -0800 | [diff] [blame] | 129 | |
| 130 | // An alternative to hostname which allows specifying multiple hostnames, |
| 131 | // any of which will match this node. |
| 132 | // |
| 133 | // Don't specify a hostname in multiple nodes in the same configuration. |
| 134 | hostnames:[string]; |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | // Overall configuration datastructure for the pubsub. |
| 138 | table Configuration { |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 139 | // List of channels. |
| 140 | channels:[Channel] (id: 0); |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 141 | // List of global maps. These are applied in reverse order. |
| 142 | maps:[Map] (id: 1); |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 143 | |
| 144 | // If present, this is the list of nodes in the system. If this is not |
| 145 | // present, AOS will be running in a single node configuration. |
| 146 | nodes:[Node] (id: 4); |
| 147 | |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 148 | // List of applications. |
| 149 | applications:[Application] (id: 2); |
| 150 | // List of imports. Imports are loaded first, and then this configuration |
| 151 | // is merged into them. |
| 152 | imports:[string] (id: 3); |
Austin Schuh | aa79e4e | 2019-12-29 20:43:32 -0800 | [diff] [blame] | 153 | |
| 154 | // Length of the channels in nanoseconds. Every channel will have enough |
| 155 | // data allocated so that if data is published at the configured frequency, |
Brian Silverman | 587da25 | 2020-01-01 17:00:47 -0800 | [diff] [blame] | 156 | // at least this many nanoseconds of messages will be available for fetchers. |
Austin Schuh | aa79e4e | 2019-12-29 20:43:32 -0800 | [diff] [blame] | 157 | channel_storage_duration:long = 2000000000 (id: 5); |
Austin Schuh | cb10841 | 2019-10-13 16:09:54 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | root_type Configuration; |