1 /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef MEMCACHED_CALLBACK_H 3 #define MEMCACHED_CALLBACK_H 4 5 #include "memcached/engine_common.h" 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 /** 12 * Event types for callbacks to the engine indicating state 13 * changes in the server. 14 */ 15 typedef enum { 16 ON_CONNECT = 0, /**< A new connection was established. */ 17 ON_DISCONNECT = 1, /**< A connection was terminated. */ 18 ON_AUTH = 2, /**< A connection was authenticated. */ 19 ON_SWITCH_CONN = 3, /**< Processing a different connection on this thread. */ 20 ON_LOG_LEVEL = 4 /**< Changed log level */ 21 } ENGINE_EVENT_TYPE; 22 23 #define MAX_ENGINE_EVENT_TYPE 5 24 25 /** 26 * Callback for server events. 27 * 28 * @param cookie The cookie provided by the frontend 29 * @param type the type of event 30 * @param event_data additional event-specific data. 31 * @param cb_data data as registered 32 */ 33 typedef void (*EVENT_CALLBACK)(const void *cookie, 34 ENGINE_EVENT_TYPE type, 35 const void *event_data, 36 const void *cb_data); 37 38 /** 39 * The API provided by the server to manipulate callbacks 40 */ 41 typedef struct { 42 /** 43 * Register an event callback. 44 * 45 * @param type the type of event to register 46 * @param cb the callback to fire when the event occurs 47 * @param cb_data opaque data to be given back to the caller 48 * on event 49 */ 50 void (*register_callback)(ENGINE_HANDLE *engine, 51 ENGINE_EVENT_TYPE type, 52 EVENT_CALLBACK cb, 53 const void *cb_data); 54 55 /** 56 * Fire callbacks 57 */ 58 void (*perform_callbacks)(ENGINE_EVENT_TYPE type, 59 const void *data, 60 const void *cookie); 61 } SERVER_CALLBACK_API; 62 63 #ifdef __cplusplus 64 } 65 #endif 66 67 #endif 68