2
3
4
5
6
7
8
9
10
14namespace mqtt::mqttstore::
lib {
17 : utils::SubCommand(parent,
this,
"MQTT session")
18 ,
clientIdOpt(setConfigurable(addOption(
"--client-id",
"MQTT Client-ID",
"string", CLI::TypeValidator<std::string>()),
true))
19 ,
qoSOpt(setConfigurable(addOption(
"--qos",
"Default subscription quality of service",
"uint8_t",
"0", CLI::Range(0, 2)),
true))
20 ,
retainSessionOpt(setConfigurable(addFlag(
"--retain-session{true},-r{true}",
21 "Use a persistent MQTT session (sets clean_session=false)",
24 CLI::IsMember({
"true",
"false"})),
28 addOption(
"--keep-alive",
"MQTT keep alive in seconds",
"uint16_t",
"60", CLI::TypeValidator<std::uint16_t>()),
true))
29 ,
willTopicOpt(setConfigurable(addOption(
"--will-topic",
"MQTT will topic",
"string", CLI::TypeValidator<std::string>()),
true))
31 setConfigurable(addOption(
"--will-message",
"MQTT will message",
"string", CLI::TypeValidator<std::string>()),
true))
32 ,
willQoSOpt(setConfigurable(addOption(
"--will-qos",
"MQTT will quality of service",
"uint8_t",
"0", CLI::Range(0, 2)),
true))
34 addFlag(
"--will-retain{true}",
"MQTT will message retain",
"bool",
"false", CLI::IsMember({
"true",
"false"})),
true))
35 ,
usernameOpt(setConfigurable(addOption(
"--username",
"MQTT username",
"string", CLI::TypeValidator<std::string>()),
true))
36 ,
passwordOpt(setConfigurable(addOption(
"--password",
"MQTT password",
"string", CLI::TypeValidator<std::string>()),
true))
38 addOption(
"--session-store",
"Path to persistent MQTT session store",
"filename", !CLI::ExistingDirectory),
true)) {
48 return qoSOpt->as<std::uint8_t>();
88 : utils::SubCommand(parent,
this,
"MQTT subscriptions")
89 ,
topicOpt(setConfigurable(addOption(
"--topic",
90 "Topic filter to persist; append ##<qos> to override QoS",
92 CLI::TypeValidator<std::string>()),
101 std::list<std::string> topicList =
topicOpt->as<std::list<std::string>>();
103 if (!topicList.empty() && topicList.front().empty()) {
104 topicList.pop_front();
111 : utils::SubCommand(parent,
this,
"Database connection")
113 addOption(
"--host",
"Hostname or IP address of MariaDB server",
"hostname|IPv4", CLI::TypeValidator<std::string>()),
true))
114 ,
usernameOpt(setConfigurable(addOption(
"--username",
"Database username",
"string", CLI::TypeValidator<std::string>()),
true))
115 ,
passwordOpt(setConfigurable(addOption(
"--password",
"Database password",
"string", CLI::TypeValidator<std::string>()),
true))
116 ,
databaseOpt(setConfigurable(addOption(
"--database",
"Database name",
"string", CLI::TypeValidator<std::string>()),
true))
117 ,
portOpt(setConfigurable(addOption(
"--port",
"Database TCP port",
"uint16_t", 3306, CLI::TypeValidator<std::uint16_t>()),
true))
118 ,
socketOpt(setConfigurable(addOption(
"--socket",
119 "Database socket file (overrides host and port when set)",
121 "/run/mysqld/mysqld.sock",
122 CLI::TypeValidator<std::string>()),
124 ,
flagsOpt(setConfigurable(addOption(
"--flags",
"MariaDB connection flags",
"uint32_t",
"0", CLI::TypeValidator<std::uint32_t>()),
131 return hostOpt->as<std::string>();
147 return portOpt->as<std::uint16_t>();
155 return flagsOpt->as<std::uint32_t>();
159 : utils::SubCommand(parent,
this,
"Storage behavior")
161 addOption(
"--raw-table",
"Raw MQTT envelope table",
"identifier",
"mqtt_messages", CLI::TypeValidator<std::string>()),
true))
163 "Create the raw MQTT envelope table automatically",
166 CLI::IsMember({
"true",
"false"})),
169 addOption(
"--projection-file",
"Optional JSON file describing typed projections",
"filename", CLI::ExistingFile),
true)) {
std::string getHost() const
CLI::Option * databaseOpt
std::string getSocket() const
~ConfigDatabase() override
std::uint32_t getFlags() const
CLI::Option * passwordOpt
std::string getPassword() const
std::string getUsername() const
std::string getDatabase() const
std::uint16_t getPort() const
CLI::Option * usernameOpt
ConfigDatabase(utils::SubCommand *parent)
std::uint8_t getWillQoS() const
ConfigSession(utils::SubCommand *parent)
CLI::Option * passwordOpt
~ConfigSession() override
std::uint16_t getKeepAlive() const
CLI::Option * sessionStoreOpt
CLI::Option * willMessageOpt
CLI::Option * usernameOpt
std::string getPassword() const
bool getWillRetain() const
std::string getClientId() const
std::string getWillMessage() const
CLI::Option * retainSessionOpt
std::string getSessionStore() const
std::string getWillTopic() const
CLI::Option * willTopicOpt
std::string getUsername() const
CLI::Option * clientIdOpt
std::uint8_t getQoS() const
bool getRetainSession() const
CLI::Option * keepAliveOpt
CLI::Option * willRetainOpt
CLI::Option * projectionFileOpt
std::string getProjectionFile() const
bool getAutoCreateRawTable() const
CLI::Option * rawTableOpt
std::string getRawTable() const
ConfigStorage(utils::SubCommand *parent)
CLI::Option * autoCreateRawTableOpt
~ConfigStorage() override
ConfigSubscribe(utils::SubCommand *parent)
std::list< std::string > getTopic() const
~ConfigSubscribe() override