Skip to content

Commit

Permalink
docs: backend docs updated with SSL example (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosschroh authored Jun 18, 2024
1 parent ecbc632 commit 2aa67be
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
./scripts/test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.4.0
uses: codecov/codecov-action@v4.5.0
with:
file: ./coverage.xml
name: kstreams
Expand Down
2 changes: 1 addition & 1 deletion docs/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ with the backend.
options:
show_root_heading: true
docstring_section_style: table
show_bases: false
show_bases: false
31 changes: 29 additions & 2 deletions kstreams/backends/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,38 @@ class Kafka(BaseModel):
It uses pydantic internally.
!!! Example
```python
```python title="Backend with PLAINTEXT"
from kstreams.backends.kafka import Kafka
from kstreams import create_engine, Stream
backend = Kafka(bootstrap_servers=["localhost:8082"])
backend = Kafka(bootstrap_servers=["localhost:9092"])
stream_engine = create_engine(title="my-stream-engine", backend=backend)
```
!!! Example
```python title="Backend with SSL"
import ssl
from kstreams.backends.kafka import Kafka
from kstreams import create_engine, utils, Stream
def get_ssl_context() -> ssl.SSLContext:
# SSL context can also be created from mem:
# https://kpn.github.io/kstreams/utils/#kstreams.utils.create_ssl_context_from_mem
return utils.create_ssl_context(
certdata="path/to/client-certificate",
keydata="path/to/client-private-key",
cadata="path/to/ca-bundle", # Default None
password="password-to-load-certificate-chain" # Default None
)
backend = Kafka(
bootstrap_servers=["localhost:9094"],
security_protocol="SSL",
ssl_context=get_ssl_context(),
)
stream_engine = create_engine(title="my-stream-engine", backend=backend)
```
Expand Down

0 comments on commit 2aa67be

Please sign in to comment.