Copilot commented on code in PR #1471:
URL: https://github.com/apache/pulsar-client-go/pull/1471#discussion_r2958270009
##########
pulsaradmin/README.md:
##########
@@ -103,6 +103,40 @@ func main() {
}
```
+- Read scoped topic policies
+
+```go
+import (
+ "github.com/apache/pulsar-client-go/pulsaradmin"
+ "github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
+)
+
+func main() {
+ cfg := &pulsaradmin.Config{}
+ admin, err := pulsaradmin.NewClient(cfg)
+ if err != nil {
+ panic(err)
+ }
+
+ topic, _ := utils.GetTopicName("persistent://public/default/example")
+
+ localPolicies, err := pulsaradmin.TopicPoliciesOf(admin, false)
+ if err != nil {
+ panic(err)
+ }
+
+ ttl, err := localPolicies.GetMessageTTL(*topic, false)
+ if err != nil {
+ panic(err)
+ }
+ if ttl == nil {
+ return
+ }
+
+ _, _ = pulsaradmin.TopicPoliciesOf(admin, true)
Review Comment:
The last line `_, _ = pulsaradmin.TopicPoliciesOf(admin, true)` discards
both return values and doesn't demonstrate global policy usage. Consider either
removing it or showing a minimal example of using `globalPolicies` so the
snippet is actionable and not misleading.
##########
pulsaradmin/README.md:
##########
@@ -103,6 +103,40 @@ func main() {
}
```
+- Read scoped topic policies
+
+```go
+import (
+ "github.com/apache/pulsar-client-go/pulsaradmin"
+ "github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
+)
+
+func main() {
+ cfg := &pulsaradmin.Config{}
+ admin, err := pulsaradmin.NewClient(cfg)
+ if err != nil {
+ panic(err)
+ }
+
+ topic, _ := utils.GetTopicName("persistent://public/default/example")
+
Review Comment:
In this README example, `utils.GetTopicName`'s error is ignored (`topic, _
:= ...`). Since this is the primary way users will copy/paste usage, please
handle the error (or use `require.NoError` style in docs/tests) to avoid
encouraging unsafe patterns.
--
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]