Last active
March 2, 2023 09:52
-
-
Save tomas-quix/3a02056246f7057d4e613e878770f9db to your computer and use it in GitHub Desktop.
OS announcement blog
This file contains 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
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