This is an automated email from the ASF dual-hosted git repository.
dcelasun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push:
new 0c173bf THRIFT-5164: Small cleanup on example code
0c173bf is described below
commit 0c173bf9e02ee218ee7427aa0521845f674a3dd3
Author: Yuxuan 'fishy' Wang <[email protected]>
AuthorDate: Thu Apr 30 23:49:29 2020 -0700
THRIFT-5164: Small cleanup on example code
Client: go
Godoc requires at least one other exported type/function to render the
whole example file in the example, so export
simpleProcessorLoggingMiddleware to make the example of
ProcessorMiddleware more helpful.
Currently it's rendered in a not very helpful way:
https://pkg.go.dev/github.com/apache/[email protected]/lib/go/thrift?tab=doc#example-ProcessorMiddleware
Compare to the client middleware example rendering:
https://pkg.go.dev/github.com/apache/[email protected]/lib/go/thrift?tab=doc#example-ClientMiddleware
While I'm here, also update CHANGES.md to mention ClientMiddleware.
[skip ci]
---
CHANGES.md | 1 +
lib/go/thrift/example_client_middleware_test.go | 2 ++
lib/go/thrift/example_processor_middleware_test.go | 6 ++++--
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index b8bef21..0c394c4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -20,6 +20,7 @@
- [THRIFT-5069](https://issues.apache.org/jira/browse/THRIFT-5069) - Add
TSerializerPool and TDeserializerPool, which are thread-safe versions of
TSerializer and TDeserializer.
- [THRIFT-5164](https://issues.apache.org/jira/browse/THRIFT-5164) - Add
ProcessorMiddleware function type and WrapProcessor function to support
wrapping a TProcessor with middleware functions.
+- [THRIFT-5164](https://issues.apache.org/jira/browse/THRIFT-5164) - Add
ClientMiddleware function type and WrapClient function to support wrapping a
TClient with middleware functions.
## 0.13.0
diff --git a/lib/go/thrift/example_client_middleware_test.go
b/lib/go/thrift/example_client_middleware_test.go
index e2e11c3..8a29083 100644
--- a/lib/go/thrift/example_client_middleware_test.go
+++ b/lib/go/thrift/example_client_middleware_test.go
@@ -59,6 +59,8 @@ func simpleClientLoggingMiddleware(next TClient) TClient {
}
}
+// This example demonstrates how to define and use a simple logging middleware
+// to your thrift client.
func ExampleClientMiddleware() {
var (
trans TTransport
diff --git a/lib/go/thrift/example_processor_middleware_test.go
b/lib/go/thrift/example_processor_middleware_test.go
index 844358f..724a4f2 100644
--- a/lib/go/thrift/example_processor_middleware_test.go
+++ b/lib/go/thrift/example_processor_middleware_test.go
@@ -24,7 +24,7 @@ import (
"log"
)
-func simpleProcessorLoggingMiddleware(name string, next TProcessorFunction)
TProcessorFunction {
+func SimpleProcessorLoggingMiddleware(name string, next TProcessorFunction)
TProcessorFunction {
return WrappedTProcessorFunction{
Wrapped: func(ctx context.Context, seqId int32, in, out
TProtocol) (bool, TException) {
log.Printf("Before: %q", name)
@@ -39,6 +39,8 @@ func simpleProcessorLoggingMiddleware(name string, next
TProcessorFunction) TPro
}
}
+// This example demonstrates how to define and use a simple logging middleware
+// to your thrift server/processor.
func ExampleProcessorMiddleware() {
var (
processor TProcessor
@@ -46,7 +48,7 @@ func ExampleProcessorMiddleware() {
transFactory TTransportFactory
protoFactory TProtocolFactory
)
- processor = WrapProcessor(processor, simpleProcessorLoggingMiddleware)
+ processor = WrapProcessor(processor, SimpleProcessorLoggingMiddleware)
server := NewTSimpleServer4(processor, trans, transFactory,
protoFactory)
log.Fatal(server.Serve())
}