Home / Function/ Benchmark_Client_Request_Send_ContextCancel() — fiber Function Reference

Benchmark_Client_Request_Send_ContextCancel() — fiber Function Reference

Architecture documentation for the Benchmark_Client_Request_Send_ContextCancel() function in client_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  8a2283e3_a1f4_e204_db28_cc1c156b61e1["Benchmark_Client_Request_Send_ContextCancel()"]
  5d11d0f7_2b3b_7bf3_3b1d_76d79d6872a2["client_test.go"]
  8a2283e3_a1f4_e204_db28_cc1c156b61e1 -->|defined in| 5d11d0f7_2b3b_7bf3_3b1d_76d79d6872a2
  style 8a2283e3_a1f4_e204_db28_cc1c156b61e1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

client/client_test.go lines 2303–2347

func Benchmark_Client_Request_Send_ContextCancel(b *testing.B) {
	app, ln, start := createHelperServer(b)

	startedCh := make(chan struct{})
	errCh := make(chan error)
	respCh := make(chan *Response)

	app.Post("/", func(c fiber.Ctx) error {
		startedCh <- struct{}{}
		time.Sleep(time.Millisecond) // let cancel be called
		return c.Status(fiber.StatusOK).SendString("post")
	})

	go start()

	client := New().SetDial(ln)

	b.ReportAllocs()
	b.ResetTimer()

	for b.Loop() {
		ctx, cancel := context.WithCancel(context.Background())

		req := AcquireRequest().
			SetClient(client).
			SetURL("http://example.com").
			SetMethod(fiber.MethodPost).
			SetContext(ctx)

		go func(r *Request) {
			defer ReleaseRequest(r)

			resp, err := r.Send()

			respCh <- resp
			errCh <- err
		}(req)

		<-startedCh // request is made, we can cancel the context now
		cancel()

		require.Nil(b, <-respCh)
		require.ErrorIs(b, <-errCh, ErrTimeoutOrCancel)
	}
}

Domain

Subdomains

Frequently Asked Questions

What does Benchmark_Client_Request_Send_ContextCancel() do?
Benchmark_Client_Request_Send_ContextCancel() is a function in the fiber codebase, defined in client/client_test.go.
Where is Benchmark_Client_Request_Send_ContextCancel() defined?
Benchmark_Client_Request_Send_ContextCancel() is defined in client/client_test.go at line 2303.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free