~ne02ptzero/libfloat

ref: cb70314608dbeef0f66a7692be6101c16414cae9 libfloat/log.h -rw-r--r-- 1.9 KiB
cb703146 — Michael Bonfils Ignore snapshot log if it matches current snapshot 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef LIBFLOAT_LOG_H
#define LIBFLOAT_LOG_H

#include "node.h"
#include "externals/list.h"

typedef enum {
    LIBFLOAT_HOPEFULLY_CONSISTENT = 0,  /*!< Callback when log is in memory */
    LIBFLOAT_EVENTUALLY_CONSISTENT,     /*!< Callback when leader as written log and queued replication */
    LIBFLOAT_STRONGLY_CONSISTENT,       /*!< Callback when a majority of nodes have replicated the log */
    LIBFLOAT_ABSOLUTELY_CONSISTENT,      /*!< Callback when all nodes have replicated the log */
} libfloat_commit_type_t;

typedef enum {
    LIBFLOAT_ENTRY_COMMITTED = 0,
    LIBFLOAT_ENTRY_REFUSED,
    LIBFLOAT_ENTRY_TIMEOUT
} libfloat_commit_status_t;

typedef struct {
    uint32_t            type;   /*!< Type of log. Implementation defined. 0 is reserved */
    size_t              len;    /*!< Length of the buffer */
    uint8_t             *buf;   /*!< Log data */

    /* */
    libfloat_term_t     term;   /*!< Log Term */
} libfloat_log_data_t;

typedef struct {
    libfloat_node_id_t  id;
    libfloat_list_t     next;
} libfloat_node_ack_t;

typedef struct {
    libfloat_entry_id_t         id;     /*!< Log ID */
    libfloat_term_t             term;   /*!< Log Term */
    libfloat_log_data_t         *data;  /*!< Log data (can be NULL) */

    /* This is "private" internal informations, don't send this over the wire */
    void                        (*commit)(void *, libfloat_commit_status_t);    /*!< Commit callback */
    libfloat_commit_type_t      commit_type;                                    /*!< Commit type */
    void                        *udata;                                         /*!< User data for callback */
    time_t                      started;                                        /*!< Age of the log */
    libfloat_list_t             node_acks;                                      /*!< List of nodes that have replicated this log */

    libfloat_list_t             next;
} libfloat_log_entry_t;

#endif /* LIBFLOAT_LOG_H */