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

Handle decode error with context, add baseURL setter to test client #41

Merged
merged 2 commits into from
Jun 28, 2021

Conversation

vearutop
Copy link
Member

No description provided.

@github-actions
Copy link

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 77 5995 (+16) 4352 (+10) 405 (+1) 1238 (+5) 829 (+2) 141.6K (+389B)

@github-actions
Copy link

Unit Test Coverage

total: (statements) 81.8%

Coverage diff with base branch
93c93
< github.com/swaggest/rest/request/decoder.go	formDataToURLValues	77.8%
---
> github.com/swaggest/rest/request/decoder.go	formDataToURLValues	66.7%
136c136,137
< github.com/swaggest/rest/resttest/client.go	NewClient	66.7%
---
> github.com/swaggest/rest/resttest/client.go	NewClient	100.0%
> github.com/swaggest/rest/resttest/client.go	SetBaseURL	66.7%

@codecov
Copy link

codecov bot commented Jun 28, 2021

Codecov Report

Merging #41 (d1b10c7) into master (224d2c1) will increase coverage by 0.10%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #41      +/-   ##
==========================================
+ Coverage   74.10%   74.20%   +0.10%     
==========================================
  Files          26       26              
  Lines        1560     1423     -137     
==========================================
- Hits         1156     1056     -100     
+ Misses        254      228      -26     
+ Partials      150      139      -11     
Flag Coverage Δ
unittests 74.20% <80.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
validator.go 0.00% <ø> (ø)
nethttp/handler.go 81.57% <60.00%> (-4.85%) ⬇️
nethttp/usecase.go 80.00% <100.00%> (ø)
resttest/client.go 61.45% <100.00%> (-0.65%) ⬇️
request/decoder.go 71.42% <0.00%> (-5.72%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 224d2c1...d1b10c7. Read the comment docs.

@github-actions
Copy link

Benchmark Result

Benchmark diff with base branch
name                                    old time/op    new time/op    delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-2    1.64µs ±36%    1.44µs ± 0%  -12.18%  (p=0.016 n=5+4)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                           829ns ± 1%     819ns ± 3%     ~     (p=0.548 n=5+5)
DecoderFunc_Decode-2                      2.29µs ± 2%    2.32µs ± 1%     ~     (p=0.310 n=5+5)
Decoder_Decode_json-2                     26.3µs ± 2%    26.7µs ± 1%     ~     (p=0.056 n=5+5)
Decoder_Decode_queryObject-2              5.77µs ± 1%    5.84µs ± 1%   +1.19%  (p=0.016 n=5+5)
Decoder_Decode_jsonParam-2                2.07µs ± 1%    2.08µs ± 1%     ~     (p=0.381 n=5+5)
DecoderFactory_SetDecoderFunc-2           1.87µs ± 1%    1.90µs ± 3%     ~     (p=0.286 n=5+5)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                              12.7µs ± 0%    12.7µs ± 0%     ~     (p=0.841 n=5+5)
Middleware_control-2                      3.36µs ± 4%    3.34µs ± 0%     ~     (p=0.222 n=5+5)

name                                    old alloc/op   new alloc/op   delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-2    2.50kB ± 0%    2.50kB ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                            440B ± 0%      440B ± 0%     ~     (all equal)
DecoderFunc_Decode-2                      1.51kB ± 0%    1.51kB ± 0%     ~     (all equal)
Decoder_Decode_json-2                     12.3kB ± 0%    12.3kB ± 0%     ~     (all equal)
Decoder_Decode_queryObject-2              2.00kB ± 0%    2.00kB ± 0%     ~     (all equal)
Decoder_Decode_jsonParam-2                  720B ± 0%      720B ± 0%     ~     (all equal)
DecoderFactory_SetDecoderFunc-2           1.02kB ± 0%    1.02kB ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                              1.11kB ± 3%    1.15kB ± 4%     ~     (p=0.095 n=5+5)
Middleware_control-2                      11.2kB ± 0%    11.2kB ± 0%     ~     (all equal)

name                                    old allocs/op  new allocs/op  delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-2      8.00 ± 0%      8.00 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                            4.00 ± 0%      4.00 ± 0%     ~     (all equal)
DecoderFunc_Decode-2                        12.0 ± 0%      12.0 ± 0%     ~     (all equal)
Decoder_Decode_json-2                        169 ± 0%       169 ± 0%     ~     (all equal)
Decoder_Decode_queryObject-2                36.0 ± 0%      36.0 ± 0%     ~     (all equal)
Decoder_Decode_jsonParam-2                  12.0 ± 0%      12.0 ± 0%     ~     (all equal)
DecoderFactory_SetDecoderFunc-2             16.0 ± 0%      16.0 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                                11.0 ± 0%      11.0 ± 0%     ~     (all equal)
Middleware_control-2                        9.00 ± 0%      9.00 ± 0%     ~     (all equal)

@github-actions
Copy link

Examples Benchmark Result

Benchmark diff with base branch
name                    old time/op    new time/op    delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2             38.7µs ± 3%    37.5µs ± 1%  -3.01%  (p=0.016 n=5+5)
_directGzipHead-2         39.8µs ± 3%    37.7µs ± 2%  -5.47%  (p=0.008 n=5+5)
_noDirectGzip-2            174µs ± 2%     171µs ± 2%    ~     (p=0.222 n=5+5)
_directGzip_decode-2       635µs ± 4%     646µs ± 5%    ~     (p=0.841 n=5+5)
_noDirectGzip_decode-2     173µs ± 2%     171µs ± 2%    ~     (p=0.222 n=5+5)
_jsonBody-2               67.4µs ± 5%    66.3µs ± 4%    ~     (p=0.222 n=5+5)
_jsonBodyValidation-2     74.5µs ± 2%    76.7µs ± 2%  +2.96%  (p=0.032 n=5+5)
_outputHeaders-2          37.0µs ± 2%    37.0µs ± 2%    ~     (p=1.000 n=5+5)
_validation-2             70.4µs ± 3%    69.5µs ± 2%    ~     (p=0.310 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2            42.9µs ± 4%    41.6µs ± 2%    ~     (p=0.310 n=5+5)
_ok-2                     43.4µs ± 3%    45.1µs ± 3%  +3.78%  (p=0.032 n=5+5)
_invalidBody-2            63.4µs ± 3%    63.8µs ± 3%    ~     (p=0.548 n=5+5)

name                    old B:rcvd/op  new B:rcvd/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2                639 ± 0%       639 ± 0%    ~     (all equal)
_directGzipHead-2            183 ± 0%       183 ± 0%    ~     (all equal)
_noDirectGzip-2            1.04k ± 0%     1.04k ± 0%    ~     (all equal)
_directGzip_decode-2         639 ± 0%       639 ± 0%    ~     (all equal)
_noDirectGzip_decode-2     1.04k ± 0%     1.04k ± 0%    ~     (all equal)
_jsonBody-2                  208 ± 0%       208 ± 0%    ~     (all equal)
_jsonBodyValidation-2        194 ± 0%       194 ± 0%    ~     (all equal)
_outputHeaders-2             155 ± 0%       155 ± 0%    ~     (all equal)
_validation-2                177 ± 0%       177 ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2               337 ± 0%       337 ± 0%    ~     (all equal)
_ok-2                        359 ± 0%       359 ± 0%    ~     (all equal)
_invalidBody-2               435 ± 0%       435 ± 0%    ~     (all equal)

name                    old B:sent/op  new B:sent/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2                103 ± 0%       103 ± 0%    ~     (all equal)
_directGzipHead-2            104 ± 0%       104 ± 0%    ~     (all equal)
_noDirectGzip-2              117 ± 0%       117 ± 0%    ~     (all equal)
_directGzip_decode-2         116 ± 0%       116 ± 0%    ~     (all equal)
_noDirectGzip_decode-2       130 ± 0%       130 ± 0%    ~     (all equal)
_jsonBody-2                  188 ± 0%       188 ± 0%    ~     (all equal)
_jsonBodyValidation-2        192 ± 0%       192 ± 0%    ~     (all equal)
_outputHeaders-2            77.0 ± 0%      77.0 ± 0%    ~     (all equal)
_validation-2                170 ± 0%       170 ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2              74.0 ± 0%      74.0 ± 0%    ~     (all equal)
_ok-2                       74.0 ± 0%      74.0 ± 0%    ~     (all equal)
_invalidBody-2               137 ± 0%       137 ± 0%    ~     (all equal)

name                    old rps        new rps        delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2              25.8k ± 3%     26.6k ± 1%  +3.07%  (p=0.032 n=5+5)
_directGzipHead-2          25.1k ± 3%     26.5k ± 2%  +5.77%  (p=0.008 n=5+5)
_noDirectGzip-2            5.75k ± 2%     5.83k ± 2%    ~     (p=0.167 n=5+5)
_directGzip_decode-2       1.58k ± 5%     1.55k ± 5%    ~     (p=0.841 n=5+5)
_noDirectGzip_decode-2     5.79k ± 2%     5.85k ± 2%    ~     (p=0.222 n=5+5)
_jsonBody-2                14.8k ± 5%     15.1k ± 4%    ~     (p=0.222 n=5+5)
_jsonBodyValidation-2      13.4k ± 2%     13.0k ± 2%  -2.87%  (p=0.032 n=5+5)
_outputHeaders-2           27.1k ± 2%     27.0k ± 2%    ~     (p=1.000 n=5+5)
_validation-2              14.2k ± 3%     14.4k ± 2%    ~     (p=0.310 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2             23.3k ± 4%     24.1k ± 2%    ~     (p=0.310 n=5+5)
_ok-2                      23.0k ± 3%     22.2k ± 3%  -3.66%  (p=0.032 n=5+5)
_invalidBody-2             15.8k ± 3%     15.7k ± 3%    ~     (p=0.548 n=5+5)

name                    old alloc/op   new alloc/op   delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2             3.87kB ± 0%    3.87kB ± 0%    ~     (p=0.460 n=5+5)
_directGzipHead-2         3.87kB ± 0%    3.87kB ± 0%    ~     (p=0.119 n=5+5)
_noDirectGzip-2           6.23kB ±17%    6.28kB ±22%    ~     (p=0.841 n=5+5)
_directGzip_decode-2       403kB ± 0%     403kB ± 0%    ~     (p=0.690 n=5+5)
_noDirectGzip_decode-2    5.31kB ±10%    5.13kB ± 7%    ~     (p=0.460 n=5+5)
_jsonBody-2               11.7kB ± 0%    11.7kB ± 0%    ~     (p=0.460 n=5+5)
_jsonBodyValidation-2     18.2kB ± 0%    18.2kB ± 0%    ~     (p=0.087 n=5+5)
_outputHeaders-2          3.65kB ± 0%    3.65kB ± 0%    ~     (p=0.841 n=5+5)
_validation-2             16.2kB ± 0%    16.2kB ± 0%    ~     (p=0.452 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2            4.82kB ± 0%    4.82kB ± 0%    ~     (p=0.770 n=5+5)
_ok-2                     4.73kB ± 0%    4.73kB ± 0%    ~     (p=0.886 n=4+4)
_invalidBody-2            8.68kB ± 4%    8.73kB ± 4%    ~     (p=0.310 n=5+5)

name                    old allocs/op  new allocs/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2               40.0 ± 0%      40.0 ± 0%    ~     (all equal)
_directGzipHead-2           40.0 ± 0%      40.0 ± 0%    ~     (all equal)
_noDirectGzip-2             48.0 ± 4%      47.8 ± 4%    ~     (p=1.000 n=5+5)
_directGzip_decode-2         498 ± 0%       498 ± 0%    ~     (all equal)
_noDirectGzip_decode-2      48.0 ± 0%      48.0 ± 0%    ~     (all equal)
_jsonBody-2                  103 ± 0%       103 ± 0%    ~     (all equal)
_jsonBodyValidation-2        144 ± 0%       144 ± 0%    ~     (all equal)
_outputHeaders-2            35.0 ± 0%      35.0 ± 0%    ~     (all equal)
_validation-2                131 ± 0%       131 ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2              52.0 ± 0%      52.0 ± 0%    ~     (all equal)
_ok-2                       48.0 ± 0%      48.0 ± 0%    ~     (all equal)
_invalidBody-2              98.0 ± 0%      99.0 ± 0%  +1.02%  (p=0.029 n=4+4)

@vearutop vearutop merged commit 9adf73f into master Jun 28, 2021
@vearutop vearutop deleted the decode-err branch June 28, 2021 12:19
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.

1 participant