Copilot commented on code in PR #1112: URL: https://github.com/apache/dubbo-go-samples/pull/1112#discussion_r3425026534
########## README_CN.md: ########## @@ -73,6 +73,7 @@ * `streaming`:流式 RPC 调用示例,并包含了Dubbo-go与Dubbo-java同时使用流式传输的互操作示例。 * `task`:任务调度与执行示例。 * `timeout`:Dubbo-go 超时处理示例。 +* `triple_header_trailer`:演示 Triple 请求 metadata/attachments 以及基于 `http.Header` 暴露的响应 header / trailer。 Review Comment: 这里写了 "metadata/attachments",但该示例实际演示的是 Triple metadata API(以 `http.Header` 暴露),并没有演示 Dubbo attachments。为避免误导,建议去掉 attachments 表述。 ########## README.md: ########## @@ -73,6 +73,7 @@ Please refer to [HOWTO.md](HOWTO.md) for detailed instructions on running the sa * `streaming`: Streaming RPC example, also includes Go–Java interoperability when both use streaming. * `task`: Task scheduling and execution example. * `timeout`: Demonstrates timeout handling in Dubbo-go. +* `triple_header_trailer`: Demonstrates Triple request metadata/attachments and response headers/trailers exposed through `http.Header`. Review Comment: The new sample entry mentions "metadata/attachments", but this sample demonstrates Triple metadata exposed via `http.Header` (not Dubbo attachments). Using "attachments" here is misleading and inconsistent with the sample README. ########## triple_header_trailer/go-client/cmd/main.go: ########## @@ -0,0 +1,185 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "context" + "fmt" + "net/http" + "strings" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/client" + _ "dubbo.apache.org/dubbo-go/v3/imports" + triple "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol" + + "github.com/dubbogo/gost/log/logger" +) + +import ( + greet "github.com/apache/dubbo-go-samples/triple_header_trailer/proto" +) + +const ( + tokenHeader = "X-Sample-Token" + modeHeader = "X-Sample-Mode" + streamResponseKey = "X-Stream-Response" + streamTrailerKey = "X-Stream-Trailer" +) + +func main() { + cli, err := client.NewClient( + client.WithClientURL("tri://127.0.0.1:20000"), + ) + if err != nil { + panic(err) + } + + svc, err := greet.NewGreetService(cli) + if err != nil { + panic(err) + } + + if err := testUnary(svc); err != nil { + panic(err) + } + if err := testBidiStream(svc); err != nil { + panic(err) + } + if err := testClientStream(svc); err != nil { + panic(err) + } + if err := testServerStream(svc); err != nil { + panic(err) + } +} + +func testUnary(cli greet.GreetService) error { + // todo: this API haven't been exposed yet, current just make a trivial unary triple call Review Comment: The TODO comment has grammatical issues ("haven't"/"current") and is a bit unclear about what is not exposed. Clarifying it makes the sample easier to understand. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
