Anonymitaet commented on code in PR #17455:
URL: https://github.com/apache/pulsar/pull/17455#discussion_r963321690


##########
site2/docs/client-libraries-go.md:
##########
@@ -442,85 +420,75 @@ if err := consumer.Unsubscribe(); err != nil {
 
 ### Consumer operations
 
-Pulsar Go consumers have the following methods available:
-
-Method | Description | Return type
-:------|:------------|:-----------
-`Subscription()` | Returns the consumer's subscription name | `string`
-`Unsubcribe()` | Unsubscribes the consumer from the assigned topic. Throws an 
error if the unsubscribe operation is somehow unsuccessful. | `error`
-`Receive(context.Context)` | Receives a single message from the topic. This 
method blocks until a message is available. | `(Message, error)`
-`Chan()` | Chan returns a channel from which to consume messages. | `<-chan 
ConsumerMessage`
-`Ack(Message)` | [Acknowledges](reference-terminology.md#acknowledgment-ack) a 
message to the Pulsar [broker](reference-terminology.md#broker) |
-`AckID(MessageID)` | 
[Acknowledges](reference-terminology.md#acknowledgment-ack) a message to the 
Pulsar [broker](reference-terminology.md#broker) by message ID |
-`ReconsumeLater(msg Message, delay time.Duration)` | ReconsumeLater mark a 
message for redelivery after custom delay |
-`Nack(Message)` | Acknowledge the failure to process a single message. |
-`NackID(MessageID)` | Acknowledge the failure to process a single message. |
-`Seek(msgID MessageID)` | Reset the subscription associated with this consumer 
to a specific message id. The message id can either be a specific message or 
represent the first or last messages in the topic. | `error`
-`SeekByTime(time time.Time)` | Reset the subscription associated with this 
consumer to a specific message publish time. | `error`
-`Close()` | Closes the consumer, disabling its ability to receive messages 
from the broker |
-`Name()` | Name returns the name of consumer | `string`
-
-### Receive example
+All available methods of `Consumer` interface are 
[here](https://pkg.go.dev/github.com/apache/pulsar-client-go/pulsar#Consumer).
 
-#### How to use regex consumer
+#### Create single-topic consumer
 
 ```go
-client, err := pulsar.NewClient(pulsar.ClientOptions{
-    URL: "pulsar://localhost:6650",
-})
+client, err := pulsar.NewClient(pulsar.ClientOptions{URL: 
"pulsar://localhost:6650"})
+if err != nil {
+    log.Fatal(err)
+}
 
 defer client.Close()
 
-p, err := client.CreateProducer(pulsar.ProducerOptions{
-       Topic:           topicInRegex,
-       DisableBatching: true,
+consumer, err := client.Subscribe(pulsar.ConsumerOptions{
+    // fill `Topic` field will create a single-topic consumer
+    Topic:            "topic-1",
+    SubscriptionName: "my-sub",
+    Type:             pulsar.Shared,
 })
 if err != nil {
-       log.Fatal(err)
+    log.Fatal(err)
 }
-defer p.Close()
+defer consumer.Close()
+```
+
+#### Create regex-topic consumer
+
+```go
+client, err := pulsar.NewClient(pulsar.ClientOptions{
+               URL: "pulsar://localhost:6650",
+})
+defer client.Close()
 
-topicsPattern := fmt.Sprintf("persistent://%s/foo.*", namespace)
+topicsPattern := "persistent://public/default/topic.*"
 opts := pulsar.ConsumerOptions{
-       TopicsPattern:    topicsPattern,
-       SubscriptionName: "regex-sub",
+    // fill `TopicsPattern` field will create a regex consumer
+    TopicsPattern:    topicsPattern,
+    SubscriptionName: "regex-sub",
 }
+
 consumer, err := client.Subscribe(opts)
 if err != nil {
-       log.Fatal(err)
+    log.Fatal(err)
 }
 defer consumer.Close()
 ```
 
-#### How to use multi topics Consumer
+#### Create multi-topic Consumer

Review Comment:
   ```suggestion
   #### Create multi-topic consumer
   ```



##########
site2/docs/client-libraries-go.md:
##########
@@ -585,64 +555,66 @@ defer cancel()
 
 // create consumer
 consumer, err := client.Subscribe(pulsar.ConsumerOptions{
-       Topic:            topic,
-       SubscriptionName: "my-sub1",
-       Type:             Shared,
+    Topic:            topic,
+    SubscriptionName: "my-sub1",
+    Type:             pulsar.Shared,
 })
 if err != nil {
-       log.Fatal(err)
+    log.Fatal(err)
 }
 defer consumer.Close()
 
+// receive message with a timeout
 msg, err := consumer.Receive(ctx)
-fmt.Println(msg.Payload())
 if err != nil {
-       log.Fatal(err)
+    log.Fatal(err)
 }
+fmt.Println(msg.Payload())
 ```
 
 #### How to use schema in consumer

Review Comment:
   ```suggestion
   #### Use schema in consumer
   ```



##########
site2/docs/client-libraries-go.md:
##########
@@ -832,12 +774,12 @@ reader, err := client.CreateReader(pulsar.ReaderOptions{
 #### How to use reader to read specific message

Review Comment:
   ```suggestion
   #### Use reader to read specific message
   ```



-- 
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