1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
//! # Exar DB's TCP protocol //! This module defines the TCP protocol used by Exar DB. //! //! ## Protocol messages //! The protocol is text-based and uses line-separated messages, //! each message consists of tab-separated values. //! //! ### Connect //! Message used to initialize a connection to Exar DB. //! //! ```text //! Connect collection [username] [password] //! ``` //! //! - The 1st field is the string `Connect`. //! - The 2nd field is the collection name. //! - The 3rd field is the authentication username (optional). //! - The 4th field is the authentication password (optional). //! //! ### Connected //! Message used to acknowledge a successful connection. //! //! ```text //! Connected //! ``` //! //! - A single field containing the string `Connected`. //! //! ### Publish //! Message used to publish an event into a collection. //! //! *It can be used only after a successful connection has been established*. //! //! ```text //! Publish tag1 tag2 timestamp event_data //! ``` //! //! - The 1st field is the string `Publish`. //! - The 2nd field is a space-separated list of tags, the event must contain at least one tag. //! - The 3rd field is the event timestamp (in ms), if set to 0 the timestamp will be set by the event logger. //! - The 4th field is the event data/payload, it can contain tabs (`\t`) but new-lines (`\n`) must be escaped. //! //! ### Published //! Message used to acknowledge a successfully published event. //! //! ```text //! Published event_id //! ``` //! //! - The 1st field is the string `Published`. //! - The 2nd field is the `id` (or sequence number) of the event that has been published. //! //! ### Subscribe //! Message used to subscribe to an event stream. //! //! *It can be used only after a successful connection has been established*. //! //! ```text //! Subscribe live offset limit [tag1] //! ``` //! //! - The 1st field is the string `Subscribe`. //! - The 2nd field is a boolean specifying wether to keep the subscription listening to real-time events. //! - The 3rd field is the query offset. //! - The 4th field is the maximum number of events to consume, if set to 0 a limit is not set. //! - The 5th field is the tag the events must contain (optional). //! //! ### Subscribed //! Message used to acknowledge a successful subscription. //! //! ```text //! Subscribed //! ``` //! //! - A single field containing the string `Subscribed`. //! //! ### Event //! Message containing an event. //! //! *It is received after a successful subscription*. //! //! ```text //! Event event_id tag1 tag2 timestamp event_data //! ``` //! //! - The 1st field is the string `Event`. //! - The 2nd field is the `id` (or sequence number) of the event. //! - The 3rd field is a space-separated list of event tags. //! - The 4th field is the event timestamp (in ms). //! - The 5th field is the event data/payload. //! //! ### EndOfEventStream //! Message signaling the end of an event stream. //! //! *It is received after a `Subscribed` or a list of `Event`s*. //! //! ```text //! EndOfEventStream //! ``` //! //! - A single field containing the string `EndOfEventStream`. //! //! ### Error //! Message containing an error. //! //! *It can be received after a `Connect`, `Publish`, `Subscribe`, or during an event stream*. //! //! ```text //! Error type [subtype] description //! ``` //! //! - The 1st field is the string `Error`. //! - The 2nd field is the type of the error, possible values are: //! `AuthenticationError`, `ConnectionError`, `EventStreamError`, `IoError`, `ParseError`, //! `SubscriptionError`, `ValidationError`. //! - The 3rd field is the sub-type of the error (optional), possible values are: //! `Empty` or `Closed` if the error type is `EventStreamError`, //! `ParseError` or `MissingField` if the error type is `ParseError`, //! or a stringified value of `std::io::ErrorKind` if the error type is `IoError`. //! - The 4th field is the error message/description. //! #[macro_use] extern crate exar; #[cfg(test)] #[macro_use] extern crate exar_testkit; mod message; mod stream; pub use self::message::*; pub use self::stream::*;