Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SQLite APIs description #171

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/man/libnng.3.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ These functions are intended for use with MQTT client applications.
|xref:nng_mqttv5_client_open.3.adoc[nng_mqttv5_client_open]|open mqtt V5 client socket
|xref:nng_mqtt_set_cb.3.adoc[nng_mqtt_set_connect_cb]| set mqtt connect callback function
|xref:nng_mqtt_set_cb.3.adoc[nng_mqtt_set_disconnect_cb]| set mqtt disconnect callback function
|xref:nng_mqtt_set_sqlite.3.adoc[nng_mqtt_sqlite]|set SQLite options
|===

== SEE ALSO
Expand Down
94 changes: 94 additions & 0 deletions docs/man/nng_mqtt_set_sqlite.3.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
= nng_mqtt_sqlite_functions(3)
//
// Copyright 2018 Staysail Systems, Inc. <[email protected]>
// Copyright 2018 Capitar IT Group BV <[email protected]>
//
// This document is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//

== NAME

nng_mqtt_alloc_sqlite_opt - allocate a nng_mqtt_sqlite_option object

nng_mqtt_free_sqlite_opt - free a nng_mqtt_sqlite_option object

nng_mqtt_set_sqlite_enable - enable or disable sqlite caching

nng_mqtt_set_sqlite_db_dir - specify a mount path for SQLite DB file

nng_mqtt_set_sqlite_max_rows - specify Max message limitation for caching

nng_mqtt_set_sqlite_flush_threshold - specify a threshold of flushing messages to flash

nng_mqtt_sqlite_db_init - initialize sqlite options and create or open a database file

nng_mqtt_sqlite_db_fini - deinit `nng_mqtt_sqlite_option` and close database file

nng_mqtt_sqlite_db_get_cached_size - get cached message size

== SYNOPSIS

[source, c]
----
#include <nng/mqtt/mqtt_client.h>
typedef struct nng_mqtt_sqlite_option nng_mqtt_sqlite_option;
int nng_mqtt_alloc_sqlite_opt(nng_mqtt_sqlite_option **opt);
int nng_mqtt_free_sqlite_opt(nng_mqtt_sqlite_option *opt);
void nng_mqtt_set_sqlite_enable(nng_mqtt_sqlite_option *opt, bool enable);
void nng_mqtt_set_sqlite_db_dir(
nng_mqtt_sqlite_option *opt, const char *dir_path);
void nng_mqtt_set_sqlite_max_rows(nng_mqtt_sqlite_option *opt, size_t max_rows);
void nng_mqtt_set_sqlite_flush_threshold(
nng_mqtt_sqlite_option *opt, size_t threshold);
void nng_mqtt_sqlite_db_init(
nng_mqtt_sqlite_option *opt, const char *db_name, uint8_t mqtt_proto);
void nng_mqtt_sqlite_db_fini(nng_mqtt_sqlite_option *opt);
size_t nng_mqtt_sqlite_db_get_cached_size(nng_mqtt_sqlite_option *opt);
----

== DESCRIPTION

SQLite is disabled by default.To enable SQLite, it's necessary to compile with cmake option `-DNNG_ENABLE_SQLITE=ON`.


|===
|Function | Description | Return
|`nng_mqtt_alloc_sqlite_opt()` | allocate a nng_mqtt_sqlite_option object | 0: success +
nonzero: error code
|`nng_mqtt_free_sqlite_opt()` | free a nng_mqtt_sqlite_option object | 0
|`nng_mqtt_set_sqlite_enable()` | enable or disable sqlite caching | non
|`nng_mqtt_set_sqlite_db_dir()` | specify a mount path for SQLite DB file +
(default: client running path) | non
|`nng_mqtt_set_sqlite_max_rows()` | specify Max message limitation for caching +
0 means ineffective +
range: 1-infinity +
(default: 102400) | non
|`nng_mqtt_set_sqlite_flush_threshold()` |specify a threshold of flushing messages to flash +
1-infinity +
(default: 100)
| non
|`nng_mqtt_sqlite_db_init()` | initialize sqlite options and create or open a database file | non
|`nng_mqtt_sqlite_db_fini()` | deinit `nng_mqtt_sqlite_option` and close database file | non
|`nng_mqtt_sqlite_db_get_cached_size()` | get cached message size | message size
|===

== ERRORS

none

== SEE ALSO

[.text-left]
xref:nng_mqtt_msg_alloc.3.adoc[nng_mqtt_msg_alloc()],
xref:nng_mqtt_msg_set_connect.3.adoc[nng_mqtt_msg_set_connect()],
xref:xref:nng_pipe_notify.3.adoc[nng_pipe_notify()],
xref:nng_strerror.3.adoc[nng_strerror(3)],
xref:nng_url_parse.3.adoc[nng_url_parse(3)],
xref:nng.7.adoc[nng(7)]