AT&T ECOMP Vendor Event Listener library
0.1
|
Event Manager. More...
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <pthread.h>
#include <curl/curl.h>
#include "evel.h"
#include "evel_internal.h"
#include "ring_buffer.h"
#include "evel_throttle.h"
Go to the source code of this file.
Functions | |
EVEL_ERR_CODES | event_handler_initialize (const char *const event_api_url, const char *const throt_api_url, const char *const username, const char *const password, int verbosity) |
Initialize the event handler. More... | |
EVEL_ERR_CODES | event_handler_run () |
Run the event handler. More... | |
EVEL_ERR_CODES | event_handler_terminate () |
Terminate the event handler. More... | |
EVEL_ERR_CODES | evel_post_event (EVENT_HEADER *event) |
Post an event. More... | |
size_t | evel_write_callback (void *contents, size_t size, size_t nmemb, void *userp) |
Callback function to provide returned data. More... | |
void | evel_handle_event_response (const MEMORY_CHUNK *const chunk, MEMORY_CHUNK *const post) |
Handle a JSON response from the listener, contained in a MEMORY_CHUNK. More... | |
Event Manager.
Simple event manager that is responsible for taking events (Heartbeats, Faults and Measurements) from the ring-buffer and posting them to the API.
Copyright(c) <2016>, AT&T Intellectual Property. All other rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY AT&T INTELLECTUAL PROPERTY ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AT&T INTELLECTUAL PROPERTY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file evel_event_mgr.c.
void evel_handle_event_response | ( | const MEMORY_CHUNK *const | chunk, |
MEMORY_CHUNK *const | post | ||
) |
Handle a JSON response from the listener, contained in a MEMORY_CHUNK.
Tokenize the response, and decode any tokens found.
chunk | The memory chunk containing the response. |
post | The memory chunk in which to place any resulting POST. |
Definition at line 904 of file evel_event_mgr.c.
EVEL_ERR_CODES evel_post_event | ( | EVENT_HEADER * | event | ) |
Post an event.
event | The event to be posted. |
EVEL_SUCCESS | On success |
One of ::EVEL_ERR_CODES | On failure. |
Definition at line 497 of file evel_event_mgr.c.
size_t evel_write_callback | ( | void * | contents, |
size_t | size, | ||
size_t | nmemb, | ||
void * | userp | ||
) |
Callback function to provide returned data.
Copy data into the supplied buffer, write_callback::ptr, checking size limits.
Definition at line 712 of file evel_event_mgr.c.
EVEL_ERR_CODES event_handler_initialize | ( | const char *const | event_api_url, |
const char *const | throt_api_url, | ||
const char *const | username, | ||
const char *const | password, | ||
int | verbosity | ||
) |
Initialize the event handler.
Primarily responsible for getting CURL ready for use.
[in] | event_api_url | The URL where the Vendor Event Listener API is expected to be. |
[in] | throt_api_url | The URL where the Throttling API is expected to be. |
[in] | username | The username for the Basic Authentication of requests. |
[in] | password | The password for the Basic Authentication of requests. |
verbosity | 0 for normal operation, positive values for chattier logs. |
Definition at line 133 of file evel_event_mgr.c.
EVEL_ERR_CODES event_handler_run | ( | ) |
Run the event handler.
Spawns the thread responsible for handling events and sending them to the API.
EVEL_SUCCESS | if everything OK. |
One | of EVEL_ERR_CODES if there was a problem. |
Definition at line 371 of file evel_event_mgr.c.
EVEL_ERR_CODES event_handler_terminate | ( | ) |
Terminate the event handler.
Shuts down the event handler thread in as clean a way as possible. Sets the global exit flag and then signals the thread to interrupt it since it's most likely waiting on the ring-buffer.
Having achieved an orderly shutdown of the event handler thread, clean up the cURL library's resources cleanly.
EVEL_SUCCESS | if everything OK. |
One | of EVEL_ERR_CODES if there was a problem. |
Definition at line 408 of file evel_event_mgr.c.