trafilo 0.1.0
Streaming event-handler framework in C
Loading...
Searching...
No Matches
trafilo.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  event_t
 A struct to hold event data. More...
struct  window_result_t
 A result to be piped to sinking module when a window emits. More...
struct  trafilo_config_t
 Configuration struct for Trafilo framework. More...

Typedefs

typedef int(* trafilo_parse_fn) (const char *raw, size_t len, event_t **out)
 Parse and fillout **out with a fresh event_t.
typedef void(* trafilo_event_free_fn) (event_t *event)
 Free a user allocated event from memory.
typedef void(* trafilo_handle_fn) (const event_t *event, void *user_state)
 Handling callback function provided by user.
typedef void(* trafilo_sink_fn) (const char *key, const window_result_t *result, void *user_state)
 Sink window callback.
typedef void *(* trafilo_state_init_fn) (const char *key)
 Initialize the state of a bucket, called the first time a key is seen.
typedef void(* trafilo_state_free_fn) (void *user_state)
 Free the user defined state, when a bucket is evicted.

Functions

trafilo_t * trafilo_create (const trafilo_config_t *config)
 Create a framework instance.
int trafilo_run (trafilo_t *trafilo)
 Run the framework. Blocks until trafilo_shutdown() is called.
void trafilo_shutdown (trafilo_t *trafilo)
 Signal the framework to shut down.
void trafilo_destroy (trafilo_t *t)
 Free all resources.
int trafilo_emit (trafilo_t *t, const char *raw, size_t len)
 Push a raw line into the framework's queue, bypassing the socket.

Typedef Documentation

◆ trafilo_event_free_fn

typedef void(* trafilo_event_free_fn) (event_t *event)

Free a user allocated event from memory.

Parameters
eventEvent to be freed.

◆ trafilo_handle_fn

typedef void(* trafilo_handle_fn) (const event_t *event, void *user_state)

Handling callback function provided by user.

Parameters
eventEvent to be handled.
user_stateBucket's state pointer.

◆ trafilo_parse_fn

typedef int(* trafilo_parse_fn) (const char *raw, size_t len, event_t **out)

Parse and fillout **out with a fresh event_t.

Parameters
rawRaw log entry from stream.
lenLength of the raw entry.
outNew parsed entry along with event data.
Returns
0 on success, -1 to drop entry.

◆ trafilo_sink_fn

typedef void(* trafilo_sink_fn) (const char *key, const window_result_t *result, void *user_state)

Sink window callback.

Parameters
keyBucket identifier (service identifier).
resultWindow result snapshot.
user_stateBucket's state pointer.

◆ trafilo_state_free_fn

typedef void(* trafilo_state_free_fn) (void *user_state)

Free the user defined state, when a bucket is evicted.

Parameters
user_stateState to be freed.

◆ trafilo_state_init_fn

typedef void *(* trafilo_state_init_fn) (const char *key)

Initialize the state of a bucket, called the first time a key is seen.

Parameters
keyBucket specific key.
Returns
Pointer to initialized state.

Function Documentation

◆ trafilo_create()

trafilo_t * trafilo_create ( const trafilo_config_t * config)

Create a framework instance.

Parameters
configPointer to the configuration struct.
Returns
New trafilo_t* on success, NULL on invalid config or alloc failure.

◆ trafilo_destroy()

void trafilo_destroy ( trafilo_t * t)

Free all resources.

Parameters
tThe framework instance.

◆ trafilo_emit()

int trafilo_emit ( trafilo_t * t,
const char * raw,
size_t len )

Push a raw line into the framework's queue, bypassing the socket.

Parameters
tThe framework instance.
rawRaw line data.
lenLength of the raw line.
Returns
0 on success, -1 if queue full or framework shutting down.

◆ trafilo_run()

int trafilo_run ( trafilo_t * trafilo)

Run the framework. Blocks until trafilo_shutdown() is called.

Parameters
trafiloThe framework instance.
Returns
0 on clean shutdown, non-zero on error.

◆ trafilo_shutdown()

void trafilo_shutdown ( trafilo_t * trafilo)

Signal the framework to shut down.

Parameters
trafiloThe framework instance.