Advertisement
mmandrille

Untitled

Dec 10th, 2020 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. def get_cert():
  2.     import json, requests
  3.     r = requests.get('https://certstream.calidog.io/example.json')
  4.     return r.json()
  5.  
  6. def send_message(msg):
  7.     import json
  8.     from kafka import KafkaProducer
  9.     producer = KafkaProducer(
  10.         bootstrap_servers="localhost:9092",
  11.         value_serializer=lambda x: json.dumps(x).encode('utf-8')
  12.     )
  13.     return producer.send('CertStream', msg)
  14.  
  15.  
  16. In [12]: msg = get_cert()
  17. In [13]: rps = send_message(msg)
  18.  
  19. In [14]: dir(rps)
  20. Out[14]:
  21. ['__class__',
  22.  '__delattr__',
  23.  '__dict__',
  24.  '__dir__',
  25.  '__doc__',
  26.  '__eq__',
  27.  '__format__',
  28.  '__ge__',
  29.  '__getattribute__',
  30.  '__gt__',
  31.  '__hash__',
  32.  '__init__',
  33.  '__init_subclass__',
  34.  '__le__',
  35.  '__lt__',
  36.  '__module__',
  37.  '__ne__',
  38.  '__new__',
  39.  '__reduce__',
  40.  '__reduce_ex__',
  41.  '__repr__',
  42.  '__setattr__',
  43.  '__sizeof__',
  44.  '__str__',
  45.  '__subclasshook__',
  46.  '__weakref__',
  47.  '_call_backs',
  48.  '_callbacks',
  49.  '_errbacks',
  50.  '_produce_future',
  51.  '_produce_success',
  52.  'add_both',
  53.  'add_callback',
  54.  'add_errback',
  55.  'args',
  56.  'chain',
  57.  'error_on_callbacks',
  58.  'exception',
  59.  'failed',
  60.  'failure',
  61.  'get',
  62.  'is_done',
  63.  'retriable',
  64.  'succeeded',
  65.  'success',
  66.  'value']
  67.  
  68. In [16]: rps.is_done
  69. Out[16]: True
  70.  
  71. In [18]: rps.succeeded()
  72. Out[18]: True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement