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 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
|
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="libprelude-prelude-connection-pool">
<refmeta>
<refentrytitle id="top_of_page">prelude-connection-pool</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>LIBPRELUDE Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>prelude-connection-pool</refname>
<refpurpose>
Pool of connection handling</refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>
<refsynopsisdiv id="synopsis">
<title id="synopsis.title">Synopsis</title>
<synopsis>
enum <link linkend="prelude-connection-pool-flags-t">prelude_connection_pool_flags_t</link>;
enum <link linkend="prelude-connection-pool-event-t">prelude_connection_pool_event_t</link>;
typedef <link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link>;
<link linkend="void">void</link> <link linkend="prelude-connection-pool-broadcast">prelude_connection_pool_broadcast</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-msg-t">prelude_msg_t</link> *msg);
<link linkend="void">void</link> <link linkend="prelude-connection-pool-broadcast-async">prelude_connection_pool_broadcast_async</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-msg-t">prelude_msg_t</link> *msg);
<link linkend="int">int</link> <link linkend="prelude-connection-pool-init">prelude_connection_pool_init</link> (<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);
<link linkend="int">int</link> <link linkend="prelude-connection-pool-new">prelude_connection_pool_new</link> (<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> **ret,
<link linkend="prelude-client-profile-t">prelude_client_profile_t</link> *cp,
<link linkend="prelude-connection-permission-t">prelude_connection_permission_t</link> permission);
<link linkend="prelude-list-t">prelude_list_t</link>* <link linkend="prelude-connection-pool-get-connection-list">prelude_connection_pool_get_connection_list</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);
<link linkend="int">int</link> <link linkend="prelude-connection-pool-add-connection">prelude_connection_pool_add_connection</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-t">prelude_connection_t</link> *cnx);
<link linkend="int">int</link> <link linkend="prelude-connection-pool-set-connection-dead">prelude_connection_pool_set_connection_dead</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-t">prelude_connection_t</link> *cnx);
<link linkend="int">int</link> <link linkend="prelude-connection-pool-set-connection-alive">prelude_connection_pool_set_connection_alive</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-t">prelude_connection_t</link> *cnx);
<link linkend="int">int</link> <link linkend="prelude-connection-pool-set-connection-string">prelude_connection_pool_set_connection_string</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
const <link linkend="char">char</link> *cfgstr);
const <link linkend="char">char</link>* <link linkend="prelude-connection-pool-get-connection-string">prelude_connection_pool_get_connection_string</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);
<link linkend="void">void</link> <link linkend="prelude-connection-pool-destroy">prelude_connection_pool_destroy</link> (<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);
<link linkend="prelude-connection-pool-flags-t">prelude_connection_pool_flags_t</link> <link linkend="prelude-connection-pool-get-flags">prelude_connection_pool_get_flags</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);
<link linkend="void">void</link> <link linkend="prelude-connection-pool-set-flags">prelude_connection_pool_set_flags</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-pool-flags-t">prelude_connection_pool_flags_t</link> flags);
<link linkend="void">void</link> <link linkend="prelude-connection-pool-set-required-permission">prelude_connection_pool_set_required_permission</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-permission-t">prelude_connection_permission_t</link> req_perm);
<link linkend="void">void</link> <link linkend="prelude-connection-pool-set-data">prelude_connection_pool_set_data</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="void">void</link> *data);
<link linkend="void">void</link>* <link linkend="prelude-connection-pool-get-data">prelude_connection_pool_get_data</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);
<link linkend="int">int</link> <link linkend="prelude-connection-pool-check-event">prelude_connection_pool_check_event</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="int">int</link> timeout,
<link linkend="int">int</link> (*event_cb) (prelude_connection_pool_t *pool,prelude_connection_pool_event_t event,prelude_connection_t *cnx, void *extra),
<link linkend="void">void</link> *extra);
<link linkend="int">int</link> <link linkend="prelude-connection-pool-recv">prelude_connection_pool_recv</link> (<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="int">int</link> timeout,
<link linkend="prelude-connection-t">prelude_connection_t</link> **outconn,
<link linkend="prelude-msg-t">prelude_msg_t</link> **outmsg);
<link linkend="void">void</link> <link linkend="prelude-connection-pool-set-global-event-handler">prelude_connection_pool_set_global_event_handler</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-pool-event-t">prelude_connection_pool_event_t</link> wanted_events,
<link linkend="int">int</link> (*callback) (prelude_connection_pool_t *pool,prelude_connection_pool_event_t events));
<link linkend="void">void</link> <link linkend="prelude-connection-pool-set-event-handler">prelude_connection_pool_set_event_handler</link>
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-pool-event-t">prelude_connection_pool_event_t</link> wanted_events,
<link linkend="int">int</link> (*callback) (prelude_connection_pool_t *pool,prelude_connection_pool_event_t events,prelude_connection_t *cnx));
</synopsis>
</refsynopsisdiv>
<refsect1 id="desc">
<title id="desc.title">Description</title>
<para>
This API handle pool of connection, allowing to address a set of connection using only one object.
</para>
<para>
AND & OR of connection are supported, so that it is possible to
address several connection at once, or to only address a set of connection
if another connection went down.
</para>
<para>
Additionally it provide failover in case one of the connection in
the pool goes down, and automatic reconnection and flushing of the
information that could not be sent due to the connection status.
</para>
<para>
It is usually not necessary to access this API directly, however if
you are looking at how to read events from a pool of connection, you're most
probably looking for the <link linkend="prelude-connection-pool-check-event"><function>prelude_connection_pool_check_event()</function></link> function.
</para>
<para>
If this is the case, use <link linkend="prelude-connection-pool-check-event"><function>prelude_connection_pool_check_event()</function></link> for polling the
pool or <link linkend="prelude-connection-set-event-handler"><function>prelude_connection_set_event_handler()</function></link> / <link linkend="prelude-connection-set-global-event-handler"><function>prelude_connection_set_global_event_handler()</function></link>
if you want asynchronous notification of event.
</para>
<para>
Note that <link linkend="prelude-connection-set-event-handler"><function>prelude_connection_set_event_handler()</function></link> and <link linkend="prelude-connection-set-global-event-handler"><function>prelude_connection_set_global_event_handler()</function></link>
are only asynchronous if timer are running in asynchronous mode. Otherwise, the callback for theses
function might be called when you call the <link linkend="prelude-timer-wake-up"><function>prelude_timer_wake_up()</function></link> function.
</para>
<para>
In the provided callback, you might use <link linkend="prelude-connection-recv"><function>prelude_connection_recv()</function></link> to retrieve an event of type
<link linkend="PRELUDE-CONNECTION-POOL-EVENT-INPUT:CAPS"><type>PRELUDE_CONNECTION_POOL_EVENT_INPUT</type></link>. And, you could, for example, if the retrieved message has
the <link linkend="PRELUDE-MSG-ID-IDMEF:CAPS"><type>PRELUDE_MSG_ID_IDMEF</type></link> tag, provide the returned <link linkend="prelude-msg-t"><type>prelude_msg_t</type></link> object to <link linkend="idmef-message-read"><function>idmef_message_read()</function></link>
in order to convert the received message to a <link linkend="idmef-message-t"><type>idmef_message_t</type></link> object.
</para>
</refsect1>
<refsect1 id="details">
<title id="details.title">Details</title>
<refsect2>
<title><anchor id="prelude-connection-pool-flags-t" role="enum"/>enum prelude_connection_pool_flags_t</title>
<indexterm><primary>prelude_connection_pool_flags_t</primary></indexterm><programlisting>typedef enum {
PRELUDE_CONNECTION_POOL_FLAGS_RECONNECT = 0x01,
PRELUDE_CONNECTION_POOL_FLAGS_FAILOVER = 0x02
} prelude_connection_pool_flags_t;
</programlisting>
<para>
</para></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-event-t" role="enum"/>enum prelude_connection_pool_event_t</title>
<indexterm><primary>prelude_connection_pool_event_t</primary></indexterm><programlisting>typedef enum {
PRELUDE_CONNECTION_POOL_EVENT_INPUT = 0x01,
PRELUDE_CONNECTION_POOL_EVENT_DEAD = 0x02,
PRELUDE_CONNECTION_POOL_EVENT_ALIVE = 0x04
} prelude_connection_pool_event_t;
</programlisting>
<para>
</para></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-t" role="typedef"/>prelude_connection_pool_t</title>
<indexterm><primary>prelude_connection_pool_t</primary></indexterm><programlisting>typedef struct prelude_connection_pool prelude_connection_pool_t;
</programlisting>
<para>
</para></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-broadcast" role="function"/>prelude_connection_pool_broadcast ()</title>
<indexterm><primary>prelude_connection_pool_broadcast</primary></indexterm><programlisting><link linkend="void">void</link> prelude_connection_pool_broadcast
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-msg-t">prelude_msg_t</link> *msg);</programlisting>
<para>
Sends the message contained in <parameter>msg</parameter> to all the connection in <parameter>pool</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>msg</parameter> :</term>
<listitem><simpara> Pointer on a <link linkend="prelude-msg-t"><type>prelude_msg_t</type></link> object.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-broadcast-async" role="function"/>prelude_connection_pool_broadcast_async ()</title>
<indexterm><primary>prelude_connection_pool_broadcast_async</primary></indexterm><programlisting><link linkend="void">void</link> prelude_connection_pool_broadcast_async
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-msg-t">prelude_msg_t</link> *msg);</programlisting>
<para>
Sends the message contained in <parameter>msg</parameter> to all connections
in <parameter>pool</parameter> asynchronously. After the request is processed,
the <parameter>msg</parameter> message will be freed.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>msg</parameter> :</term>
<listitem><simpara> Pointer on a <link linkend="prelude-msg-t"><type>prelude_msg_t</type></link> object.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-init" role="function"/>prelude_connection_pool_init ()</title>
<indexterm><primary>prelude_connection_pool_init</primary></indexterm><programlisting><link linkend="int">int</link> prelude_connection_pool_init (<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);</programlisting>
<para>
Initializes <parameter>pool</parameter>. This means that connection associated
with <parameter>pool</parameter> using <link linkend="prelude-connection-pool-set-connection-string"><function>prelude_connection_pool_set_connection_string()</function></link>
will be established.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> 0 on success, a negative value on error.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-new" role="function"/>prelude_connection_pool_new ()</title>
<indexterm><primary>prelude_connection_pool_new</primary></indexterm><programlisting><link linkend="int">int</link> prelude_connection_pool_new (<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> **ret,
<link linkend="prelude-client-profile-t">prelude_client_profile_t</link> *cp,
<link linkend="prelude-connection-permission-t">prelude_connection_permission_t</link> permission);</programlisting>
<para>
<link linkend="prelude-connection-pool-new"><function>prelude_connection_pool_new()</function></link> initializes a new Connection Manager object.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>ret</parameter> :</term>
<listitem><simpara> Pointer to an address where to store the created <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cp</parameter> :</term>
<listitem><simpara> The <link linkend="prelude-client-profile-t"><type>prelude_client_profile_t</type></link> to use for connection.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>permission</parameter> :</term>
<listitem><simpara> Permission the connection in this connection-pool will require.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> 0 on success or a negative value if an error occured.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-get-connection-list" role="function"/>prelude_connection_pool_get_connection_list ()</title>
<indexterm><primary>prelude_connection_pool_get_connection_list</primary></indexterm><programlisting><link linkend="prelude-list-t">prelude_list_t</link>* prelude_connection_pool_get_connection_list
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);</programlisting>
<para>
</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> The list of connections handled by <parameter>pool</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-add-connection" role="function"/>prelude_connection_pool_add_connection ()</title>
<indexterm><primary>prelude_connection_pool_add_connection</primary></indexterm><programlisting><link linkend="int">int</link> prelude_connection_pool_add_connection
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-t">prelude_connection_t</link> *cnx);</programlisting>
<para>
Adds <parameter>cnx</parameter> to <parameter>pool</parameter> set of connections.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cnx</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-t"><type>prelude_connection_t</type></link> object to add to <parameter>pool</parameter>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> 0 on success, a negative value if an error occured.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-set-connection-dead" role="function"/>prelude_connection_pool_set_connection_dead ()</title>
<indexterm><primary>prelude_connection_pool_set_connection_dead</primary></indexterm><programlisting><link linkend="int">int</link> prelude_connection_pool_set_connection_dead
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-t">prelude_connection_t</link> *cnx);</programlisting>
<para>
Notifies <parameter>pool</parameter> that the connection identified by <parameter>cnx</parameter> is dead.
</para>
<para>
Usually, this function should not be used since <parameter>pool</parameter> is
self sufficient, and handles connections issues internally. However,
it is sometime useful when the user has several mechanisms using the
connection, and that its own mechanism detects a connection problem
before <parameter>pool</parameter> notice.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cnx</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-t"><type>prelude_connection_t</type></link> object used within <parameter>pool</parameter>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> 0 on success, a negative value if an error occured.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-set-connection-alive" role="function"/>prelude_connection_pool_set_connection_alive ()</title>
<indexterm><primary>prelude_connection_pool_set_connection_alive</primary></indexterm><programlisting><link linkend="int">int</link> prelude_connection_pool_set_connection_alive
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-t">prelude_connection_t</link> *cnx);</programlisting>
<para>
Notifies <parameter>pool</parameter> that the connection identified by <parameter>cnx</parameter> went back alive.
</para>
<para>
Usually, this function should not be used since <parameter>pool</parameter> is
self sufficient, and handles connection issues internally. However,
it is sometime useful when the user has several mechanisms using the
connection, and that its own mechanism detects a connection problem
before <parameter>pool</parameter> notice.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cnx</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-t"><type>prelude_connection_t</type></link> object used within <parameter>pool</parameter>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> 0 on success, a negative value if an error occured.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-set-connection-string" role="function"/>prelude_connection_pool_set_connection_string ()</title>
<indexterm><primary>prelude_connection_pool_set_connection_string</primary></indexterm><programlisting><link linkend="int">int</link> prelude_connection_pool_set_connection_string
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
const <link linkend="char">char</link> *cfgstr);</programlisting>
<para>
Sets the connection string for <parameter>pool</parameter>. The connection string should be
in the form of : "address". Special operand like || (OR) and && (AND),
are also accepted: "address && address".
</para>
<para>
Where && means that alert sent using <parameter>pool</parameter> will go to both configured
addresses, and || means that if the left address fails, the right address
will be used.
</para>
<para>
<link linkend="prelude-connection-pool-init"><function>prelude_connection_pool_init()</function></link> should be used to initiates the connection.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cfgstr</parameter> :</term>
<listitem><simpara> Connection string.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> 0 on success, a negative value if an error occured.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-get-connection-string" role="function"/>prelude_connection_pool_get_connection_string ()</title>
<indexterm><primary>prelude_connection_pool_get_connection_string</primary></indexterm><programlisting>const <link linkend="char">char</link>* prelude_connection_pool_get_connection_string
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);</programlisting>
<para>
Used to query the connection string used by <parameter>pool</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> The connection string.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-destroy" role="function"/>prelude_connection_pool_destroy ()</title>
<indexterm><primary>prelude_connection_pool_destroy</primary></indexterm><programlisting><link linkend="void">void</link> prelude_connection_pool_destroy (<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);</programlisting>
<para>
Destroys <parameter>pool</parameter> and all connections handled.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-get-flags" role="function"/>prelude_connection_pool_get_flags ()</title>
<indexterm><primary>prelude_connection_pool_get_flags</primary></indexterm><programlisting><link linkend="prelude-connection-pool-flags-t">prelude_connection_pool_flags_t</link> prelude_connection_pool_get_flags
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);</programlisting>
<para>
</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> the <link linkend="prelude-connection-pool-flags-t"><type>prelude_connection_pool_flags_t</type></link> used in <parameter>pool</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-set-flags" role="function"/>prelude_connection_pool_set_flags ()</title>
<indexterm><primary>prelude_connection_pool_set_flags</primary></indexterm><programlisting><link linkend="void">void</link> prelude_connection_pool_set_flags
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-pool-flags-t">prelude_connection_pool_flags_t</link> flags);</programlisting>
<para>
Sets <parameter>flags</parameter> within <parameter>pools</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>flags</parameter> :</term>
<listitem><simpara> Flags to use for <parameter>pool</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-set-required-permission" role="function"/>prelude_connection_pool_set_required_permission ()</title>
<indexterm><primary>prelude_connection_pool_set_required_permission</primary></indexterm><programlisting><link linkend="void">void</link> prelude_connection_pool_set_required_permission
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-permission-t">prelude_connection_permission_t</link> req_perm);</programlisting>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>req_perm</parameter> :</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-set-data" role="function"/>prelude_connection_pool_set_data ()</title>
<indexterm><primary>prelude_connection_pool_set_data</primary></indexterm><programlisting><link linkend="void">void</link> prelude_connection_pool_set_data
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="void">void</link> *data);</programlisting>
<para>
The user might use this function to associate data with <parameter>pool</parameter>.
The data associated might be retrieved using <link linkend="prelude-connection-pool-get-data"><function>prelude_connection_pool_get_data()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter> :</term>
<listitem><simpara> Pointer to user specific data.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-get-data" role="function"/>prelude_connection_pool_get_data ()</title>
<indexterm><primary>prelude_connection_pool_get_data</primary></indexterm><programlisting><link linkend="void">void</link>* prelude_connection_pool_get_data
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool);</programlisting>
<para>
The user might use this function to query data associated with
<parameter>pool</parameter> using <link linkend="prelude-connection-pool-set-data"><function>prelude_connection_pool_set_data()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> the user data associated to <parameter>pool</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-check-event" role="function"/>prelude_connection_pool_check_event ()</title>
<indexterm><primary>prelude_connection_pool_check_event</primary></indexterm><programlisting><link linkend="int">int</link> prelude_connection_pool_check_event
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="int">int</link> timeout,
<link linkend="int">int</link> (*event_cb) (prelude_connection_pool_t *pool,prelude_connection_pool_event_t event,prelude_connection_t *cnx, void *extra),
<link linkend="void">void</link> *extra);</programlisting>
<para>
This function queries the set of connections available in <parameter>pool</parameter> to see if
events are waiting to be handled. If timeout is zero, then this function
will return immediatly in case there is no event to be handled.
</para>
<para>
If timeout is -1, this function won't return until an event is available.
Otherwise this function will return if there is no event after the specified
number of second.
</para>
<para>
For each event, <parameter>event_cb</parameter> is called with the concerned <parameter>pool</parameter>, the provided
<parameter>extra</parameter> data, and the <parameter>cnx</parameter> where an event has occured.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>timeout</parameter> :</term>
<listitem><simpara> Time to wait for an event.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>event_cb</parameter> :</term>
<listitem><simpara> User provided callback function to call on received events.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>extra</parameter> :</term>
<listitem><simpara> Pointer to user specific data provided to <parameter>event_cb</parameter>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> The number of handled events, or a negative value if an error occured.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-recv" role="function"/>prelude_connection_pool_recv ()</title>
<indexterm><primary>prelude_connection_pool_recv</primary></indexterm><programlisting><link linkend="int">int</link> prelude_connection_pool_recv (<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="int">int</link> timeout,
<link linkend="prelude-connection-t">prelude_connection_t</link> **outconn,
<link linkend="prelude-msg-t">prelude_msg_t</link> **outmsg);</programlisting>
<para>
This function queries the set of connections available in <parameter>pool</parameter> to see if
events are waiting to be handled. If timeout is zero, then this function
will return immediatly in case there is no event to be handled.
</para>
<para>
If timeout is -1, this function won't return until an event is available.
Otherwise this function will return if there is no event after the specified
number of second.
</para>
<para>
If an event is available, it will be read and store the <link linkend="prelude-connection-t"><type>prelude_connection_t</type></link>
object in the <parameter>outconn</parameter> pointer. If <parameter>outmsg</parameter> was specified, the message will be
read and stored in there.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>timeout</parameter> :</term>
<listitem><simpara> Time to wait for an event.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>outconn</parameter> :</term>
<listitem><simpara> Pointer where the connection where an event happened should be stored.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>outmsg</parameter> :</term>
<listitem><simpara> Pointer where the next message that will be read should be stored.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> The number of handled events (0 or 1) or a negative value if an error occured.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-set-global-event-handler" role="function"/>prelude_connection_pool_set_global_event_handler ()</title>
<indexterm><primary>prelude_connection_pool_set_global_event_handler</primary></indexterm><programlisting><link linkend="void">void</link> prelude_connection_pool_set_global_event_handler
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-pool-event-t">prelude_connection_pool_event_t</link> wanted_events,
<link linkend="int">int</link> (*callback) (prelude_connection_pool_t *pool,prelude_connection_pool_event_t events));</programlisting>
<para>
<parameter>callback</parameter> will be called each time one of the event specified in
<parameter>wanted_events</parameter> happen to <parameter>pool</parameter>. However, contrary to
<link linkend="prelude-connection-pool-set-event-handler"><function>prelude_connection_pool_set_event_handler()</function></link>, the callback will be called
only once per set of event.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>wanted_events</parameter> :</term>
<listitem><simpara> Event the user want to be notified about.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>callback</parameter> :</term>
<listitem><simpara> User specific callback to call when an event is available.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="prelude-connection-pool-set-event-handler" role="function"/>prelude_connection_pool_set_event_handler ()</title>
<indexterm><primary>prelude_connection_pool_set_event_handler</primary></indexterm><programlisting><link linkend="void">void</link> prelude_connection_pool_set_event_handler
(<link linkend="prelude-connection-pool-t">prelude_connection_pool_t</link> *pool,
<link linkend="prelude-connection-pool-event-t">prelude_connection_pool_event_t</link> wanted_events,
<link linkend="int">int</link> (*callback) (prelude_connection_pool_t *pool,prelude_connection_pool_event_t events,prelude_connection_t *cnx));</programlisting>
<para>
<parameter>callback</parameter> will be called each time one of the event specified in
<parameter>wanted_events</parameter> happens to <parameter>pool</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pool</parameter> :</term>
<listitem><simpara> Pointer to a <link linkend="prelude-connection-pool-t"><type>prelude_connection_pool_t</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>wanted_events</parameter> :</term>
<listitem><simpara> Event the user want to be notified about.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>callback</parameter> :</term>
<listitem><simpara> User specific callback to call when an event is available.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<link linkend="prelude-connection-t"><type>prelude_connection_t</type></link>
<link linkend="idmef-message-read"><function>idmef_message_read()</function></link>
</para>
</refsect1>
</refentry>
|