Skip to content

Instantly share code, notes, and snippets.

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 tomas-quix/3a02056246f7057d4e613e878770f9db to your computer and use it in GitHub Desktop.
Save tomas-quix/3a02056246f7057d4e613e878770f9db to your computer and use it in GitHub Desktop.
OS announcement blog
topic_producer = client.get_topic_producer("data")
stream = topic_producer.create_stream("bus-123AAAV")
# Message 1 sent (the stream context)
stream.properties.name = "BUS 123 AAAV"
# Message 2 sent (the human-readable identifier the bus)
stream.timeseries \
.buffer \
.add_timestamp(datetime.datetime.utcnow()) \
.add_value("Lat", math.sin(index / 100.0) + math.sin(index) / 5.0) \
.add_value("Long", math.sin(index / 200.0) + math.sin(index) / 5.0) \
.publish()
# Message 3 sent (the time-series telemetry data from the bus)
stream.events \
.add_timestamp_in_nanoseconds(time.time_ns()) \
.add_value("driver_bell", "Doors 3 bell activated by passenger") \
.publish()
# Message 4 sent (an event related to something that happened on the bus)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment