Added support for grouping notifications from subscriptions. · datamk/python-cx_Oracle@4ec7685 · GitHub
Skip to content

Commit 4ec7685

Browse files
Added support for grouping notifications from subscriptions.
1 parent bab41ac commit 4ec7685

6 files changed

Lines changed: 86 additions & 14 deletions

File tree

doc/src/connection.rst

Lines changed: 18 additions & 7 deletions

doc/src/module.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,39 @@ in database resident connection pooling (DRCP).
781781
need not be new and may have prior session state.
782782

783783

784+
Subscription Grouping Classes
785+
-----------------------------
786+
787+
These constants are extensions to the DB API definition. They are possible
788+
values for the groupingClass parameter of the :meth:`Connection.subscribe()`
789+
method.
790+
791+
.. data:: SUBSCR_GROUPING_CLASS_TIME
792+
793+
This constant is used to specify that events are to be grouped by the
794+
period of time in which they are received.
795+
796+
797+
Subscription Grouping Types
798+
---------------------------
799+
800+
These constants are extensions to the DB API definition. They are possible
801+
values for the groupingType parameter of the :meth:`Connection.subscribe()`
802+
method.
803+
804+
.. data:: SUBSCR_GROUPING_TYPE_SUMMARY
805+
806+
This constant is used to specify that when events are grouped a summary of
807+
the events should be sent instead of the individual events. This is the
808+
default value.
809+
810+
.. data:: SUBSCR_GROUPING_TYPE_LAST
811+
812+
This constant is used to specify that when events are grouped the last
813+
event that makes up the group should be sent instead of the individual
814+
events.
815+
816+
784817
Subscription Namespaces
785818
-----------------------
786819

src/cxoConnection.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,21 +1456,28 @@ static PyObject *cxoConnection_subscribe(cxoConnection *conn, PyObject* args,
14561456
PyObject* keywordArgs)
14571457
{
14581458
static char *keywordList[] = { "namespace", "protocol", "callback",
1459-
"timeout", "operations", "port", "qos", "ipAddress", NULL };
1459+
"timeout", "operations", "port", "qos", "ipAddress",
1460+
"groupingClass", "groupingValue", "groupingType", NULL };
14601461
uint32_t namespace, protocol, port, timeout, operations, qos;
1462+
uint8_t groupingClass, groupingType;
14611463
PyObject *callback, *ipAddress;
1464+
uint32_t groupingValue;
14621465

1463-
timeout = port = qos = 0;
1466+
groupingClass = 0;
14641467
callback = ipAddress = NULL;
1468+
timeout = port = qos = groupingValue = 0;
1469+
groupingType = DPI_SUBSCR_GROUPING_TYPE_SUMMARY;
14651470
namespace = DPI_SUBSCR_NAMESPACE_DBCHANGE;
14661471
protocol = DPI_SUBSCR_PROTO_CALLBACK;
14671472
operations = DPI_OPCODE_ALL_OPS;
1468-
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "|iiOiiiiO",
1473+
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "|iiOiiiiObib",
14691474
keywordList, &namespace, &protocol, &callback, &timeout,
1470-
&operations, &port, &qos, &ipAddress))
1475+
&operations, &port, &qos, &ipAddress, &groupingClass,
1476+
&groupingValue, &groupingType))
14711477
return NULL;
14721478
return (PyObject*) cxoSubscr_new(conn, namespace, protocol, ipAddress,
1473-
port, callback, timeout, operations, qos);
1479+
port, callback, timeout, operations, qos, groupingClass,
1480+
groupingValue, groupingType);
14741481
}
14751482

14761483

src/cxoModule.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,16 @@ static PyObject *cxoModule_initialize(void)
439439
CXO_ADD_INT_CONSTANT("SUBSCR_NAMESPACE_DBCHANGE",
440440
DPI_SUBSCR_NAMESPACE_DBCHANGE)
441441

442+
// add constants for subscription grouping classes
443+
CXO_ADD_INT_CONSTANT("SUBSCR_GROUPING_CLASS_TIME",
444+
DPI_SUBSCR_GROUPING_CLASS_TIME)
445+
446+
// add constants for subscription grouping types
447+
CXO_ADD_INT_CONSTANT("SUBSCR_GROUPING_TYPE_SUMMARY",
448+
DPI_SUBSCR_GROUPING_TYPE_SUMMARY)
449+
CXO_ADD_INT_CONSTANT("SUBSCR_GROUPING_TYPE_LAST",
450+
DPI_SUBSCR_GROUPING_TYPE_LAST)
451+
442452
// add constants for event types
443453
CXO_ADD_INT_CONSTANT("EVENT_NONE", DPI_EVENT_NONE)
444454
CXO_ADD_INT_CONSTANT("EVENT_STARTUP", DPI_EVENT_STARTUP)

src/cxoModule.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ struct cxoSubscr {
364364
uint32_t timeout;
365365
uint32_t operations;
366366
uint32_t qos;
367+
uint8_t groupingClass;
368+
uint32_t groupingValue;
369+
uint8_t groupingType;
367370
uint64_t id;
368371
};
369372

@@ -433,7 +436,8 @@ cxoObjectType *cxoObjectType_newByName(cxoConnection *connection,
433436
cxoSubscr *cxoSubscr_new(cxoConnection *connection, uint32_t namespace,
434437
uint32_t protocol, PyObject *ipAddress, uint32_t port,
435438
PyObject *callback, uint32_t timeout, uint32_t operations,
436-
uint32_t qos);
439+
uint32_t qos, uint8_t groupingClass, uint32_t groupingValue,
440+
uint8_t groupingType);
437441

438442
PyObject *cxoTransform_dateFromTicks(PyObject *args);
439443
int cxoTransform_fromPython(cxoTransformNum transformNum, PyObject *pyValue,

src/cxoSubscr.c

Lines changed: 8 additions & 1 deletion

0 commit comments

Comments
 (0)