olehborysevych commented on code in PR #29507:
URL: https://github.com/apache/beam/pull/29507#discussion_r1411161588


##########
learning/prompts/code-explaination/02_io_pubsub.md:
##########
@@ -0,0 +1,34 @@
+Prompt:
+What does this code do?
+```python
+pipeline_options = PipelineOptions(pipeline_args)
+
+with beam.Pipeline(options=options) as p:
+    (p | "Read" >> ReadFromPubSub(subscription=input_subscription)
+       | "Process" >> ParDo(ProcessMessage())
+       | "Write" >> WriteToPubSub(topic=output_topic))
+```
+
+Response:
+This code reads messages from a [PubSub](https://cloud.google.com/pubsub) 
subscription `input_subscription` using the `ReadFromPubSub`, processes them 
and writes the resulting collection to a PubSub topic `output_topic` using the 
`WriteToPubSub` transform.
+
+PubSub is currently supported only in streaming pipelines.
+
+Reading messages directly from a topic is also supported. In this case a 
temporary subscription will be created automatically.
+
+`ReadFromPubSub` produces a `PCollection` of `PubsubMessage` objects or a 
`PCollection` of byte sequences. Behavior is controlled by the 
`with_attributes` parameter with byte sequences being the default.

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to