[
https://issues.apache.org/jira/browse/THRIFT-4553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16436674#comment-16436674
]
gansteed commented on THRIFT-4553:
----------------------------------
[~calcifer] hello, I want to do it in BinaryProtocol, too, do you have some
suggestions? I'm developing a function to calculate execution time of RPC
service, and sent it to prometheus. since thrift go implementation does not
support middleware, so I wrap the generated processor code, and do something
like this:
{code:java}
func (c CustomizedTProcessor) Process(ctx context.Context, iprot, oprot
thrift.TProtocol) (success bool, err thrift.TException) {
start := time.Now()
success, err = c.p.Process(ctx, iprot, oprot)
end := time.Now()
latency := end.Sub(start)
var status string
if success {
status = "200"
} else {
status = "400"
}
// log, and sent add it to prometheus client
}{code}
but I cannot get which function `c.p.Process` will execute. any suggestions?
Thanks!
> are there any plans for add middle-ware support for thrift Go implementation?
> -----------------------------------------------------------------------------
>
> Key: THRIFT-4553
> URL: https://issues.apache.org/jira/browse/THRIFT-4553
> Project: Thrift
> Issue Type: New Feature
> Affects Versions: 0.11.0
> Reporter: gansteed
> Priority: Major
>
> version1:
> provide a function to register middleware, and chain processors all. each
> function can call `Next` to skip to next function. something like middle-ware
> implementation in gin[1].
> version2:
> provide two function in TSimpleServer, one for preProcess, one for
> afterProcess. and call them
> before and after `ok, err := processor.Process(defaultCtx, inputProtocol,
> outputProtocol)`, so they can use defaultCtx to do something.
>
> middle-ware is useful for something like monitoring micro service, count
> execution time...etc.
>
> [1]: https://github.com/gin-gonic/gin/blob/master/context.go#L104
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)