Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate default.topic.configuration #446

Merged
merged 8 commits into from Sep 24, 2018
Merged

Conversation

rnpridgeon
Copy link
Contributor

No description provided.

Copy link
Contributor

@edenhill edenhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

some comments.
might want to fix the CI failures in this same PR too

@@ -1613,6 +1541,21 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
PyDict_DelItemString(confdict, "plugin.library.paths");
}

if ((vo = PyDict_GetItemString(confdict, "default.topic.config"))) {
PyErr_Warn(PyExc_DeprecationWarning,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out this warning until we hit 1.0


if ((PyDict_Update(confdict, vo) == -1)) {
PyErr_SetString(PyExc_TypeError,
"unable to process default.topic.config");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process is vague, and you shouldn't raise an exception here since PyDict_Update() already did, see the py docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, read the docs(thats how I found PyDict_Update), but failed to consider the fact that it will raise the exception for me

"default.topic.config has being deprecated, "
"set default topic configuration values in the global dict");

if ((PyDict_Update(confdict, vo) == -1)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip outer parens

timeout = time.time() + 5000
while not seen_delivery_cb:
if time.time() > timeout:
if os.environ.get("on_ci") == 'CI':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The environment name is "CI", so:
if "CI" in os.environ:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

seen_delivery_cb = True
assert err.code() == confluent_kafka.KafkaError._MSG_TIMED_OUT

p = confluent_kafka.Producer({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add all three test-cases we discussed:

  • {"message.timeout.ms":60000, "default.topic.config": {"message.timeout.ms":1000}} -> should take ~1s
  • {"message.timeout.ms":1000} -> should take ~1s
  • {"default.topic.config": {"message.timeout.ms":1000}} -> should take ~1s

@rnpridgeon
Copy link
Contributor Author

CI build shows as failing here, but passing in the travis console since the .travis changes have been made. Either way ready for another review @edenhill


def test_topic_config_update():
confs = [{"message.timeout.ms": 600000, "default.topic.config": {"message.timeout.ms": 1000}},
{"message.timeout.ms": 1000}, {"default.topic.config": {"message.timeout.ms": 1000}}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two should be on separate lines to avoid confusion (I was confused!)

seen_delivery_cb = True
assert err.code() == confluent_kafka.KafkaError._MSG_TIMED_OUT

for conf in confs[:]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the [:] for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to be really explicit about the fact its all the configs not just some.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does the opposite, I'm afraid. Slicing is typically used to get a subset of something.

p.poll(1)

duration = time.time() - start
if 1.02 >= duration <= .98:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is too tight. Since the "other" timeout is a lot higher (1 minute or 5 minutes), I think any value within 10s is okay here, which also makes it solid on CI.

Copy link
Contributor

@edenhill edenhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change all examples, tests and docs to not use default.topic.config, otherwise cut'n'paste people will keep using it.


/*
* Default config (overridable by user)
*/

/* Enable valid offsets in delivery reports */
rd_kafka_topic_conf_set(tconf, "produce.offset.report", "true", NULL, 0);
rd_kafka_conf_set(conf, "produce.offset.report", "true", NULL, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is soon being enabled by default (1.0) :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to wait? I can fix the examples in the meantime

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the default.topic.config fix needs to go in v0.11.6.

@edenhill
Copy link
Contributor

..but we can do that for 1.0

@edenhill
Copy link
Contributor

LGTM!

Copy link
Contributor

@edenhill edenhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments.
Also make sure to execute each of the changed files so that they are py-syntactically correct.

docs/index.rst Outdated
@@ -110,7 +110,7 @@ https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md

The Python bindings also provide some additional configuration properties:

* ``default.topic.config``: value is a dict of client topic-level configuration
* **DEPRECATED** ``default.topic.config``: value is a dict of client topic-level configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to mention that topic configuration now goes on the global config dictionary.

@@ -159,7 +159,7 @@ def verify_producer():
conf = {'bootstrap.servers': bootstrap_servers,
'error_cb': error_cb,
'api.version.request': api_version_request,
'default.topic.config': {'produce.offset.report': True}}
'produce.offset.report': True}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this, it is set to true in common_conf_setup()

@@ -285,7 +285,7 @@ def verify_avro():
conf = {'bootstrap.servers': bootstrap_servers,
'error_cb': error_cb,
'api.version.request': api_version_request,
'default.topic.config': {'produce.offset.report': True}}
'produce.offset.report': True}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dito

README.md Outdated
'default.topic.config': {
'auto.offset.reset': 'smallest'
}
'auto.offset.reset': 'smallest'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change smallest -> earliest to be consistent

docs/index.rst Outdated
@@ -110,7 +110,8 @@ https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md

The Python bindings also provide some additional configuration properties:

* **DEPRECATED** ``default.topic.config``: value is a dict of client topic-level configuration
* **DEPRECATED**: topic configurations should be specified in the global configuration **
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the trailing double splats look wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line now reads as if "topic confiugration (not configruations!) should be specified in the global config .." is DEPRECATED.

I would use something like:
"default.topic.config: value is a dict of client topi-level configuration properties that are applied to all used topics for the instance. DEPRECATED: topic configuration should now be specified in the global top-level configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

Copy link
Contributor

@edenhill edenhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs another two bytes

docs/index.rst Outdated
* **DEPRECATED**: topic configurations should be specified in the global configuration **
``default.topic.config``:value is a dict of client topic-level configuration
properties that are applied to all used topics for the instance.
* ``default.topic.config``:value is a dict of client topic-level configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add space after :

docs/index.rst Outdated
properties that are applied to all used topics for the instance.
* ``default.topic.config``:value is a dict of client topic-level configuration
properties that are applied to all used topics for the instance. **DEPRECATED:**
topic configuration should now be specified in the global top-level configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end sentence with period.

Copy link
Contributor

@edenhill edenhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rnpridgeon rnpridgeon merged commit 34baea6 into master Sep 24, 2018
@rnpridgeon rnpridgeon deleted the deprecation_topic_conf branch September 24, 2018 19:57
RasmusWL added a commit to RasmusWL/confluent-kafka-python that referenced this pull request Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants