root/src/noit_check_tools.h

Revision 4b96846179a35015ac0b22d5fe9e9f92480f06a5, 1.3 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

check code consolidation. allow modules to be more terse and add convenience functions to make writing completely asynch checkers much easier. (add a postgres proof-of-concept asynch checker

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  */
5
6 #ifndef _NOIT_CHECK_TOOLS_H
7 #define _NOIT_CHECK_TOOLS_H
8
9 #include "noit_defines.h"
10 #include "eventer/eventer.h"
11 #include "noit_module.h"
12 #include "noit_check.h"
13 #include "utils/noit_hash.h"
14
15 typedef int (*dispatch_func_t)(noit_module_t *, noit_check_t *);
16
17 API_EXPORT(int)
18   noit_check_interpolate(char *buff, int len, const char *fmt,
19                          noit_hash_table *attrs,
20                          noit_hash_table *config);
21
22 API_EXPORT(int)
23   noit_check_schedule_next(noit_module_t *self,
24                            struct timeval *last_check, noit_check_t *check,
25                            struct timeval *now, dispatch_func_t recur);
26
27 API_EXPORT(void)
28   noit_check_run_full_asynch(noit_check_t *check, eventer_func_t callback);
29
30 #define INITIATE_CHECK(func, self, check) do { \
31   if(once) { \
32     func(self, check); \
33   } \
34   else if(!check->fire_event) { \
35     struct timeval epoch = { 0L, 0L }; \
36     noit_check_fake_last_check(check, &epoch, NULL); \
37     noit_check_schedule_next(self, &epoch, check, NULL, func); \
38   } \
39 } while(0)
40
41 API_EXPORT(void)
42   noit_check_make_attrs(noit_check_t *check, noit_hash_table *attrs);
43 API_EXPORT(void)
44   noit_check_release_attrs(noit_hash_table *attrs);
45
46
47 #endif
48
Note: See TracBrowser for help on using the browser.