smax-clib v0.9
A C/C++ client library for SMA-X
Loading...
Searching...
No Matches
smax-resilient.c File Reference

This module adds trusty push delivery to SMA-X. If the server cannot be reached, push requests are stored and updated locally until the server connection is restored, at which point they are delivered. More...

Functions

boolean smaxIsResilient ()
 
void smaxSetResilient (boolean value)
 
void smaxSetResilientExit (boolean value)
 

Detailed Description

This module adds trusty push delivery to SMA-X. If the server cannot be reached, push requests are stored and updated locally until the server connection is restored, at which point they are delivered.

Date
Aug 14, 2019
Author
Attila Kovacs

This way, push requests are guaranteed to make it to the database sooner or later as long as the calling program keeps running.

It's mainly useful for daemons that generate infrequent data for the database. It's not especially meaningful for simple executables, which are run for limited time without persistence.

See also
smaxSetResilient()
smaxIsResilient()

Function Documentation

◆ smaxIsResilient()

boolean smaxIsResilient ( )

Checks whether the resiliency feature has been enabled.

Returns
TRUE if enabled, otherwise FALSE.
See also
smaxSetResilient()

◆ smaxSetResilient()

void smaxSetResilient ( boolean  value)

Enables the resiliency feature of the library, which keeps track of local changes destined to the database when the database is not reachable, and sending all locally stored updates once the database comes online again. However, after sending all pending updates to the remote server, the program may exit (default behavior), unless smaxSetResilientExit() is set to FALSE (0), so that it can be restarted in a fresh state, setting up subscriptions and scripts again as necessary.

Parameters
valueTRUE (non-zero) to enable, or FALSE (0) to disable resiliency.
See also
smaxIsResilient()
smaxSetResilientExit()

References FALSE, smaxAddConnectHook(), smaxRemoveConnectHook(), TRUE, and xvprintf.

◆ smaxSetResilientExit()

void smaxSetResilientExit ( boolean  value)

Sets whether the program should exit in resilient mode, after having pushed all local updates. The default is to exit since the reconnecting in resilient mode does not by itself re-establish existing subscriptions. However, when subscriptions aren't used, or if they are set up as a connect hook, the user may want the program to simply continue. This is possible by passing FALSE (0) as the argument to this call. This setting only takes effect when resilient mode is enabled. Otherwise, the exit policy is set by the RedisX library.

Parameters
valueWhether to exit the program after all local updates have been pushed to SMA-X after a recovering from an outage.
See also
smaxSetResilient()
smaxAddConnectHook()

References FALSE, and TRUE.