Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POC] wasm middlewares #3626

Closed
wants to merge 22 commits into from
Closed

[POC] wasm middlewares #3626

wants to merge 22 commits into from

Conversation

gernest
Copy link
Contributor

@gernest gernest commented Jul 19, 2021

{
    "name": "API with wasm middleware",
    "api_id": "3",
    "org_id": "default",
    "use_keyless": true,
    "proxy": {
        "listen_path": "/wasm/",
        "target_url": "http://httpbin.org/",
        "strip_listen_path": true
    },
    "do_not_track": true,
    "custom_middleware": {
        "pre": [
            {
                "name": "replace test header",
                "path": "http_headers.wasm"
            }
        ],
        "driver": "wasm"
    }
}

Copy link
Contributor

@matiasinsaurralde matiasinsaurralde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

Comment on lines +40 to +45
func (r *Request) GetHttpRequestMetadata() common.HeaderMap {
if r.Request == nil {
return nil
}
return &Header{head: r.Request.Trailer}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a bug.

@TykTechnologies TykTechnologies deleted a comment from github-actions bot Jul 28, 2021
@TykTechnologies TykTechnologies deleted a comment from github-actions bot Jul 28, 2021
@TykTechnologies TykTechnologies deleted a comment from github-actions bot Jul 28, 2021
@TykTechnologies TykTechnologies deleted a comment from github-actions bot Jul 28, 2021
@TykTechnologies TykTechnologies deleted a comment from github-actions bot Jul 28, 2021
@TykTechnologies TykTechnologies deleted a comment from github-actions bot Jul 28, 2021
@TykTechnologies TykTechnologies deleted a comment from github-actions bot Jul 28, 2021
@TykTechnologies TykTechnologies deleted a comment from github-actions bot Jul 28, 2021
@TykTechnologies TykTechnologies deleted a comment from github-actions bot Jul 28, 2021
@TykTechnologies TykTechnologies deleted a comment from github-actions bot Jul 28, 2021
@buger
Copy link
Member

buger commented Jul 28, 2021

@gernest wasm package looks like a copy from another project. What was the original?

@gernest
Copy link
Contributor Author

gernest commented Jul 28, 2021

@gernest
Copy link
Contributor Author

gernest commented Jul 28, 2021

With exception of https://github.com/gernest/tt/blob/master/wasm/instance.go which Is a modified copy of https://github.com/mosn/proxy-wasm-go-host/blob/main/wasmer/instance.go

I will add proper attribution (Its under Apache). My code is under MIT.

@gernest
Copy link
Contributor Author

gernest commented Jul 28, 2021

My project has different goals and release cadence. I had to copy over so as to have something tyk specific for this POC.

@github-actions
Copy link
Contributor

💥 CI tests failed 🙈

CI test log

go: downloading github.com/pmylund/go-cache v2.1.0+incompatible
go: downloading github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23
go: downloading github.com/miekg/dns v1.0.14
go: downloading github.com/satori/go.uuid v1.2.0
go: downloading google.golang.org/grpc v1.29.1
go: downloading github.com/justinas/alice v0.0.0-20171023064455-03f45bd4b7da
go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: downloading github.com/golang/protobuf v1.4.2
go: downloading github.com/TykTechnologies/graphql-go-tools v1.6.2-0.20210719163346-e69d4234c60e
go: downloading github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
go: downloading github.com/TykTechnologies/leakybucket v0.0.0-20170301023702-71692c943e3c
go: downloading gopkg.in/vmihailenco/msgpack.v2 v2.9.1
go: downloading github.com/newrelic/go-agent v2.13.0+incompatible
go: downloading golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
go: downloading github.com/opentracing/opentracing-go v1.1.0
go: downloading gorm.io/gorm v1.21.11
go: downloading github.com/Jeffail/gabs v1.4.0
go: downloading gopkg.in/Masterminds/sprig.v2 v2.21.0
go: downloading google.golang.org/protobuf v1.23.0
go: downloading github.com/gorilla/mux v1.7.3
go: downloading mosn.io/proxy-wasm-go-host v0.1.1-0.20210524020952-3fb13ba763a6
go: downloading github.com/wasmerio/wasmer-go v1.0.3
go: downloading gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
go: downloading gopkg.in/xmlpath.v2 v2.0.0-20150820204837-860cbeca3ebc
go: downloading github.com/hashicorp/consul/api v1.3.0
go: downloading github.com/evalphobia/logrus_sentry v0.8.2
go: downloading go.uber.org/atomic v1.5.1
go: downloading github.com/mavricknz/ldap v0.0.0-20160227184754-f5a958005e43
go: downloading github.com/google/uuid v1.1.1
go: downloading github.com/Masterminds/goutils v1.1.0
go: downloading github.com/TykTechnologies/again v0.0.0-20190805133618-6ad301e7eaed
go: downloading github.com/sirupsen/logrus v1.4.2
go: downloading github.com/bshuster-repo/logrus-logstash-hook v0.4.1
go: downloading github.com/getsentry/raven-go v0.2.0
go: downloading github.com/TykTechnologies/drl v0.0.0-20190905191955-cc541aa8e3e1
go: downloading golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
go: downloading golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b
go: downloading github.com/clbanning/mxj v1.8.4
go: downloading github.com/hashicorp/serf v0.8.2
go: downloading github.com/square/go-jose v2.4.1+incompatible
go: downloading github.com/TykTechnologies/openid2go v0.0.0-20200312160651-00c254a52b19
go: downloading github.com/mavricknz/asn1-ber v0.0.0-20151103223136-b9df1c2f4213
go: downloading github.com/pires/go-proxyproto v0.0.0-20190615163442-2c19fd512994
go: downloading github.com/jensneuse/byte-template v0.0.0-20200214152254-4f3cf06e5c68
go: downloading google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55
go: downloading github.com/hashicorp/go-rootcerts v1.0.1
go: downloading github.com/mitchellh/mapstructure v1.4.1
go: downloading github.com/jensneuse/abstractlogger v0.0.4
go: downloading github.com/cenk/backoff v2.2.1+incompatible
go: downloading github.com/gobwas/ws v1.0.4
go: downloading github.com/gocraft/health v0.0.0-20170925182251-8675af27fef0
go: downloading github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8
go: downloading github.com/dgrijalva/jwt-go v3.2.0+incompatible
go: downloading github.com/oschwald/maxminddb-golang v1.5.0
go: downloading github.com/tidwall/sjson v1.0.4
go: downloading github.com/imdario/mergo v0.3.9
go: downloading github.com/cenkalti/backoff/v4 v4.0.2
go: downloading github.com/nats-io/nats.go v1.11.1-0.20210623165838-4b75fc59ae30
go: downloading github.com/Masterminds/semver v1.5.0
go: downloading github.com/eclipse/paho.mqtt.golang v1.2.0
go: downloading golang.org/x/text v0.3.3
go: downloading github.com/TykTechnologies/goverify v0.0.0-20160822133757-7ccc57452ade
go: downloading github.com/Jeffail/tunny v0.0.0-20171107125207-452a8e97d6a3
go: downloading github.com/gemnasium/logrus-graylog-hook v2.0.7+incompatible
go: downloading golang.org/x/sys v0.0.0-20201119102817-f84b799fce68
go: downloading github.com/gorilla/websocket v1.4.2
go: downloading github.com/TykTechnologies/circuitbreaker v2.2.2+incompatible
go: downloading github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
go: downloading github.com/certifi/gocertifi v0.0.0-20190905060710-a5e0173ced67
go: downloading github.com/jensneuse/pipeline v0.0.0-20200117120358-9fb4de085cd6
go: downloading github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a
go: downloading github.com/gobwas/pool v0.2.0
go: downloading github.com/hashicorp/go-cleanhttp v0.5.1
go: downloading github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee
go: downloading github.com/hashicorp/vault/api v1.0.4
go: downloading github.com/TykTechnologies/murmur3 v0.0.0-20180602122059-1915e687e465
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/xeipuuv/gojsonschema v0.0.0-20171025060643-212d8a0df7ac
go: downloading github.com/hashicorp/vault/sdk v0.1.13
go: downloading github.com/TykTechnologies/gorpc v0.0.0-20190515174534-b9c10befc5f4
go: downloading github.com/uber/jaeger-client-go v2.19.0+incompatible
go: downloading github.com/kelseyhightower/envconfig v1.4.0
go: downloading github.com/hashicorp/errwrap v1.0.0
go: downloading gopkg.in/square/go-jose.v2 v2.3.1
go: downloading github.com/pkg/errors v0.9.1
go: downloading gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
go: downloading github.com/lonelycode/osin v0.0.0-20160423095202-da239c9dacb6
go: downloading github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d
go: downloading github.com/openzipkin/zipkin-go v0.2.2
go: downloading github.com/jinzhu/now v1.1.2
go: downloading rsc.io/letsencrypt v0.0.2
go: downloading github.com/rs/cors v1.7.0
go: downloading github.com/nats-io/nuid v1.0.1
go: downloading github.com/xenolf/lego v0.3.2-0.20170618175828-28ead50ff1ca
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/jinzhu/inflection v1.0.0
go: downloading github.com/lonelycode/go-uuid v0.0.0-20141202165402-ed3ca8a15a93
go: downloading github.com/TykTechnologies/goautosocket v0.0.0-20190430121222-97bfa5e7e481
go: downloading github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
go: downloading github.com/huandu/xstrings v1.3.0
go: downloading github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da
go: downloading github.com/hashicorp/go-sockaddr v1.0.2
go: downloading go.uber.org/zap v1.13.0
go: downloading github.com/uber/jaeger-lib v2.2.0+incompatible
go: downloading github.com/golang/snappy v0.0.3
go: downloading github.com/hashicorp/go-retryablehttp v0.5.4
go: downloading github.com/x-cray/logrus-prefixed-formatter v0.5.2
go: downloading github.com/spf13/afero v1.6.0
go: downloading github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb
go: downloading github.com/tidwall/gjson v1.3.5
go: downloading gopkg.in/sourcemap.v1 v1.0.5
go: downloading github.com/hashicorp/go-multierror v1.0.0
go: downloading github.com/nats-io/nkeys v0.3.0
go: downloading github.com/paulbellamy/ratecounter v0.2.0
go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
go: downloading github.com/tidwall/match v1.0.1
go: downloading golang.org/x/time v0.0.0-20191024005414-555d28b269f0
go: downloading gopkg.in/square/go-jose.v1 v1.1.2
go: downloading github.com/go-redis/redis/v8 v8.3.1
go: downloading github.com/pierrec/lz4 v2.0.5+incompatible
go: downloading go.uber.org/multierr v1.3.0
go: downloading github.com/hashicorp/go-immutable-radix v1.0.0
go: downloading github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
go: downloading github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
go: downloading github.com/Masterminds/sprig v2.22.0+incompatible
go: downloading go.opentelemetry.io/otel v0.13.0
go: downloading golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
go: downloading github.com/tidwall/pretty v1.0.0
go: downloading nhooyr.io/websocket v1.8.7
go: downloading github.com/TykTechnologies/gojsonschema v0.0.0-20170222154038-dcb3e4bb7990
go: downloading github.com/hashicorp/golang-lru v0.5.4
go: downloading github.com/ryanuber/go-glob v1.0.0
go: downloading github.com/mattn/go-colorable v0.1.4
go: downloading github.com/mitchellh/copystructure v1.0.0
go: downloading github.com/klauspost/compress v1.13.1
go: downloading github.com/mitchellh/reflectwalk v1.0.0
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/cespare/xxhash/v2 v2.1.1
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk
?   	github.com/TykTechnologies/tyk	[no test files]
go vet github.com/TykTechnologies/tyk
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/apidef
go: downloading github.com/stretchr/testify v1.7.0
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
ok  	github.com/TykTechnologies/tyk/apidef	0.062s	coverage: 21.4% of statements
go vet github.com/TykTechnologies/tyk/apidef
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/apidef/adapter
ok  	github.com/TykTechnologies/tyk/apidef/adapter	0.112s	coverage: 87.3% of statements
go vet github.com/TykTechnologies/tyk/apidef/adapter
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/apidef/importer
ok  	github.com/TykTechnologies/tyk/apidef/importer	0.062s	coverage: 65.6% of statements
go vet github.com/TykTechnologies/tyk/apidef/importer
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/certs
ok  	github.com/TykTechnologies/tyk/certs	5.131s	coverage: 56.5% of statements
go vet github.com/TykTechnologies/tyk/certs
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/checkup
?   	github.com/TykTechnologies/tyk/checkup	[no test files]
go vet github.com/TykTechnologies/tyk/checkup
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/cli
?   	github.com/TykTechnologies/tyk/cli	[no test files]
go vet github.com/TykTechnologies/tyk/cli
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/cli/bundler
ok  	github.com/TykTechnologies/tyk/cli/bundler	0.063s	coverage: 70.7% of statements
go vet github.com/TykTechnologies/tyk/cli/bundler
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/cli/importer
?   	github.com/TykTechnologies/tyk/cli/importer	[no test files]
go vet github.com/TykTechnologies/tyk/cli/importer
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/cli/linter
ok  	github.com/TykTechnologies/tyk/cli/linter	0.245s	coverage: 89.8% of statements
go vet github.com/TykTechnologies/tyk/cli/linter
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/config
go: downloading github.com/nsf/jsondiff v0.0.0-20210303162244-6ea32392771e
ok  	github.com/TykTechnologies/tyk/config	0.143s	coverage: 69.9% of statements
go vet github.com/TykTechnologies/tyk/config
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/coprocess
?   	github.com/TykTechnologies/tyk/coprocess	[no test files]
go vet github.com/TykTechnologies/tyk/coprocess
go test -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/coprocess/grpc
ok  	github.com/TykTechnologies/tyk/coprocess/grpc	7.417s	coverage: [no statements]
go vet github.com/TykTechnologies/tyk/coprocess/grpc
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/coprocess/python
ok  	github.com/TykTechnologies/tyk/coprocess/python	11.977s	coverage: [no statements]
go vet github.com/TykTechnologies/tyk/coprocess/python
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/ctx
?   	github.com/TykTechnologies/tyk/ctx	[no test files]
go vet github.com/TykTechnologies/tyk/ctx
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/dlpython
ok  	github.com/TykTechnologies/tyk/dlpython	0.277s	coverage: 54.5% of statements
go vet github.com/TykTechnologies/tyk/dlpython
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/dnscache
ok  	github.com/TykTechnologies/tyk/dnscache	11.690s	coverage: 82.5% of statements
go vet github.com/TykTechnologies/tyk/dnscache
go test -race -timeout 5m -coverprofile=test.cov github.com/TykTechnologies/tyk/gateway
go: downloading github.com/valyala/fasthttp v1.15.1
go: downloading github.com/valyala/bytebufferpool v1.0.0
go: downloading github.com/andybalholm/brotli v1.0.0
time="Jul 28 23:18:11" level=info msg="Rich plugins are disabled" prefix=coprocess
--- FAIL: TestAPIMutualTLS (2.68s)
    --- FAIL: TestAPIMutualTLS/Multiple_APIs_with_Mutual_TLS_on_the_same_domain (0.42s)
        --- FAIL: TestAPIMutualTLS/Multiple_APIs_with_Mutual_TLS_on_the_same_domain/Empty_domain (0.22s)
            --- FAIL: TestAPIMutualTLS/Multiple_APIs_with_Mutual_TLS_on_the_same_domain/Empty_domain/Client_certificate_not_match (0.08s)
                cert_test.go:474: [0] Expect error `Get "https://127.0.0.1:45591/with_mutual_2": write tcp 127.0.0.1:45578->127.0.0.1:45591: write: connection reset by peer` to contain `tls: bad certificate`. 
--- FAIL: TestResponseOverride (2.97s)
    --- FAIL: TestResponseOverride/JSVM (1.11s)
        coprocess_bundle_test.go:223: [0] Response body does not match with regex `{"foo": "bar"}`. {"Method":"GET","URI":"/test/?status=200","Url":"/test/?status=200","Body":"","Headers":{"Accept-Encoding":"gzip","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"status":"200"}}
            . 
        coprocess_bundle_test.go:223: [1] Response body does not match with regex `foobar`. {"Method":"GET","URI":"/test/?status=200\u0026response_body=true","Url":"/test/?status=200\u0026response_body=true","Body":"","Headers":{"Accept-Encoding":"gzip","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"response_body":"true","status":"200"}}
            . 
        coprocess_bundle_test.go:223: [2] Expected status code `400` got `200. {"Method":"GET","URI":"/test/?status=400","Url":"/test/?status=400","Body":"","Headers":{"Accept-Encoding":"gzip","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"status":"400"}}
            `. 
        coprocess_bundle_test.go:223: [3] Expected status code `400` got `200. {"Method":"GET","URI":"/test/?status=400\u0026response_body=true","Url":"/test/?status=400\u0026response_body=true","Body":"","Headers":{"Accept-Encoding":"gzip","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"response_body":"true","status":"400"}}
            `. 
        coprocess_bundle_test.go:223: [4] Expected status code `401` got `200. {"Method":"GET","URI":"/test/?status=401","Url":"/test/?status=401","Body":"","Headers":{"Accept-Encoding":"gzip","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"status":"401"}}
            `. 
        coprocess_bundle_test.go:223: [5] Expected status code `400` got `200. {"Method":"GET","URI":"/test/?status=400\u0026override=true","Url":"/test/?status=400\u0026override=true","Body":"","Headers":{"Accept-Encoding":"gzip","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"override":"true","status":"400"}}
            `. 
        coprocess_bundle_test.go:223: [6] Expected status code `400` got `200. {"Method":"GET","URI":"/test/?status=400\u0026override=true\u0026response_body=true","Url":"/test/?status=400\u0026override=true\u0026response_body=true","Body":"","Headers":{"Accept-Encoding":"gzip","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"override":"true","response_body":"true","status":"400"}}
            `. 
        coprocess_bundle_test.go:223: [7] Expected status code `401` got `200. {"Method":"GET","URI":"/test/?status=401\u0026override=true","Url":"/test/?status=401\u0026override=true","Body":"","Headers":{"Accept-Encoding":"gzip","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"override":"true","status":"401"}}
            `. 
--- FAIL: TestTykMakeHTTPRequest (2.06s)
    --- FAIL: TestTykMakeHTTPRequest/Nonexistent_endpoint (0.08s)
        mw_js_plugin_test.go:422: [0] Expected status code `404` got `200. {"Method":"GET","URI":"/sample","Url":"/sample","Body":"","Headers":{"Accept-Encoding":"gzip","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{}}
            `. 
    --- FAIL: TestTykMakeHTTPRequest/Endpoint_with_query (0.09s)
        mw_js_plugin_test.go:436: [0] Response body does not match with regex `/api/get\?param1=dummy`. {"Method":"GET","URI":"/sample","Url":"/sample","Body":"","Headers":{"Accept-Encoding":"gzip","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{}}
            . 
--- FAIL: TestJSVMStagesRequest (0.93s)
    --- FAIL: TestJSVMStagesRequest/Bundles (0.12s)
        mw_js_plugin_test.go:591: [0] Response body does not match with regex `"Pre":"foobar"`. {"Method":"GET","URI":"/test?post=foobar","Url":"/test?post=foobar","Body":"","Headers":{"Accept-Encoding":"gzip","Post":"foobar","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"post":"foobar"}}
            . 
    --- FAIL: TestJSVMStagesRequest/Files (0.10s)
        mw_js_plugin_test.go:609: [0] Response body does not match with regex `"Pre":"foobar"`. {"Method":"GET","URI":"/test?post=foobar","Url":"/test?post=foobar","Body":"","Headers":{"Accept-Encoding":"gzip","Post":"foobar","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"post":"foobar"}}
            . 
    --- FAIL: TestJSVMStagesRequest/API_definition (0.11s)
        mw_js_plugin_test.go:636: [0] Response body does not match with regex `"Pre":"foobar"`. {"Method":"GET","URI":"/test?post=foobar","Url":"/test?post=foobar","Body":"","Headers":{"Accept-Encoding":"gzip","Post":"foobar","User-Agent":"Go-http-client/1.1","X-Forwarded-For":"127.0.0.1"},"Form":{"post":"foobar"}}
            . 
--- FAIL: TestApplyMultiPolicies (0.72s)
    --- FAIL: TestApplyMultiPolicies/Requests_different_apis (0.03s)
        policy_test.go:1117: [1] Response header `X-RateLimit-Remaining` expected `48` instead `49`. map[Content-Length:[221] Content-Type:[text/plain; charset=utf-8] Date:[Wed, 28 Jul 2021 23:22:32 GMT] X-Ratelimit-Limit:[50] X-Ratelimit-Remaining:[49] X-Ratelimit-Reset:[1627518152] X-Tyk-Test:[1]]. 
    --- FAIL: TestApplyMultiPolicies/Check_key_session (0.00s)
        policy_test.go:1163: 
            	Error Trace:	policy_test.go:1163
            	            				http.go:67
            	            				http.go:299
            	            				testutil.go:988
            	            				policy_test.go:1145
            	Error:      	Not equal: 
            	            	expected: user.APILimit{Rate:1000, Per:1, ThrottleInterval:0, ThrottleRetryLimit:0, MaxQueryDepth:0, QuotaMax:50, QuotaRenews:1627518152, QuotaRemaining:48, QuotaRenewalRate:3600, SetBy:""}
            	            	actual  : user.APILimit{Rate:1000, Per:1, ThrottleInterval:0, ThrottleRetryLimit:0, MaxQueryDepth:0, QuotaMax:50, QuotaRenews:1627518152, QuotaRemaining:49, QuotaRenewalRate:3600, SetBy:""}
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -8,3 +8,3 @@
            	            	  QuotaRenews: (int64) 1627518152,
            	            	- QuotaRemaining: (int64) 48,
            	            	+ QuotaRemaining: (int64) 49,
            	            	  QuotaRenewalRate: (int64) 3600,
            	Test:       	TestApplyMultiPolicies/Check_key_session
            	Messages:   	API1 limit do not match
FAIL
coverage: 65.6% of statements
FAIL	github.com/TykTechnologies/tyk/gateway	281.267s
FAIL
Test Failed

gofmt

all ok

goimports

all ok

If the above are ok, please look at the run or in the Checks tab.

@buger
Copy link
Member

buger commented Aug 5, 2021

@gernest how extending it with custom function will look like?
For example, exposing simple memory storage functions, SetKey, GetKey ?
Also how user can get access to user session object?

@gernest
Copy link
Contributor Author

gernest commented Aug 5, 2021

@buger

how extending it with custom function will look like?

easy, you can register go functions that will be available in the module as imports.

For example, exposing simple memory storage functions, SetKey, GetKey ?

This is already described by the ABI so it is doable(I didn't implement this on this branch)

Also how user can get access to user session object?

Many ways, they will require serialization/deserialrization though. we can extend and add functions for manipulating sessions if need be or we can stick with the ABI and expose using abi primitives.

@gernest gernest closed this Oct 4, 2021
@buger
Copy link
Member

buger commented Oct 4, 2021

I do not think we need to close it

@gernest
Copy link
Contributor Author

gernest commented Oct 4, 2021

My bad! Is there still interest in this?

@gernest gernest reopened this Oct 4, 2021
@excieve
Copy link
Member

excieve commented Oct 4, 2021

Sounds like a better way to do close to native speed plugins for most users. What is it missing to go from a PoC to a feature @gernest?

FYI @alephnull: that's the PoC I mentioned.

@joshblakeley
Copy link
Member

This needs some ownership and then 100% goes into the gateway

@sonarcloud
Copy link

sonarcloud bot commented Oct 5, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@lghiur lghiur closed this Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants