wangdayong228 opened a new issue, #137:
URL: https://github.com/apache/apisix-go-plugin-runner/issues/137

   ### Issue description
   request id 和 通过 response 取的 request id 不一样, 请问有什么规则?
   
   插件代码如下
   ```
   package plugins
   
   import (
        "net/http"
   
        pkgHTTP "github.com/apache/apisix-go-plugin-runner/pkg/http"
        "github.com/apache/apisix-go-plugin-runner/pkg/log"
        "github.com/apache/apisix-go-plugin-runner/pkg/plugin"
   )
   
   func init() {
        err := plugin.RegisterPlugin(&CheckId{})
        if err != nil {
                log.Fatalf("failed to register plugin check_id: %s", err)
        }
   }
   
   // Say is a demo to show how to return data directly instead of proxying
   // it to the upstream.
   type CheckId struct {
        // Embed the default plugin here,
        // so that we don't need to reimplement all the methods.
        plugin.DefaultPlugin
   }
   
   type CheckIdConf struct {
   }
   
   func (p *CheckId) Name() string {
        return "check_id"
   }
   
   func (p *CheckId) ParseConf(in []byte) (interface{}, error) {
        return CheckIdConf{}, nil
   }
   
   func (p *CheckId) RequestFilter(conf interface{}, w http.ResponseWriter, r 
pkgHTTP.Request) {
        log.Infof("run request filter, r.ID() %d", r.ID())
   }
   
   func (p *CheckId) ResponseFilter(conf interface{}, w pkgHTTP.Response) {
        log.Infof("run response filter, w.ID() %d", w.ID())
   }
   
   ```
   
   当发送请求时控制台输出
   
   ```
   apisix_1            | 2023/08/04 10:33:48 [warn] 60#60: *120 [lua] 
init.lua:953: 2023-08-04T10:33:48.456Z       INFO    server/server.go:115    
Client connected (unix)
   apisix_1            | 2023-08-04T10:33:48.456Z  INFO    server/server.go:115 
   Client connected (unix)
   apisix_1            | , context: ngx.timer
   apisix_1            | 2023/08/04 10:33:48 [warn] 60#60: *120 [lua] 
init.lua:953: 2023-08-04T10:33:48.458Z       INFO    server/server.go:131    
receive rpc type: 2 data length: 216
   apisix_1            | 2023-08-04T10:33:48.458Z  INFO    plugin/plugin.go:120 
   run plugin check_id
   apisix_1            | 2023-08-04T10:33:48.458Z  INFO    
plugins/check_req_res_id.go:38  run request filter, r.ID() 4194308
   apisix_1            | , context: ngx.timer
   apisix_1            | 2023/08/04 10:33:48 [warn] 60#60: *120 [lua] 
init.lua:953: 2023-08-04T10:33:48.463Z       INFO    server/server.go:131    
receive rpc type: 4 data length: 388
   apisix_1            | , context: ngx.timer
   apisix_1            | 2023/08/04 10:33:48 [warn] 60#60: *120 [lua] 
init.lua:953: 2023-08-04T10:33:48.463Z       INFO    plugin/plugin.go:185    
run plugin check_id
   apisix_1            | 2023-08-04T10:33:48.463Z  INFO    
plugins/check_req_res_id.go:42  run response filter, w.ID() 4194309
   ```
   request filter 中获取的 request id 跟 responsor filter中获取的request id 不一致,分别是 
4194308 和 4194309
   
   
   ### Environment
   
   * APISIX Go Plugin Runner's version: master 主分支
   * APISIX version: docker 3.4.0-debian
   * Go version: 1.18 
   * OS (cmd: `uname -a`): Linux 49dc336f1aee 5.10.104-linuxkit #1 SMP Thu Mar 
17 17:08:06 UTC 2022 x86_64 GNU/Linux
   


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