Next: , Previous: , Up: API Reference   [Contents]


B.9 Database Client: STMYSQLClient

Async MySQL/MariaDB helper used by the Core for labels, history, and stats (starter/mysql-client.h).

Function: STMYSQLClient * st_mysql_client_new (const gchar *source, const gchar *host, guint16 port, const char *user, const gchar *pass, const gchar *db_name, GError **error)

Creates a client and begins connecting. db_name is required (non-empty valid identifier). May return an object in degraded state if connect fails.

source

Logical source label for logs/history attribution.

host

Database host.

port

Database TCP port.

user

Database user.

pass

Database password.

db_name

Schema name (required).

error

Filled when construction fails hard (e.g. invalid db_name).

Returns: New STMYSQLClient, or NULL on invalid arguments.

Function: gboolean st_mysql_client_validate_db_name (const gchar *name, GError **error)

Validates a schema name before use.

name

Candidate identifier.

error

Filled with the reason on failure.

Returns: TRUE if acceptable.

Enumeration: STMYSQLClientState
ST_MYSQL_CLIENT_STATE_IDLE

Not connected.

ST_MYSQL_CLIENT_STATE_CONNECTING

Connect in progress.

ST_MYSQL_CLIENT_STATE_READY

Ready to enqueue work.

ST_MYSQL_CLIENT_STATE_FAILED

Connection failed.

Function: STMYSQLClientState st_mysql_client_get_state (STMYSQLClient *self)

Reads connection state.

self

Client.

Returns: Current state.

Function: gboolean st_mysql_client_is_ready (STMYSQLClient *self)

Convenience for ready state.

self

Client.

Returns: TRUE if ready.

Function: void st_mysql_client_set_notify_context (STMYSQLClient *self, GMainContext *ctx)

Sets affinity for client signals.

self

Client.

ctx

Context, or NULL for default.

Returns: Nothing.

Function: GMainContext * st_mysql_client_get_notify_context (STMYSQLClient *self)

Reads notify affinity.

self

Client.

Returns: Borrowed GMainContext.

Function: void st_mysql_client_set_max_queue_depth (STMYSQLClient *self, guint depth)

Bounds the async write queue (default 1024). Useful for tests/ops.

self

Client.

depth

Maximum queued operations.

Returns: Nothing.

Function: guint st_mysql_client_get_queue_depth (STMYSQLClient *self)

Reads the current queue depth.

self

Client.

Returns: Number of queued operations.

Function: gboolean st_mysql_client_store_input_label (STMYSQLClient *self, const STInput *input, GError **error)

Enqueues an upsert of the input’s label metadata.

self

Client.

input

Source input.

error

Filled if enqueue fails.

Returns: TRUE if queued; completion/failure arrives via signals.

Function: gboolean st_mysql_client_store_output_label (STMYSQLClient *self, const STOutput *output, GError **error)

Enqueues an upsert of the output’s label metadata.

self

Client.

output

Source output.

error

Filled if enqueue fails.

Returns: TRUE if queued.

Function: gboolean st_mysql_client_store_history (STMYSQLClient *self, const gchar *name, gdouble value, guint64 flags, GError **error)

Enqueues a history row for an I/O identifier.

self

Client.

name

I/O identifier.

value

Sample value.

flags

Flags at sample time.

error

Filled if enqueue fails.

Returns: TRUE if queued.

Function: gdouble st_mysql_client_get_last_history_value (STMYSQLClient *self, const char *name, GError **error)

Reads the most recent history value for name (may block/query depending on implementation path).

self

Client.

name

I/O identifier.

error

Filled on failure.

Returns: Last value, or an invalid sentinel on failure.

Function: gboolean st_mysql_client_store_stats (STMYSQLClient *self, const STStats *stats, GError **error)

Enqueues a stats upsert for the service named in stats.

self

Client.

stats

Stats object.

error

Filled if enqueue fails.

Returns: TRUE if queued.


Next: Service D-Bus Constants, Previous: Services and Communication: Server and Client, Up: API Reference   [Contents]