root/src/modules/lua_noit.h

Revision 5bf243f7a20f4b0718b616e7bda35cccf609d095, 1.1 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 10 years ago)

Baby steps.

lua checks can now be written. Simple wrappers for check manipulation are
in place. I need to figure out how to make lua resume into a coroutine and
invoke lua_error on resumption (so we can force a timeout).

noit.sleep(number) was implemanted as a proof-of-concept coro... It works!

Need to do sockets next -- will be slightly more complicated, but I do not
see it being traumatic.

refs #28

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  */
5
6 #ifndef LUA_NOIT_H
7 #define LUA_NOIT_H
8
9 #include "noit_defines.h"
10
11 #include "noit_conf.h"
12 #include "noit_module.h"
13 #include "noit_check.h"
14 #include "noit_check_tools.h"
15 #include "utils/noit_log.h"
16
17 #include <assert.h>
18
19 #include "lua.h"
20 #include "lauxlib.h"
21 #include "lualib.h"
22
23 typedef struct lua_module_closure {
24   char *object;
25   char *script;
26   lua_State *lua_state;
27 } lua_module_closure_t;
28
29 typedef struct noit_lua_check_info {
30   noit_module_t *self;
31   noit_check_t *check;
32   int timed_out;
33   eventer_t timeout_event;
34   lua_module_closure_t *lmc;
35   lua_State *coro_state;
36   struct timeval finish_time;
37   stats_t current;
38   noit_hash_table *events; /* Any eventers we need to cleanup */
39 } noit_lua_check_info_t;
40
41 int luaopen_noit(lua_State *L);
42 noit_lua_check_info_t *get_ci(lua_State *L);
43 int noit_lua_resume(noit_lua_check_info_t *ci, int nargs);
44 void noit_lua_check_register_event(noit_lua_check_info_t *ci, eventer_t e);
45 void noit_lua_check_deregister_event(noit_lua_check_info_t *ci, eventer_t e);
46
47 #endif
Note: See TracBrowser for help on using the browser.