Ripples 1.0
High Performant Software Architecture For Transaction Processing
Loading...
Searching...
No Matches
Resources

Detailed Description

Resources are data sets that application uses in its processing logic. For a DNS authoritative server this could be, amongst others, a GeoIP location DB, along with DNS records DB (zone data).

Resources are loaded, and reloaded in a dedicated thread to avoid blocking and time consuming operations in DNS query processing threads. Once loaded into memory resources are treated as read only and shared amongst query processing threads. For data validity purpose each thread keeps a reference to the shared object. When a resource changes, processing thread is notified and updates the reference (pointer) to such a resource. This update is done once all pending queries have us been processed which ensures data validity (data does not change under in the middle of resolving a query).

When all processing threads have updated their resource reference, the old resource data can safely be disposed of.

Data Structures

struct  resource_s
 
struct  resource_loop_args_s
 

Typedefs

typedef struct resource_s resource_t
 
typedef int(* resource_check_load_fn) (resource_t *resource, void **buf, size_t *buf_len, char *err, size_t err_len)
 
typedef void(* resource_release_fn) (resource_t *resource, void *buf)
 
typedef struct resource_loop_args_s resource_loop_args_t
 

Functions

void * resource_loop (void *args)
 
void resource_release_raw_file (resource_t *resource, void *buf)
 
int resource_check_load_raw_file (resource_t *resource, void **buf, size_t *buf_len, char *err, size_t err_len)
 

Typedef Documentation

◆ resource_check_load_fn

typedef int(* resource_check_load_fn) (resource_t *resource, void **buf, size_t *buf_len, char *err, size_t err_len)

Function definition for custom function to be used when checking if resource changed and loading the resource on change.

Parameters
resourceResource object to check and update.
bufWhere to store pointer to loaded data.
buf_lenSize of buffer where new data was loaded into.
errWhere to store error message if error was encountered.
err_lenLength of err buffer.
Returns
On success returns 0, otherwise an error occurred.

◆ resource_loop_args_t

Structure holds arguments passed to resource_loop function. Since resource_loop function is started by pthread it can only receive one argument hence placing all arguments into one structure.

◆ resource_release_fn

typedef void(* resource_release_fn) (resource_t *resource, void *buf)

Function definition for custom function used to release resource data.

Parameters
resourceResource object this resource data is for.
bufData to release.

◆ resource_t

typedef struct resource_s resource_t

Structure describes a resource which is a file on disk. A resource is loaded at application start and used by other parts of the application. Resource could be periodically checked for change and updated resource data loaded.

Function Documentation

◆ resource_check_load_raw_file()

int resource_check_load_raw_file ( resource_t resource,
void **  buf,
size_t *  buf_len,
char *  err,
size_t  err_len 
)

Function checks for change and if changed loads a file into memory buffer as raw data.

Change is checked for by stating the file for change time.

Parameters
resourceResource to check
bufWhere to store pointer to loaded data, on change.
buf_lenLength of buf available to use.
errBuffer where to store error string if error was encountered.
err_lenLength of err buffer available to use.
Returns
1 - Resource changed and was successfully loaded into buf 0 - Resource has not changed. -1 - There was an error either checking of loading the resource file. Error message is populated.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resource_loop()

void * resource_loop ( void *  args)

Resource loop function. It periodically checks resources for change. On resource change it loads the new resource into memory and notifies each vectorloop thread that resource changed.

Note
This loop runs indefinitely and is meant to be run from the main() function, not on vectorloop thread, or any other tread.
Parameters
argsObject with arguments passed to resource loop.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resource_release_raw_file()

void resource_release_raw_file ( resource_t resource,
void *  buf 
)

Function releases resource data of type raw file.

Parameters
resourceResource this data applies to.
bufData to be released.
Here is the caller graph for this function: