Query timeout
A deadline on one database call, set with context.WithTimeout from the request context. When it passes, the driver cancels the query and the error wraps context.DeadlineExceeded. Reads in this course get 500 ms.
Minimal example
ctx, cancel := context.WithTimeout(r.Context(), 500*time.Millisecond)
defer cancel()Learn this concept
Lesson 2.4 · database/sql: pools, contexts and timeoutsUsed in exercises
Exercise 2.10 · GET /v1/restaurants with a cursor Exercise 2.24 · GET /v1/restaurants: search by name Exercise 6.6 · Request context and timeout layerPrerequisite conceptsdatabase/sql
RelatedConnection pool