Benchmark_ShutdownServices_withContextCancellation() — fiber Function Reference
Architecture documentation for the Benchmark_ShutdownServices_withContextCancellation() function in services_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 988f1a43_97cc_e98a_0416_17ea786c4300["Benchmark_ShutdownServices_withContextCancellation()"] a3b050d2_f10a_df85_e082_e3ac664a6a6c["services_test.go"] 988f1a43_97cc_e98a_0416_17ea786c4300 -->|defined in| a3b050d2_f10a_df85_e082_e3ac664a6a6c style 988f1a43_97cc_e98a_0416_17ea786c4300 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
services_test.go lines 648–711
func Benchmark_ShutdownServices_withContextCancellation(b *testing.B) {
benchmarkFn := func(b *testing.B, services []Service, timeout time.Duration) {
b.Helper()
for b.Loop() {
app := New(Config{
Services: services,
})
err := app.startServices(context.Background())
if err != nil {
b.Fatal("Expected no error during startup but got", err)
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
err = app.shutdownServices(ctx)
// We expect an error here due to the short timeout
if err == nil && timeout < time.Second {
b.Fatal("Expected error due to context cancellation but got none")
}
cancel()
}
}
b.Run("single-service/immediate-cancellation", func(b *testing.B) {
benchmarkFn(b, []Service{
&mockService{name: "dep1", terminateDelay: 100 * time.Millisecond},
}, 10*time.Millisecond)
})
b.Run("multiple-services/immediate-cancellation", func(b *testing.B) {
benchmarkFn(b, []Service{
&mockService{name: "dep1", terminateDelay: 100 * time.Millisecond},
&mockService{name: "dep2", terminateDelay: 200 * time.Millisecond},
&mockService{name: "dep3", terminateDelay: 300 * time.Millisecond},
}, 10*time.Millisecond)
})
b.Run("multiple-services/successful-completion", func(b *testing.B) {
const timeout = 500 * time.Millisecond
for b.Loop() {
app := New(Config{
Services: []Service{
&mockService{name: "dep1", terminateDelay: 10 * time.Millisecond},
&mockService{name: "dep2", terminateDelay: 20 * time.Millisecond},
&mockService{name: "dep3", terminateDelay: 30 * time.Millisecond},
},
})
err := app.startServices(context.Background())
if err != nil {
b.Fatal("Expected no error but got", err)
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
err = app.shutdownServices(ctx)
if err != nil {
b.Fatal("Expected no error but got", err)
}
cancel()
}
})
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Benchmark_ShutdownServices_withContextCancellation() do?
Benchmark_ShutdownServices_withContextCancellation() is a function in the fiber codebase, defined in services_test.go.
Where is Benchmark_ShutdownServices_withContextCancellation() defined?
Benchmark_ShutdownServices_withContextCancellation() is defined in services_test.go at line 648.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free