This repository has been archived by the owner on Jun 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxump_selector.icl
250 lines (226 loc) · 7.97 KB
/
xump_selector.icl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?xml?>
<!--
Copyright (c) 1996-2009 iMatix Corporation
This file is licensed under the GPL as follows:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
For information on alternative licensing for OEMs, please contact
iMatix Corporation.
-->
<class
name = "xump_selector"
comment = "Xump selector class"
script = "icl_gen"
license = "gpl"
>
<doc>
The xump_selector class references a selector resource held in a storage
layer. Note: probably needs addition of headers object for header based
routing.
</doc>
<inherit class = "icl_object">
<option name = "alloc" value = "cache" />
<option name = "links" value = "1" />
</inherit>
<import class = "xump" />
<public name = "header">
// Selector events
#define SELECTOR_WHEN_MATCH 1
#define SELECTOR_WHEN_FILTER 2
#define SELECTOR_WHEN_ALWAYS 3
#define SELECTOR_WHEN_OVERFLOW 4
#define SELECTOR_WHEN_DEFAULT 5
// Selector actions
#define SELECTOR_DO_COPY 1
#define SELECTOR_DO_MOVE 2
#define SELECTOR_DO_DELIVER 3
#define SELECTOR_DO_BOUNCE 4
</public>
<context>
uint
id;
char
*source_queue, // Queue where selector sits
*target_queue, // Optional target for messages
*operator, // Operator for event detection
*argument, // Argument for event detection
*address; // New address for action
int
event, // When to invoke selector
action; // What to do when invoked
Bool
enabled; // Active y/n?
uint
credits; // Selector credits
</context>
<method name = "new">
<argument name = "id" type = "uint" />
<argument name = "source queue" type = "char *" />
//
self->id = id;
self->source_queue = icl_mem_strdup (source_queue);
</method>
<method name = "destroy" private = "1">
icl_mem_free (self->source_queue);
icl_mem_free (self->target_queue);
icl_mem_free (self->operator);
icl_mem_free (self->argument);
icl_mem_free (self->target_queue);
icl_mem_free (self->address);
</method>
<method name = "when match" template = "function">
<doc>
Specifies match criteria for the event. The selector will be invoked
when the message matches the specified argument, using the specified
match operator. May not be mixed with other 'when' methods.
</doc>
<argument name = "operator" type = "char *">Extensible operator</argument>
<argument name = "argument" type = "char *">Requested match pattern</argument>
//
if (self->event) {
icl_console_print ("E: cannot register multiple events for selector");
assert (!self->event);
}
self->event = SELECTOR_WHEN_MATCH;
self->operator = icl_mem_strdup (operator);
self->argument = icl_mem_strdup (argument);
</method>
<method name = "when filter" template = "function">
<doc>
Specifies filter criteria for the event. The selector will be invoked
when the message matches the specified filter operator and argument. May
not be mixed with other 'when' methods.
</doc>
<argument name = "operator" type = "char *">Extensible operator</argument>
<argument name = "argument" type = "char *">Requested match pattern</argument>
//
if (self->event) {
icl_console_print ("E: cannot register multiple events for selector");
assert (!self->event);
}
self->event = SELECTOR_WHEN_FILTER;
self->operator = icl_mem_strdup (operator);
self->argument = icl_mem_strdup (argument);
</method>
<method name = "when always" template = "function">
<doc>
Specifies that the selector is invoked on every message that enters the
queue. May not be mixed with other 'when' methods.
</doc>
//
if (self->event) {
icl_console_print ("E: cannot register multiple events for selector");
assert (!self->event);
}
self->event = SELECTOR_WHEN_ALWAYS;
</method>
<method name = "when overflow" template = "function">
<doc>
Specifies that the selector is invoked on every message that enters the
queue when the queue is full. May not be mixed with other 'when' methods.
</doc>
//
if (self->event) {
icl_console_print ("E: cannot register multiple events for selector");
assert (!self->event);
}
self->event = SELECTOR_WHEN_OVERFLOW;
</method>
<method name = "when default" template = "function">
<doc>
Specifies that the selector is invoked on every message that cannot be
processed by any other selector queue. May not be mixed with other 'when'
methods.
</doc>
//
if (self->event) {
icl_console_print ("E: cannot register multiple events for selector");
assert (!self->event);
}
self->event = SELECTOR_WHEN_DEFAULT;
</method>
<method name = "do copy" template = "function">
<doc>
When the selector is invoked, it will copy the message to the specified
queue.
</doc>
<argument name = "target queue" type = "char *" />
//
if (self->action) {
icl_console_print ("E: cannot register multiple actions for selector");
assert (!self->action);
}
self->action = SELECTOR_DO_COPY;
self->target_queue = icl_mem_strdup (target_queue);
</method>
<method name = "do move" template = "function">
<doc>
When the selector is invoked, it will move the message to the specified
queue.
</doc>
<argument name = "target queue" type = "char *" />
//
if (self->action) {
icl_console_print ("E: cannot register multiple actions for selector");
assert (!self->action);
}
self->action = SELECTOR_DO_MOVE;
self->target_queue = icl_mem_strdup (target_queue);
</method>
<method name = "do deliver" template = "function">
<doc>
When the selector is invoked, it will move the message to the specified
queue, setting the message address to the new value specified.
</doc>
<argument name = "target queue" type = "char *" />
<argument name = "address" type = "char *" />
//
if (self->action) {
icl_console_print ("E: cannot register multiple actions for selector");
assert (!self->action);
}
self->action = SELECTOR_DO_DELIVER;
self->target_queue = icl_mem_strdup (target_queue);
self->address = icl_mem_strdup (address);
</method>
<method name = "do bounce" template = "function">
<doc>
When the selector is invoked, it will move the message to the specified
queue, setting the message address to the message return address, if any.
</doc>
<argument name = "target queue" type = "char *" />
//
if (self->action) {
icl_console_print ("E: cannot register multiple actions for selector");
assert (!self->action);
}
self->action = SELECTOR_DO_BOUNCE;
self->target_queue = icl_mem_strdup (target_queue);
</method>
<method name = "enable" template = "function">
<doc>
Enables or disables the selector. New selectors are disabled and the
caller must use this method at least once with a TRUE on_off argument
to active them.
</doc>
<argument name = "on off" type = "Bool" />
//
self->enabled = on_off;
</method>
<method name = "credit" template = "function">
<doc>
Adds a specified number of credits to the selector. When the selector
has
</doc>
<argument name = "credits" type = "uint" />
//
self->credits += credits;
</method>
<method name = "selftest" />
</class>