Last active
April 28, 2020 04:15
-
-
Save billydh/1780d24e2bdd0833b462685d54e2c126 to your computer and use it in GitHub Desktop.
A util function to parse command line arguments for AvroProducer
This file contains hidden or 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
| 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