apache / apache/apisix-go-plugin-runner

request help: request id 和 通过 response 取的 request id 不一样 ,是否有什么规则?

Open
#137 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
198
Forks
68
PR merge metrics
No merged PRs in 30d

Description

### Issue description
request id 和 通过 response 取的 request id 不一样, 请问有什么规则? 除了通过ID的方式,是否还有其他方式可以根据response 获取到对应的 request?

插件代码如下
```
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.