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

Kafka cluster setup #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,38 @@ If you're using AWS Kinesis instead of Kafka, it will look like this:
# 'PRODUCER_ID': 'my-application-name',
}

If you're need to set any other attributes, you cas use "KAFKA_KWARGS"

For example with Confluent Cloud will look like this:

::

LOGPIPE = {
...
# Optional Settings
'KAFKA_KWARGS': {
'security_protocol': 'SASL_SSL',
'sasl_mechanism': 'PLAIN',
'sasl_plain_username': '<api_key>',
'sasl_plain_password': '<api_secret>',
}
}

or with OVHcloud will look like this:

::

LOGPIPE = {
...
# Optional Settings
'KAFKA_KWARGS': {
'security_protocol': 'SSL',
'ssl_cafile': '<ca.pem or ca.certificate.pem>',
'ssl_certfile': '<service.cert or access.certificate.pem>',
'ssl_keyfile': '<service.key or access.key>',
}
}

Run migrations. This will create the model used to store Kafka log position offsets.::

$ python manage.py migrate logpipe
Expand Down
11 changes: 6 additions & 5 deletions src/logpipe/backend/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def _get_client_config(self):
"enable_auto_commit": False,
"consumer_timeout_ms": 1000,
}
kwargs.update(settings.get("KAFKA_KWARGS", {}))
kwargs.update(settings.get("KAFKA_CONSUMER_KWARGS", {}))
kwargs.update(self.client_kwargs)
kwargs.update(
Expand Down Expand Up @@ -145,9 +146,9 @@ def send(self, topic_name, key, value):
)

def _get_client_config(self):
servers = settings.get("KAFKA_BOOTSTRAP_SERVERS")
retries = settings.get("KAFKA_MAX_SEND_RETRIES", 0)
return {
"bootstrap_servers": servers,
"retries": retries,
kwargs = {
"bootstrap_servers": settings.get("KAFKA_BOOTSTRAP_SERVERS"),
"retries": settings.get("KAFKA_MAX_SEND_RETRIES", 0),
}
kwargs.update(settings.get("KAFKA_KWARGS", {}))
return kwargs