pubnub / go

PubNub clients for Go
Other
102 stars 62 forks source link

Close body and idle connections #126

Closed kleewho closed 2 years ago

kleewho commented 2 years ago

The image is the proof for the fix. On the left a goroutine analysis after the fix, on the right before. Test is the same

func TestGrantTokenForTrace(t *testing.T) {
    println(strconv.Itoa(runtime.NumGoroutine()))
    for i := 0; i < 10; i++ {

        token, err := GenerateGrantToken(strconv.Itoa(i))
        if err == nil {
            t.Fail()
        }
        println(token)
        println(strconv.Itoa(runtime.NumGoroutine()))
    }
}

GenerateGrantToken is making one grant token call, and then destroys the PubNub client. The whole test takes around 10-12s and as you see on the right one of the readLoop goroutines is living for the whole duration of it. Next one is a little younger and so on. On the left all of them have comparable life time.

image

codecov-commenter commented 2 years ago

Codecov Report

Merging #126 (4746aee) into master (ceb3da6) will decrease coverage by 3.00%. The diff coverage is 74.45%.

@@            Coverage Diff             @@
##           master     #126      +/-   ##
==========================================
- Coverage   80.84%   77.83%   -3.01%     
==========================================
  Files          62       73      +11     
  Lines        6953     8488    +1535     
==========================================
+ Hits         5621     6607     +986     
- Misses       1156     1641     +485     
- Partials      176      240      +64     
Impacted Files Coverage Δ
remove_all_push_channels_request.go 67.85% <ø> (-0.90%) :arrow_down:
remove_channel_channel_group_request.go 86.66% <ø> (-2.07%) :arrow_down:
remove_channels_from_push_request.go 77.41% <ø> (-1.24%) :arrow_down:
request.go 80.92% <ø> (-0.62%) :arrow_down:
request_workers.go 80.85% <ø> (ø)
revoke_token.go 47.29% <ø> (ø)
set_state_request.go 86.44% <ø> (-1.28%) :arrow_down:
signal_request.go 72.64% <ø> (-0.81%) :arrow_down:
subscribe_request.go 74.44% <ø> (-1.14%) :arrow_down:
subscription_manager.go 74.92% <ø> (-0.82%) :arrow_down:
... and 71 more

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 ecbfcda...4746aee. Read the comment docs.