1 #ifndef NCHAN_REDIS_LUA_SCRIPTS_H
2 #define NCHAN_REDIS_LUA_SCRIPTS_H
3 // don't edit this please, it was auto-generated by hsss
4 // https://github.com/slact/hsss
5 
6 typedef struct {
7   char *name;
8   char *hash;
9   char *script;
10 } redis_lua_script_t;
11 
12 typedef struct {
13   //input:  keys: [], values: [namespace, channel_id, number, time]
14   //output: current_fake_subscribers
15   redis_lua_script_t add_fakesub;
16 
17   //input:  keys: [], values: [namespace, channel_id, ttl]
18   // ttl is for when there are no messages but at least 1 subscriber.
19   //output: seconds until next keepalive is expected, or -1 for "let it disappear"
20   redis_lua_script_t channel_keepalive;
21 
22   //input: keys: [],  values: [ namespace, channel_id ]
23   //output: channel_hash {ttl, time_last_seen, subscribers, messages} or nil
24   // delete this channel and all its messages
25   redis_lua_script_t delete;
26 
27   //input: keys: [],  values: [ namespace, channel_id ]
28   //output: channel_hash {ttl, time_last_seen, subscribers, last_channel_id, messages} or nil
29   // finds and return the info hash of a channel, or nil of channel not found
30   redis_lua_script_t find_channel;
31 
32   //input:  keys: [], values: [namespace, channel_id, msg_time, msg_tag, no_msgid_order, create_channel_ttl]
33   //output: result_code, msg_ttl, msg_time, msg_tag, prev_msg_time, prev_msg_tag, message, content_type, eventsource_event, compression_type, channel_subscriber_count
34   // no_msgid_order: 'FILO' for oldest message, 'FIFO' for most recent
35   // create_channel_ttl - make new channel if it's absent, with ttl set to this. 0 to disable.
36   // result_code can be: 200 - ok, 404 - not found, 410 - gone, 418 - not yet available
37   redis_lua_script_t get_message;
38 
39   //input:  keys: [message_key], values: []
40   //output: msg_ttl, msg_time, msg_tag, prev_msg_time, prev_msg_tag, message, content_type, eventsource_event, compression, channel_subscriber_count
41   redis_lua_script_t get_message_from_key;
42 
43   //input:  keys: [unique_request_id_key], values: []
44   //output: next_unique_request_id_integer
45   redis_lua_script_t get_subscriber_info_id;
46 
47   //input:  keys: [], values: [namespace, channel_id, time, message, content_type, eventsource_event, compression_setting, msg_ttl, max_msg_buf_size, pubsub_msgpacked_size_cutoff, optimize_target]
48   //output: channel_hash {ttl, time_last_subscriber_seen, subscribers, last_message_id, messages}, channel_created_just_now?
49   redis_lua_script_t publish;
50 
51   //input:  keys: [], values: [namespace, channel_id, status_code]
52   //output: current_subscribers
53   redis_lua_script_t publish_status;
54 
55   //input: keys: [],  values: [ namespace, channel_id, info_response_id ]
56   //output: -nothing-
57   redis_lua_script_t request_subscriber_info;
58 
59   //redis-store consistency check
60   redis_lua_script_t rsck;
61 
62   //input: keys: [], values: [namespace, channel_id, subscriber_id, active_ttl, time, want_channel_settings]
63   //  'subscriber_id' can be '-' for new id, or an existing id
64   //  'active_ttl' is channel ttl with non-zero subscribers. -1 to persist, >0 ttl in sec
65   //output: subscriber_id, num_current_subscribers, next_keepalive_time, channel_buffer_length
66   //  'channel_buffer_length' is returned only if want_channel_settings is 1
67   redis_lua_script_t subscriber_register;
68 
69   //input: keys: [], values: [namespace, channel_id, subscriber_id, empty_ttl]
70   // 'subscriber_id' is an existing id
71   // 'empty_ttl' is channel ttl when without subscribers. 0 to delete immediately, -1 to persist, >0 ttl in sec
72   //output: subscriber_id, num_current_subscribers
73   redis_lua_script_t subscriber_unregister;
74 
75 } redis_lua_scripts_t;
76 extern redis_lua_scripts_t redis_lua_scripts;
77 extern const int redis_lua_scripts_count;
78 #define REDIS_LUA_SCRIPTS_EACH(script) \
79 for((script)=(redis_lua_script_t *)&redis_lua_scripts; (script) < (redis_lua_script_t *)(&redis_lua_scripts + 1); (script)++)
80 #endif //NCHAN_REDIS_LUA_SCRIPTS_H
81