Skip to content

Instantly share code, notes, and snippets.

@billydh
Last active April 28, 2020 04:15
Show Gist options
  • Select an option

  • Save billydh/1780d24e2bdd0833b462685d54e2c126 to your computer and use it in GitHub Desktop.

Select an option

Save billydh/1780d24e2bdd0833b462685d54e2c126 to your computer and use it in GitHub Desktop.
A util function to parse command line arguments for AvroProducer
from argparse import ArgumentParser
def parse_command_line_args():
arg_parser = ArgumentParser()
arg_parser.add_argument("--topic", required=True, help="Topic name")
arg_parser.add_argument("--bootstrap-servers", required=False, default="localhost:9092", help="Bootstrap server address")
arg_parser.add_argument("--schema-registry", required=False, default="http://localhost:8081", help="Schema Registry url")
arg_parser.add_argument("--schema-file", required=True, help="File name of Avro schema to use")
arg_parser.add_argument("--record-key", required=False, type=str, help="Record key. If not provided, will be a random UUID")
arg_parser.add_argument("--record-value", required=True, help="Record value")
return arg_parser.parse_args()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment