@@ -1369,79 +1369,12 @@ int Handle_traverse (Handle *h, visitproc visit, void *arg) {
1369
1369
return 0 ;
1370
1370
}
1371
1371
1372
-
1373
-
1374
- /**
1375
- * Populate topic conf from provided dict.
1376
- *
1377
- * Will raise an exception on error and return -1, or returns 0 on success.
1378
- */
1379
- static int populate_topic_conf (rd_kafka_topic_conf_t * tconf , const char * what ,
1380
- PyObject * dict ) {
1381
- Py_ssize_t pos = 0 ;
1382
- PyObject * ko , * vo ;
1383
-
1384
- if (!PyDict_Check (dict )) {
1385
- cfl_PyErr_Format (RD_KAFKA_RESP_ERR__INVALID_ARG ,
1386
- "%s: requires a dict" , what );
1387
- return -1 ;
1388
- }
1389
-
1390
- while (PyDict_Next (dict , & pos , & ko , & vo )) {
1391
- PyObject * ks , * ks8 ;
1392
- PyObject * vs , * vs8 ;
1393
- const char * k ;
1394
- const char * v ;
1395
- char errstr [256 ];
1396
-
1397
- if (!(ks = cfl_PyObject_Unistr (ko ))) {
1398
- PyErr_SetString (PyExc_TypeError ,
1399
- "expected configuration property "
1400
- "value as type unicode string" );
1401
- return -1 ;
1402
- }
1403
-
1404
- if (!(vs = cfl_PyObject_Unistr (vo ))) {
1405
- PyErr_SetString (PyExc_TypeError ,
1406
- "expected configuration property "
1407
- "value as type unicode string" );
1408
- Py_DECREF (ks );
1409
- return -1 ;
1410
- }
1411
-
1412
- k = cfl_PyUnistr_AsUTF8 (ks , & ks8 );
1413
- v = cfl_PyUnistr_AsUTF8 (vs , & vs8 );
1414
-
1415
- if (rd_kafka_topic_conf_set (tconf , k , v ,
1416
- errstr , sizeof (errstr )) !=
1417
- RD_KAFKA_CONF_OK ) {
1418
- cfl_PyErr_Format (RD_KAFKA_RESP_ERR__INVALID_ARG ,
1419
- "%s: %s" , what , errstr );
1420
- Py_XDECREF (ks8 );
1421
- Py_XDECREF (vs8 );
1422
- Py_DECREF (ks );
1423
- Py_DECREF (vs );
1424
- return -1 ;
1425
- }
1426
-
1427
- Py_XDECREF (ks8 );
1428
- Py_XDECREF (vs8 );
1429
- Py_DECREF (ks );
1430
- Py_DECREF (vs );
1431
- }
1432
-
1433
- return 0 ;
1434
- }
1435
-
1436
-
1437
-
1438
1372
/**
1439
1373
* @brief Set single special producer config value.
1440
1374
*
1441
1375
* @returns 1 if handled, 0 if unknown, or -1 on failure (exception raised).
1442
1376
*/
1443
1377
static int producer_conf_set_special (Handle * self , rd_kafka_conf_t * conf ,
1444
- rd_kafka_topic_conf_t * tconf ,
1445
1378
const char * name , PyObject * valobj ) {
1446
1379
1447
1380
if (!strcmp (name , "on_delivery" )) {
@@ -1483,7 +1416,6 @@ static int producer_conf_set_special (Handle *self, rd_kafka_conf_t *conf,
1483
1416
* @returns 1 if handled, 0 if unknown, or -1 on failure (exception raised).
1484
1417
*/
1485
1418
static int consumer_conf_set_special (Handle * self , rd_kafka_conf_t * conf ,
1486
- rd_kafka_topic_conf_t * tconf ,
1487
1419
const char * name , PyObject * valobj ) {
1488
1420
1489
1421
if (!strcmp (name , "on_commit" )) {
@@ -1516,7 +1448,6 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1516
1448
PyObject * args ,
1517
1449
PyObject * kwargs ) {
1518
1450
rd_kafka_conf_t * conf ;
1519
- rd_kafka_topic_conf_t * tconf ;
1520
1451
Py_ssize_t pos = 0 ;
1521
1452
PyObject * ko , * vo ;
1522
1453
PyObject * confdict = NULL ;
@@ -1569,14 +1500,13 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1569
1500
}
1570
1501
1571
1502
conf = rd_kafka_conf_new ();
1572
- tconf = rd_kafka_topic_conf_new ();
1573
1503
1574
1504
/*
1575
1505
* Default config (overridable by user)
1576
1506
*/
1577
1507
1578
1508
/* Enable valid offsets in delivery reports */
1579
- rd_kafka_topic_conf_set ( tconf , "produce.offset.report" , "true" , NULL , 0 );
1509
+ rd_kafka_conf_set ( conf , "produce.offset.report" , "true" , NULL , 0 );
1580
1510
1581
1511
/*
1582
1512
* Plugins must be configured prior to handling any of their configuration properties.
@@ -1592,7 +1522,6 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1592
1522
PyErr_SetString (PyExc_TypeError ,
1593
1523
"expected configuration property name "
1594
1524
"as type unicode string" );
1595
- rd_kafka_topic_conf_destroy (tconf );
1596
1525
rd_kafka_conf_destroy (conf );
1597
1526
Py_DECREF (confdict );
1598
1527
@@ -1606,7 +1535,6 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1606
1535
cfl_PyErr_Format (RD_KAFKA_RESP_ERR__INVALID_ARG ,
1607
1536
"%s" , errstr );
1608
1537
1609
- rd_kafka_topic_conf_destroy (tconf );
1610
1538
rd_kafka_conf_destroy (conf );
1611
1539
Py_DECREF (confdict );
1612
1540
@@ -1622,6 +1550,20 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1622
1550
PyDict_DelItemString (confdict , "plugin.library.paths" );
1623
1551
}
1624
1552
1553
+ if ((vo = PyDict_GetItemString (confdict , "default.topic.config" ))) {
1554
+ /* TODO: uncomment for 1.0 release
1555
+ PyErr_Warn(PyExc_DeprecationWarning,
1556
+ "default.topic.config has being deprecated, "
1557
+ "set default topic configuration values in the global dict");
1558
+ */
1559
+ if (PyDict_Update (confdict , vo ) == -1 ) {
1560
+ rd_kafka_conf_destroy (conf );
1561
+ Py_DECREF (confdict );
1562
+ return NULL ;
1563
+ }
1564
+ PyDict_DelItemString (confdict , "default.topic.config" );
1565
+ }
1566
+
1625
1567
/* Convert config dict to config key-value pairs. */
1626
1568
while (PyDict_Next (confdict , & pos , & ko , & vo )) {
1627
1569
PyObject * ks , * ks8 ;
@@ -1632,35 +1574,21 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1632
1574
int r = 0 ;
1633
1575
1634
1576
if (!(ks = cfl_PyObject_Unistr (ko ))) {
1635
- PyErr_SetString (PyExc_TypeError ,
1636
- "expected configuration property name "
1637
- "as type unicode string" );
1638
- rd_kafka_topic_conf_destroy (tconf );
1577
+ PyErr_SetString (PyExc_TypeError ,
1578
+ "expected configuration property name "
1579
+ "as type unicode string" );
1639
1580
rd_kafka_conf_destroy (conf );
1640
1581
Py_DECREF (confdict );
1641
1582
1642
1583
return NULL ;
1643
1584
}
1644
1585
1645
1586
k = cfl_PyUnistr_AsUTF8 (ks , & ks8 );
1646
- if (!strcmp (k , "default.topic.config" )) {
1647
- if (populate_topic_conf (tconf , k , vo ) == -1 ) {
1648
- Py_DECREF (ks );
1649
- rd_kafka_topic_conf_destroy (tconf );
1650
- rd_kafka_conf_destroy (conf );
1651
- Py_DECREF (confdict );
1652
- return NULL ;
1653
- }
1654
- Py_XDECREF (ks8 );
1655
- Py_DECREF (ks );
1656
- continue ;
1657
-
1658
- } else if (!strcmp (k , "error_cb" )) {
1587
+ if (!strcmp (k , "error_cb" )) {
1659
1588
if (!PyCallable_Check (vo )) {
1660
1589
PyErr_SetString (PyExc_TypeError ,
1661
1590
"expected error_cb property "
1662
1591
"as a callable function" );
1663
- rd_kafka_topic_conf_destroy (tconf );
1664
1592
rd_kafka_conf_destroy (conf );
1665
1593
Py_DECREF (confdict );
1666
1594
@@ -1685,7 +1613,6 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1685
1613
PyErr_SetString (PyExc_ValueError ,
1686
1614
"expected throttle_cb property "
1687
1615
"as a callable function" );
1688
- rd_kafka_topic_conf_destroy (tconf );
1689
1616
rd_kafka_conf_destroy (conf );
1690
1617
Py_DECREF (confdict );
1691
1618
@@ -1710,7 +1637,6 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1710
1637
PyErr_SetString (PyExc_TypeError ,
1711
1638
"expected stats_cb property "
1712
1639
"as a callable function" );
1713
- rd_kafka_topic_conf_destroy (tconf );
1714
1640
rd_kafka_conf_destroy (conf );
1715
1641
Py_DECREF (confdict );
1716
1642
@@ -1748,14 +1674,13 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1748
1674
1749
1675
/* Special handling for certain config keys. */
1750
1676
if (ktype == RD_KAFKA_PRODUCER )
1751
- r = producer_conf_set_special (h , conf , tconf , k , vo );
1677
+ r = producer_conf_set_special (h , conf , k , vo );
1752
1678
else if (ktype == RD_KAFKA_CONSUMER )
1753
- r = consumer_conf_set_special (h , conf , tconf , k , vo );
1679
+ r = consumer_conf_set_special (h , conf , k , vo );
1754
1680
if (r == -1 ) {
1755
1681
/* Error */
1756
1682
Py_XDECREF (ks8 );
1757
1683
Py_DECREF (ks );
1758
- rd_kafka_topic_conf_destroy (tconf );
1759
1684
rd_kafka_conf_destroy (conf );
1760
1685
Py_DECREF (confdict );
1761
1686
@@ -1778,7 +1703,6 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1778
1703
"expected configuration "
1779
1704
"property value as type "
1780
1705
"unicode string" );
1781
- rd_kafka_topic_conf_destroy (tconf );
1782
1706
rd_kafka_conf_destroy (conf );
1783
1707
Py_DECREF (confdict );
1784
1708
@@ -1794,7 +1718,6 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1794
1718
RD_KAFKA_CONF_OK ) {
1795
1719
cfl_PyErr_Format (RD_KAFKA_RESP_ERR__INVALID_ARG ,
1796
1720
"%s" , errstr );
1797
- rd_kafka_topic_conf_destroy (tconf );
1798
1721
rd_kafka_conf_destroy (conf );
1799
1722
Py_DECREF (confdict );
1800
1723
@@ -1830,9 +1753,6 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1830
1753
rd_kafka_conf_set_log_cb (conf , log_cb );
1831
1754
}
1832
1755
1833
- rd_kafka_topic_conf_set_opaque (tconf , h );
1834
- rd_kafka_conf_set_default_topic_conf (conf , tconf );
1835
-
1836
1756
rd_kafka_conf_set_opaque (conf , h );
1837
1757
1838
1758
#ifdef WITH_PY_TSS
0 commit comments