![]() |
fuse_kafka
|
#include <stdlib.h>#include <stdio.h>#include "time_queue.h"Go to the source code of this file.
Functions | |
| unsigned long | time_queue_hash (unsigned char *str) |
| Internal: generates a djb2 hash. | |
| time_queue * | time_queue_new (unsigned int size, unsigned int quota) |
| Public: instantiates a new time queue, free it with time_queue_delete. | |
| unsigned long | time_queue_time () |
| Internal: get the time. | |
| void | time_queue_set (time_queue *queue, char *key) |
| Public: set a time queue key to current time. | |
| unsigned long * | time_queue_get (time_queue *queue, char *key) |
| Public: get last stored time pointer for given key. | |
| int | time_queue_overflows (time_queue *queue, char *key, unsigned int size) |
| Internal: checks if the given key overflows the quota. | |
| void | time_queue_delete (time_queue *queue) |
| Public: deletes the time queue structure and allocated content. | |
A time queue is a datastructure which allows to store time for a finite number of keys. It allows to check if, for a given key, a limit per unit of time is reached or not.
Definition in file time_queue.c.
| void time_queue_delete | ( | time_queue * | queue | ) |
Public: deletes the time queue structure and allocated content.
| queue | the queue to delete |
Definition at line 149 of file time_queue.c.
| unsigned long* time_queue_get | ( | time_queue * | queue, |
| char * | key | ||
| ) |
Public: get last stored time pointer for given key.
| queue | the time queue to modify |
| key | the key to get the value from |
Examples
time_queue_get(queue, "/unset/key") => NULL time_queue_get(queue, "/existing/key") => pointer to: 1412074060579654
Definition at line 110 of file time_queue.c.
| unsigned long time_queue_hash | ( | unsigned char * | str | ) |
Internal: generates a djb2 hash.
| str | the string to hash |
Examples
time_queue_hash('hello world') => 13876786532495509697
Definition at line 21 of file time_queue.c.
| time_queue* time_queue_new | ( | unsigned int | size, |
| unsigned int | quota | ||
| ) |
Public: instantiates a new time queue, free it with time_queue_delete.
| size | the maximum number of items saved in the queue |
| quota | the maximum size allowed per second per hash entry |
Examples
time_queue_new(10, 42) => time_queue*
Definition at line 42 of file time_queue.c.
| int time_queue_overflows | ( | time_queue * | queue, |
| char * | key, | ||
| unsigned int | size | ||
| ) |
Internal: checks if the given key overflows the quota.
| queue | the time queue to get data from |
| key | the key to check |
| size | the size to compare with the quota |
Examples
time_queue* queue = time_queue_new(10, 42); time_queue_set(queue, "/var/log/lol"); sleep(1); time_queue_overflows(queue, "/var/log/lol", 880); => 1
Definition at line 137 of file time_queue.c.
| void time_queue_set | ( | time_queue * | queue, |
| char * | key | ||
| ) |
Public: set a time queue key to current time.
| queue | the time queue to modify |
| key | the key to set |
Examples
time_queue_set(queue, "/var/log/blah.log")
Definition at line 75 of file time_queue.c.
| unsigned long time_queue_time | ( | ) |
Internal: get the time.
Definition at line 60 of file time_queue.c.
1.7.6.1