AT&T ECOMP Vendor Event Listener library  0.1
evel_throttle.h
Go to the documentation of this file.
1 #ifndef EVEL_THROTTLE_INCLUDED
2 #define EVEL_THROTTLE_INCLUDED
3 
4 /**************************************************************************/
44 #include "evel_internal.h"
45 #include "jsmn.h"
46 
47 /*****************************************************************************/
48 /* Maximum depth of JSON response that we can handle. */
49 /*****************************************************************************/
50 #define EVEL_JSON_STACK_DEPTH 10
51 
52 /**************************************************************************/
55 #define EVEL_MAX_RESPONSE_TOKENS 1024
56 
57 /**************************************************************************/
62 typedef enum {
67 
68 /**************************************************************************/
72 typedef enum
73 {
74  /***************************************************************************/
75  /* Initial state. */
76  /***************************************************************************/
78 
79  /***************************************************************************/
80  /* {"commandList": [ */
81  /***************************************************************************/
83 
84  /***************************************************************************/
85  /* {"commandList": [{ */
86  /***************************************************************************/
88 
89  /***************************************************************************/
90  /* {"commandList": [{"command": { */
91  /***************************************************************************/
93 
94  /***************************************************************************/
95  /* ... "eventDomainThrottleSpecification": { */
96  /***************************************************************************/
98 
99  /***************************************************************************/
100  /* ... "suppressedFieldNames": [ */
101  /***************************************************************************/
103 
104  /***************************************************************************/
105  /* ... "suppressedNvPairsList": [ */
106  /***************************************************************************/
108 
109  /***************************************************************************/
110  /* ... "suppressedNvPairsList": [{ */
111  /***************************************************************************/
113 
114  /***************************************************************************/
115  /* ... "suppressedNvPairNames": [ */
116  /***************************************************************************/
118 
121 
122 /**************************************************************************/
125 typedef struct evel_json_stack_entry {
126 
127  /***************************************************************************/
128  /* The number of elements required at this level. */
129  /***************************************************************************/
131 
132  /***************************************************************************/
133  /* The number of elements collected at this level. */
134  /***************************************************************************/
136 
137  /***************************************************************************/
138  /* The collection state at this level in the JSON stack. */
139  /***************************************************************************/
141 
142  /***************************************************************************/
143  /* The key being collected (if json_state is EVEL_JSON_VALUE), or NULL. */
144  /***************************************************************************/
145  char * json_key;
146 
148 
149 /**************************************************************************/
152 typedef struct evel_json_stack {
153 
154  /***************************************************************************/
155  /* The current position of the stack - starting at zero. */
156  /***************************************************************************/
157  int level;
158 
159  /***************************************************************************/
160  /* The stack itself. */
161  /***************************************************************************/
163 
164  /***************************************************************************/
165  /* The underlying memory chunk. */
166  /***************************************************************************/
168 
170 
171 /**************************************************************************/
177 
178 /**************************************************************************/
184 
185 /**************************************************************************/
194 bool evel_handle_command_list(const MEMORY_CHUNK * const chunk,
195  const jsmntok_t * const json_tokens,
196  const int num_tokens,
197  MEMORY_CHUNK * const post);
198 
199 /**************************************************************************/
205 
206 /**************************************************************************/
214  const char * const field_name);
215 
216 /**************************************************************************/
225  const char * const field_name,
226  const char * const name);
227 
228 #endif
EVEL_EVENT_DOMAINS
Event domains for the various events we support.
Definition: evel.h:130
EVEL_JSON_STATE
The nature of the next token that we are iterating through.
Definition: evel_throttle.h:62
JSON token description.
Definition: jsmn.h:40
EVEL_JSON_STATE json_state
An entry in the JSON stack.
A chunk of memory used in the cURL functions.
Definition: evel_internal.h:77
bool evel_handle_command_list(const MEMORY_CHUNK *const chunk, const jsmntok_t *const json_tokens, const int num_tokens, MEMORY_CHUNK *const post)
Handle a JSON response from the listener, as a list of tokens from JSMN.
void evel_throttle_terminate()
Clean up event throttling.
struct evel_json_stack EVEL_JSON_STACK
The JSON stack.
The JSON stack.
Event Throttling Specification for a domain which is in a throttled state.
#define EVEL_JSON_STACK_DEPTH
Definition: evel_throttle.h:50
int json_count
int num_required
char * json_key
bool evel_throttle_suppress_nv_pair(EVEL_THROTTLE_SPEC *throttle_spec, const char *const field_name, const char *const name)
Determine whether a name-value pair should be allowed (not suppressed).
EVEL_JSON_COMMAND_STATE
States which we move through during JSON processing, tracking our way through the supported JSON stru...
Definition: evel_throttle.h:72
void evel_throttle_initialize()
Initialize event throttling to the default state.
EVEL internal definitions.
const MEMORY_CHUNK * chunk
bool evel_throttle_suppress_field(EVEL_THROTTLE_SPEC *throttle_spec, const char *const field_name)
Determine whether a field_name should be suppressed.
EVEL_THROTTLE_SPEC * evel_get_throttle_spec(EVEL_EVENT_DOMAINS domain)
Return the EVEL_THROTTLE_SPEC for a given domain.
struct evel_json_stack_entry EVEL_JSON_STACK_ENTRY
An entry in the JSON stack.