From 30984e9e686cc1dc2bede6784a2534371b02219d Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sat, 11 Apr 2026 00:21:02 +0200 Subject: say no to ctx --- README.md | 7 +++++++ benchmark/benchmark_test.go | 4 ++-- query.go | 3 +-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 28d357c..4494b49 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,10 @@ SPDX-License-Identifier: Apache-2.0 # Oblast My attempt at an ORM library for Go. Inspired by [Gorp](https://pkg.go.dev/gopkg.in/gorp.v3), but without the bits that make Gorp slow. + +## Unstructured notes + +TODO: write out a proper readme + +- goals: as fast as possible, as little allocs on hot paths as possible +- consequences: no `context.Context` (benchmarking shows up to 50% more allocations and 100% more memory allocated in OLTP usecase, i.e. QueryRow vs. QueryRowContext) diff --git a/benchmark/benchmark_test.go b/benchmark/benchmark_test.go index c08361e..9c0c326 100644 --- a/benchmark/benchmark_test.go +++ b/benchmark/benchmark_test.go @@ -54,10 +54,10 @@ func BenchmarkSelect(b *testing.B) { ID int `db:"id"` Message string `db:"message"` } - query := `SELECT * FROM entries WHERE id < ` + strconv.Itoa(selectedRecordCount) + query := `SELECT * FROM entries WHERE id < ` + strconv.Itoa(selectedRecordCount) //nolint:gosec selectWithOblast := func(b *testing.B) { - records, err := oblast.Select[record](b.Context(), odb, query) + records, err := oblast.Select[record](odb, query) if err != nil { b.Error(err) } diff --git a/query.go b/query.go index 94dc17b..95c1f59 100644 --- a/query.go +++ b/query.go @@ -4,12 +4,11 @@ package oblast import ( - "context" "fmt" "reflect" ) -func Select[T any](ctx context.Context, db *DB, query string, args ...any) ([]T, error) { +func Select[T any](db *DB, query string, args ...any) ([]T, error) { // TODO: minimize function body to avoid binary size blowup from monomorphization // TODO: catch error from rows.Close(), if any // TODO: add context to errors -- cgit v1.2.3