diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-04-11 00:21:02 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-04-11 00:21:02 +0200 |
| commit | 30984e9e686cc1dc2bede6784a2534371b02219d (patch) | |
| tree | 2dc7f52977e14b7ab5870215071ac74d7557e51b | |
| parent | 2607d3f7d6f2a831e15aeb25f0e258b5887ed531 (diff) | |
| download | go-oblast-30984e9e686cc1dc2bede6784a2534371b02219d.tar.gz | |
say no to ctx
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r-- | benchmark/benchmark_test.go | 4 | ||||
| -rw-r--r-- | query.go | 3 |
3 files changed, 10 insertions, 4 deletions
@@ -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) } @@ -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 |
