Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_kafka.h File Reference

Kafka generic produce and consume event header. More...

#include "nilorea/n_log.h"
#include "nilorea/n_network.h"
#include "cJSON.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <libgen.h>
#include <errno.h>
#include <unistd.h>
#include "rdkafka.h"
+ Include dependency graph for n_kafka.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  N_KAFKA
 structure of a KAFKA consumer or producer handle More...
 
struct  N_KAFKA_EVENT
 structure of a KAFKA message More...
 

Macros

#define N_KAFKA_EVENT_CREATED   5
 state of a freshly created event
 
#define N_KAFKA_EVENT_ERROR   2
 state of an errored event
 
#define N_KAFKA_EVENT_OK   4
 state of an OK event
 
#define N_KAFKA_EVENT_QUEUED   0
 state of a queued event
 
#define N_KAFKA_EVENT_WAITING_ACK   1
 state of a sent event waiting for acknowledgement
 

Functions

int n_kafka_add_header (N_KAFKA_EVENT *event, N_STR *key, N_STR *value)
 add a header to an event
 
int n_kafka_add_header_ex (N_KAFKA_EVENT *event, char *key, size_t key_length, char *value, size_t value_length)
 add a header to an event (extended version)
 
void n_kafka_delete (N_KAFKA *kafka)
 delete a kafka handle
 
int n_kafka_disable_event_consumption (N_KAFKA *kafka)
 disable event consumption
 
int n_kafka_disable_event_production (N_KAFKA *kafka)
 disable event production
 
int n_kafka_dump_unprocessed (N_KAFKA *kafka, char *directory)
 dump unprocessed events to a directory
 
int n_kafka_enable_event_consumption (N_KAFKA *kafka)
 enable event consumption
 
int n_kafka_enable_event_production (N_KAFKA *kafka)
 enable event production
 
int n_kafka_event_destroy (N_KAFKA_EVENT **event)
 destroy a kafka event
 
void n_kafka_event_destroy_ptr (void *event)
 destroy a kafka event (void pointer version for list destructor)
 
N_KAFKA_EVENTn_kafka_get_event (N_KAFKA *kafka)
 get the next received event
 
int32_t n_kafka_get_schema_from_char (const char *string)
 get schema id from a char string
 
int32_t n_kafka_get_schema_from_nstr (const N_STR *string)
 get schema id from an N_STR string
 
int n_kafka_get_status (N_KAFKA *kafka, size_t *nb_queued, size_t *nb_waiting, size_t *nb_error)
 get kafka queue status counters
 
N_KAFKAn_kafka_load_config (char *config_file, int mode)
 load kafka configuration from file
 
int n_kafka_load_unprocessed (N_KAFKA *kafka, const char *directory)
 load unprocessed events from a directory
 
N_KAFKAn_kafka_new (int32_t poll_timeout, int32_t poll_interval, size_t errstr_len)
 create a new kafka handle
 
N_KAFKA_EVENTn_kafka_new_event (int schema_id)
 create a new empty kafka event
 
N_KAFKA_EVENTn_kafka_new_event_from_char (const char *string, size_t written, int schema_id)
 create a new kafka event from a char string
 
N_KAFKA_EVENTn_kafka_new_event_from_file (char *filename, int schema_id)
 create a new kafka event from a file
 
N_KAFKA_EVENTn_kafka_new_event_from_string (const N_STR *string, int schema_id)
 create a new kafka event from an N_STR string
 
int n_kafka_new_headers (N_KAFKA_EVENT *event, size_t count)
 create new headers for an event
 
int n_kafka_poll (N_KAFKA *kafka)
 poll kafka for events
 
int n_kafka_produce (N_KAFKA *kafka, N_KAFKA_EVENT *event)
 produce a kafka event
 
int n_kafka_put_schema_in_char (char *string, int schema_id)
 put schema id in a char string
 
int n_kafka_put_schema_in_nstr (N_STR *string, int schema_id)
 put schema id in an N_STR string
 
int n_kafka_start_polling_thread (N_KAFKA *kafka)
 start the kafka polling thread
 
int n_kafka_stop_polling_thread (N_KAFKA *kafka)
 stop the kafka polling thread
 

Detailed Description

Kafka generic produce and consume event header.

Author
Castagnier Mickael
Version
1.0
Date
23/11/2022

Definition in file n_kafka.h.