Skip to content

Instantly share code, notes, and snippets.

@merlin-quix
Last active January 23, 2023 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save merlin-quix/639fafd0ba72277bcfb4cabbdcadb664 to your computer and use it in GitHub Desktop.
Save merlin-quix/639fafd0ba72277bcfb4cabbdcadb664 to your computer and use it in GitHub Desktop.
# Add a switch to let us easily switch between methods
compmethod = 'topic'
# Initialize a simple counter for the message key
message_key = 0
# Iterate through file line-by-line
with open(file, "r") as file_handle:
for line in file_handle:
print(f"Sending: {line}")
# Select the relevant compression method based on the switch
if compmethod == 'topic':
producer.send(topic="nginx-log-topic-compression", value=line, key=message_key)
else:
producer_compression.send(topic="nginx-log-producer-compression", value=line, key=message_key)
message_key = message_key+1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment