Comment 1 for bug 418641

Revision history for this message
Alex Yurchenko (ayurchen) wrote :

Now it looks like this:

/*! Type of the status variable value in struct wsrep_status_var */
typedef enum wsrep_var_type
{
    WSREP_STATUS_STRING, //!< pointer to null-terminated string
    WSREP_STATUS_INT64, //!< int64_t
    WSREP_STATUS_DOUBLE, //!< double
}
wsrep_var_type_t;

/*! Generalized status variable representation */
struct wsrep_status_var
{
    const char* name; //!< variable name
    wsrep_var_type_t type; //!< variable value type
    union {
        int64_t _int64;
        double _double;
        const char* _string;
    } value; //!< variable value
};

  /*!
   * @brief Returns an array fo status variables.
   * Array is terminated by Null variable name.
   *
   * @param wsrep this wsrep handle
   * @return array of struct wsrep_status_var
   */
    struct wsrep_status_var* (*status_get) (wsrep_t*);

On provider side:
static struct wsrep_status_var wsrep_status[] =
{
    {"state_uuid", WSREP_STATUS_STRING, {._string = state_uuid_str}},
    {"last_committed", WSREP_STATUS_INT64, { -1 } },
    {"replicated", WSREP_STATUS_INT64, { 0 } },
    {"replicated_bytes", WSREP_STATUS_INT64, { 0 } },
    {"received", WSREP_STATUS_INT64, { 0 } },
    {"received_bytes", WSREP_STATUS_INT64, { 0 } },
    {"local_commits", WSREP_STATUS_INT64, { 0 } },
    {"local_cert_failures", WSREP_STATUS_INT64, { 0 } },
    {"local_bf_aborts", WSREP_STATUS_INT64, { 0 } },
    {NULL, 0, { 0 }}
};