-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config param to pass additional parameters to confluent-kafka-pyt…
…hon (#1505) * Add config param to pass additional parameters to confluent-kafka-python * Raise error if ssl_context is passed * Add ConfluentConfig typed dict * Add docs for passing config * Fix mypy failure * Remove unused parameters * Bump version
- Loading branch information
1 parent
c20629c
commit df2a0a1
Showing
37 changed files
with
562 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
dependant | ||
unsecure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/BrokerAddressFamily.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.BrokerAddressFamily |
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/BuiltinFeatures.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.BuiltinFeatures |
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/ClientDNSLookup.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.ClientDNSLookup |
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/CompressionCodec.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.CompressionCodec |
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/CompressionType.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.CompressionType |
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/ConfluentConfig.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.ConfluentConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.Debug |
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/GroupProtocol.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.GroupProtocol |
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/IsolationLevel.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.IsolationLevel |
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/OffsetStoreMethod.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.OffsetStoreMethod |
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/SASLOAUTHBearerMethod.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.SASLOAUTHBearerMethod |
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/confluent/config/SecurityProtocol.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.confluent.config.SecurityProtocol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 10 | ||
--- | ||
|
||
# Passing Additional Configuration to confluent-kafka-python | ||
|
||
The `confluent-kafka-python` package is a Python wrapper around [librdkakfa](https://github.com/confluentinc/librdkafka), which is a C/C++ client library for Apache Kafka. | ||
|
||
`confluent-kafka-python` accepts a `config` dictionary that is then passed on to `librdkafka`. `librdkafka` provides plenty of [configuration properties](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md) to configure the Kafka client. | ||
|
||
**FastStream** also provides users with the ability to pass the config dictionary to `librdkafka` to provide greater customizability. | ||
|
||
## Example | ||
|
||
In the following example, we are setting the parameter `topic.metadata.refresh.fast.interval.ms`'s value to `300` instead of the default value `100` via the `config` parameter. | ||
|
||
```python linenums="1" hl_lines="15 16" | ||
{! docs_src/confluent/additional_config/app.py !} | ||
``` | ||
|
||
Similarly, you could use the `config` parameter to pass any [configuration properties](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md) to `librdkafka`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
from faststream import FastStream, Logger | ||
from faststream.confluent import KafkaBroker | ||
|
||
|
||
class HelloWorld(BaseModel): | ||
msg: str = Field( | ||
..., | ||
examples=["Hello"], | ||
description="Demo hello world message", | ||
) | ||
|
||
|
||
config = {"topic.metadata.refresh.fast.interval.ms": 300} | ||
broker = KafkaBroker("localhost:9092", config=config) | ||
app = FastStream(broker) | ||
|
||
|
||
@broker.subscriber("hello_world") | ||
async def on_hello_world(msg: HelloWorld, logger: Logger): | ||
logger.info(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
import ssl | ||
|
||
from faststream.confluent import KafkaBroker | ||
from faststream.security import BaseSecurity | ||
|
||
ssl_context = ssl.create_default_context() | ||
security = BaseSecurity(ssl_context=ssl_context) | ||
security = BaseSecurity(use_ssl=True) | ||
|
||
broker = KafkaBroker("localhost:9092", security=security) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import ssl | ||
|
||
from faststream.confluent import KafkaBroker | ||
from faststream.security import SASLPlaintext | ||
|
||
ssl_context = ssl.create_default_context() | ||
security = SASLPlaintext( | ||
ssl_context=ssl_context, | ||
username="admin", | ||
password="password", # pragma: allowlist secret | ||
use_ssl=True, | ||
) | ||
|
||
broker = KafkaBroker("localhost:9092", security=security) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import ssl | ||
|
||
from faststream.confluent import KafkaBroker | ||
from faststream.security import SASLScram256 | ||
|
||
ssl_context = ssl.create_default_context() | ||
security = SASLScram256( | ||
ssl_context=ssl_context, | ||
username="admin", | ||
password="password", # pragma: allowlist secret | ||
use_ssl=True, | ||
) | ||
|
||
broker = KafkaBroker("localhost:9092", security=security) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import ssl | ||
|
||
from faststream.confluent import KafkaBroker | ||
from faststream.security import SASLScram512 | ||
|
||
ssl_context = ssl.create_default_context() | ||
security = SASLScram512( | ||
ssl_context=ssl_context, | ||
username="admin", | ||
password="password", # pragma: allowlist secret | ||
use_ssl=True, | ||
) | ||
|
||
broker = KafkaBroker("localhost:9092", security=security) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.