snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s

This commit is contained in:
upstream-mirror
2026-09-18 01:22:23 +05:00
commit 7e385fc126
8391 changed files with 1766236 additions and 0 deletions

27
server/vendor/github.com/ngrok/sqlmw/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof
# IDEs
.idea

3
server/vendor/github.com/ngrok/sqlmw/.golangci.yml generated vendored Normal file
View File

@@ -0,0 +1,3 @@
issues:
exclude:
- "SA1019: .* has been deprecated since Go 1.*: Drivers should implement .*"

23
server/vendor/github.com/ngrok/sqlmw/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,23 @@
MIT License
Copyright (c) 2017 Expansive Worlds
Copyright (c) 2017 Avalanche Studios
Copyright (c) 2020 Alan Shreve
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

158
server/vendor/github.com/ngrok/sqlmw/README.md generated vendored Normal file
View File

@@ -0,0 +1,158 @@
[![GoDoc](https://godoc.org/github.com/ngrok/sqlmw?status.svg)](https://godoc.org/github.com/ngrok/sqlmw)
# sqlmw
sqlmw provides an absurdly simple API that allows a caller to wrap a `database/sql` driver
with middleware.
This provides an abstraction similar to http middleware or GRPC interceptors but for the database/sql package.
This allows a caller to implement observability like tracing and logging easily. More importantly, it also enables
powerful possible behaviors like transparently modifying arguments, results or query execution strategy. This power allows programmers to implement
functionality like automatic sharding, selective tracing, automatic caching, transparent query mirroring, retries, fail-over
in a reuseable way, and more.
## Usage
- Define a new type and embed the `sqlmw.NullInterceptor` type.
- Add a method you want to intercept from the `sqlmw.Interceptor` interface.
- Wrap the driver with your interceptor with `sqlmw.Driver` and then install it with `sql.Register`.
- Use `sql.Open` on the new driver string that was passed to register.
Here's a complete example:
```go
func run(dsn string) {
// install the wrapped driver
sql.Register("postgres-mw", sqlmw.Driver(pq.Driver{}, new(sqlInterceptor)))
db, err := sql.Open("postgres-mw", dsn)
...
}
type sqlInterceptor struct {
sqlmw.NullInterceptor
}
func (in *sqlInterceptor) StmtQueryContext(ctx context.Context, conn driver.StmtQueryContext, query string, args []driver.NamedValue) (driver.Rows, error) {
startedAt := time.Now()
rows, err := conn.QueryContext(ctx, args)
log.Debug("executed sql query", "duration", time.Since(startedAt), "query", query, "args", args, "err", err)
return rows, err
}
```
You may override any subset of methods to intercept in the `Interceptor` interface (https://godoc.org/github.com/ngrok/sqlmw#Interceptor):
```go
type Interceptor interface {
// Connection interceptors
ConnBeginTx(context.Context, driver.ConnBeginTx, driver.TxOptions) (driver.Tx, error)
ConnPrepareContext(context.Context, driver.ConnPrepareContext, string) (driver.Stmt, error)
ConnPing(context.Context, driver.Pinger) error
ConnExecContext(context.Context, driver.ExecerContext, string, []driver.NamedValue) (driver.Result, error)
ConnQueryContext(context.Context, driver.QueryerContext, string, []driver.NamedValue) (driver.Rows, error)
// Connector interceptors
ConnectorConnect(context.Context, driver.Connector) (driver.Conn, error)
// Results interceptors
ResultLastInsertId(driver.Result) (int64, error)
ResultRowsAffected(driver.Result) (int64, error)
// Rows interceptors
RowsNext(context.Context, driver.Rows, []driver.Value) error
// Stmt interceptors
StmtExecContext(context.Context, driver.StmtExecContext, string, []driver.NamedValue) (driver.Result, error)
StmtQueryContext(context.Context, driver.StmtQueryContext, string, []driver.NamedValue) (driver.Rows, error)
StmtClose(context.Context, driver.Stmt) error
// Tx interceptors
TxCommit(context.Context, driver.Tx) error
TxRollback(context.Context, driver.Tx) error
}
```
Bear in mind that because you are intercepting the calls entirely, that you are responsible for passing control up to the wrapped
driver in any function that you override, like so:
```go
func (in *sqlInterceptor) ConnPing(ctx context.Context, conn driver.Pinger) error {
return conn.Ping(ctx)
}
```
## Examples
### Logging
```go
func (in *sqlInterceptor) StmtQueryContext(ctx context.Context, conn driver.StmtQueryContext, query string, args []driver.NamedValue) (driver.Rows, error) {
startedAt := time.Now()
rows, err := conn.QueryContext(ctx, args)
log.Debug("executed sql query", "duration", time.Since(startedAt), "query", query, "args", args, "err", err)
return rows, err
}
```
### Tracing
```go
func (in *sqlInterceptor) StmtQueryContext(ctx context.Context, conn driver.StmtQueryContext, query string, args []driver.NamedValue) (driver.Rows, error) {
span := trace.FromContext(ctx).NewSpan(ctx, "StmtQueryContext")
span.Tags["query"] = query
defer span.Finish()
rows, err := conn.QueryContext(ctx, args)
if err != nil {
span.Error(err)
}
return rows, err
}
```
### Retries
```go
func (in *sqlInterceptor) StmtQueryContext(ctx context.Context, conn driver.StmtQueryContext, query string, args []driver.NamedValue) (driver.Rows, error) {
for {
rows, err := conn.QueryContext(ctx, args)
if err == nil {
return rows, nil
}
if err != nil && !isIdempotent(query) {
return nil, err
}
select {
case <-ctx.Done():
return nil, ctx.Err()
case <-time.After(time.Second):
}
}
}
```
## Comparison with similar projects
There are a number of other packages that allow the programmer to wrap a `database/sql/driver.Driver` to add logging or tracing.
Examples of tracing packages:
- github.com/ExpansiveWorlds/instrumentedsql
- contrib.go.opencensus.io/integrations/ocsql
- gopkg.in/DataDog/dd-trace-go.v1/contrib/database/sql
A few provide a much more flexible setup of arbitrary before/after hooks to facilitate custom observability.
Packages that provide before/after hooks:
- github.com/gchaincl/sqlhooks
- github.com/shogo82148/go-sql-proxy
None of these packages provide an interface with sufficient power. `sqlmw` passes control of executing the
sql query to the caller which allows the caller to completely disintermediate the sql calls. This is what provides
the power to implement advanced behaviors like caching, sharding, retries, etc.
## Go version support
Go versions 1.9 and forward are supported.
## Fork
This project began by forking the code in github.com/luna-duclos/instrumentedsql, which itself is a fork of github.com/ExpansiveWorlds/instrumentedsql

181
server/vendor/github.com/ngrok/sqlmw/conn.go generated vendored Normal file
View File

@@ -0,0 +1,181 @@
package sqlmw
import (
"context"
"database/sql/driver"
)
type wrappedConn struct {
intr Interceptor
parent driver.Conn
}
// Compile time validation that our types implement the expected interfaces
var (
_ driver.Conn = wrappedConn{}
_ driver.ConnBeginTx = wrappedConn{}
_ driver.ConnPrepareContext = wrappedConn{}
_ driver.Execer = wrappedConn{}
_ driver.ExecerContext = wrappedConn{}
_ driver.Pinger = wrappedConn{}
_ driver.Queryer = wrappedConn{}
_ driver.QueryerContext = wrappedConn{}
)
func (c wrappedConn) Prepare(query string) (driver.Stmt, error) {
stmt, err := c.parent.Prepare(query)
if err != nil {
return nil, err
}
return wrappedStmt{intr: c.intr, query: query, parent: stmt, conn: c}, nil
}
func (c wrappedConn) Close() error {
return c.parent.Close()
}
func (c wrappedConn) Begin() (driver.Tx, error) {
tx, err := c.parent.Begin()
if err != nil {
return nil, err
}
return wrappedTx{intr: c.intr, parent: tx}, nil
}
func (c wrappedConn) BeginTx(ctx context.Context, opts driver.TxOptions) (tx driver.Tx, err error) {
wrappedParent := wrappedParentConn{c.parent}
tx, err = c.intr.ConnBeginTx(ctx, wrappedParent, opts)
if err != nil {
return nil, err
}
return wrappedTx{intr: c.intr, ctx: ctx, parent: tx}, nil
}
func (c wrappedConn) PrepareContext(ctx context.Context, query string) (stmt driver.Stmt, err error) {
wrappedParent := wrappedParentConn{c.parent}
stmt, err = c.intr.ConnPrepareContext(ctx, wrappedParent, query)
if err != nil {
return nil, err
}
return wrappedStmt{intr: c.intr, ctx: ctx, query: query, parent: stmt, conn: c}, nil
}
func (c wrappedConn) Exec(query string, args []driver.Value) (driver.Result, error) {
if execer, ok := c.parent.(driver.Execer); ok {
res, err := execer.Exec(query, args)
if err != nil {
return nil, err
}
return wrappedResult{intr: c.intr, parent: res}, nil
}
return nil, driver.ErrSkip
}
func (c wrappedConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (r driver.Result, err error) {
wrappedParent := wrappedParentConn{c.parent}
r, err = c.intr.ConnExecContext(ctx, wrappedParent, query, args)
if err != nil {
return nil, err
}
return wrappedResult{intr: c.intr, ctx: ctx, parent: r}, nil
}
func (c wrappedConn) Ping(ctx context.Context) (err error) {
if pinger, ok := c.parent.(driver.Pinger); ok {
return c.intr.ConnPing(ctx, pinger)
}
return nil
}
func (c wrappedConn) Query(query string, args []driver.Value) (driver.Rows, error) {
if queryer, ok := c.parent.(driver.Queryer); ok {
rows, err := queryer.Query(query, args)
if err != nil {
return nil, err
}
return wrapRows(context.Background(), c.intr, rows), nil //nolint
}
return nil, driver.ErrSkip
}
func (c wrappedConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (rows driver.Rows, err error) {
// Quick skip path: If the wrapped connection implements neither QueryerContext nor Queryer, we have absolutely nothing to do
_, hasQueryerContext := c.parent.(driver.QueryerContext)
_, hasQueryer := c.parent.(driver.Queryer)
if !hasQueryerContext && !hasQueryer {
return nil, driver.ErrSkip
}
wrappedParent := wrappedParentConn{c.parent}
rows, err = c.intr.ConnQueryContext(ctx, wrappedParent, query, args)
if err != nil {
return nil, err
}
return wrapRows(ctx, c.intr, rows), nil
}
type wrappedParentConn struct {
driver.Conn
}
func (c wrappedParentConn) BeginTx(ctx context.Context, opts driver.TxOptions) (tx driver.Tx, err error) {
if connBeginTx, ok := c.Conn.(driver.ConnBeginTx); ok {
return connBeginTx.BeginTx(ctx, opts)
}
// Fallback implementation
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
return c.Conn.Begin()
}
}
func (c wrappedParentConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
if connPrepareCtx, ok := c.Conn.(driver.ConnPrepareContext); ok {
return connPrepareCtx.PrepareContext(ctx, query)
}
// Fallback implementation
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
return c.Conn.Prepare(query)
}
}
func (c wrappedParentConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (r driver.Result, err error) {
if execContext, ok := c.Conn.(driver.ExecerContext); ok {
return execContext.ExecContext(ctx, query, args)
}
// Fallback implementation
dargs, err := namedValueToValue(args)
if err != nil {
return nil, err
}
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
return c.Conn.(driver.Execer).Exec(query, dargs)
}
}
func (c wrappedParentConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (rows driver.Rows, err error) {
if queryerContext, ok := c.Conn.(driver.QueryerContext); ok {
return queryerContext.QueryContext(ctx, query, args)
}
// Fallback implementation
dargs, err := namedValueToValue(args)
if err != nil {
return nil, err
}
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
return c.Conn.(driver.Queryer).Query(query, dargs)
}
}

19
server/vendor/github.com/ngrok/sqlmw/conn_go110.go generated vendored Normal file
View File

@@ -0,0 +1,19 @@
// +build go1.10
package sqlmw
import (
"context"
"database/sql/driver"
)
var _ driver.SessionResetter = wrappedConn{}
func (c wrappedConn) ResetSession(ctx context.Context) error {
conn, ok := c.parent.(driver.SessionResetter)
if !ok {
return nil
}
return conn.ResetSession(ctx)
}

19
server/vendor/github.com/ngrok/sqlmw/conn_go115.go generated vendored Normal file
View File

@@ -0,0 +1,19 @@
// +build go1.15
package sqlmw
import (
"database/sql/driver"
)
var _ driver.SessionResetter = wrappedConn{}
func (c wrappedConn) IsValid() bool {
conn, ok := c.parent.(driver.Validator)
if !ok {
// the default if driver.Validator is not supported
return true
}
return conn.IsValid()
}

22
server/vendor/github.com/ngrok/sqlmw/conn_go19.go generated vendored Normal file
View File

@@ -0,0 +1,22 @@
// +build go1.9
package sqlmw
import "database/sql/driver"
var (
_ driver.NamedValueChecker = wrappedConn{}
)
func defaultCheckNamedValue(nv *driver.NamedValue) (err error) {
nv.Value, err = driver.DefaultParameterConverter.ConvertValue(nv.Value)
return err
}
func (c wrappedConn) CheckNamedValue(v *driver.NamedValue) error {
if checker, ok := c.parent.(driver.NamedValueChecker); ok {
return checker.CheckNamedValue(v)
}
return defaultCheckNamedValue(v)
}

45
server/vendor/github.com/ngrok/sqlmw/connector.go generated vendored Normal file
View File

@@ -0,0 +1,45 @@
// +build go1.10
package sqlmw
import (
"context"
"database/sql/driver"
)
type wrappedConnector struct {
parent driver.Connector
driverRef *wrappedDriver
}
var (
_ driver.Connector = wrappedConnector{}
)
func (c wrappedConnector) Connect(ctx context.Context) (conn driver.Conn, err error) {
conn, err = c.driverRef.intr.ConnectorConnect(ctx, c.parent)
if err != nil {
return nil, err
}
return wrappedConn{intr: c.driverRef.intr, parent: conn}, nil
}
func (c wrappedConnector) Driver() driver.Driver {
return c.driverRef
}
// dsnConnector is a fallback connector placed in position of wrappedConnector.parent
// when given Driver does not comply with DriverContext interface.
type dsnConnector struct {
dsn string
driver driver.Driver
}
func (t dsnConnector) Connect(_ context.Context) (driver.Conn, error) {
return t.driver.Open(t.dsn)
}
func (t dsnConnector) Driver() driver.Driver {
return t.driver
}

4
server/vendor/github.com/ngrok/sqlmw/contributors generated vendored Normal file
View File

@@ -0,0 +1,4 @@
Luna Duclos
Dominik Honnef
Daniel Cormier
Alan Shreve

38
server/vendor/github.com/ngrok/sqlmw/driver.go generated vendored Normal file
View File

@@ -0,0 +1,38 @@
package sqlmw
import "database/sql/driver"
// driver wraps a sql.Driver with an interceptor.
type wrappedDriver struct {
intr Interceptor
parent driver.Driver
}
// Compile time validation that our types implement the expected interfaces
var (
_ driver.Driver = wrappedDriver{}
)
// WrapDriver will wrap the passed SQL driver and return a new sql driver that uses it and also logs and traces calls using the passed logger and tracer
// The returned driver will still have to be registered with the sql package before it can be used.
//
// Driver returns the supplied driver.Driver with a new object that has all of its calls intercepted by the supplied
// Interceptor object.
//
// Important note: Seeing as the context passed into the various instrumentation calls this package calls,
// Any call without a context passed will not be intercepted. Please be sure to use the ___Context() and BeginTx()
// function calls added in Go 1.8 instead of the older calls which do not accept a context.
func Driver(driver driver.Driver, intr Interceptor) driver.Driver {
return wrappedDriver{parent: driver, intr: intr}
}
// Open implements the database/sql/driver.Driver interface for WrappedDriver.
func (d wrappedDriver) Open(name string) (driver.Conn, error) {
conn, err := d.parent.Open(name)
if err != nil {
return nil, err
}
return wrappedConn{intr: d.intr, parent: conn}, nil
}

23
server/vendor/github.com/ngrok/sqlmw/driver_go110.go generated vendored Normal file
View File

@@ -0,0 +1,23 @@
// +build go1.10
package sqlmw
import "database/sql/driver"
var _ driver.DriverContext = wrappedDriver{}
func (d wrappedDriver) OpenConnector(name string) (driver.Connector, error) {
driver, ok := d.parent.(driver.DriverContext)
if !ok {
return wrappedConnector{
parent: dsnConnector{dsn: name, driver: d.parent},
driverRef: &d,
}, nil
}
conn, err := driver.OpenConnector(name)
if err != nil {
return nil, err
}
return wrappedConnector{parent: conn, driverRef: &d}, nil
}

18
server/vendor/github.com/ngrok/sqlmw/helpers.go generated vendored Normal file
View File

@@ -0,0 +1,18 @@
package sqlmw
import (
"database/sql/driver"
"errors"
)
// namedValueToValue is a helper function copied from the database/sql package
func namedValueToValue(named []driver.NamedValue) ([]driver.Value, error) {
dargs := make([]driver.Value, len(named))
for n, param := range named {
if len(param.Name) > 0 {
return nil, errors.New("sql: driver does not support the use of Named Parameters")
}
dargs[n] = param.Value
}
return dargs, nil
}

102
server/vendor/github.com/ngrok/sqlmw/interceptor.go generated vendored Normal file
View File

@@ -0,0 +1,102 @@
package sqlmw
import (
"context"
"database/sql/driver"
)
type Interceptor interface {
// Connection interceptors
ConnBeginTx(context.Context, driver.ConnBeginTx, driver.TxOptions) (driver.Tx, error)
ConnPrepareContext(context.Context, driver.ConnPrepareContext, string) (driver.Stmt, error)
ConnPing(context.Context, driver.Pinger) error
ConnExecContext(context.Context, driver.ExecerContext, string, []driver.NamedValue) (driver.Result, error)
ConnQueryContext(context.Context, driver.QueryerContext, string, []driver.NamedValue) (driver.Rows, error)
// Connector interceptors
ConnectorConnect(context.Context, driver.Connector) (driver.Conn, error)
// Results interceptors
ResultLastInsertId(driver.Result) (int64, error)
ResultRowsAffected(driver.Result) (int64, error)
// Rows interceptors
RowsNext(context.Context, driver.Rows, []driver.Value) error
RowsClose(context.Context, driver.Rows) error
// Stmt interceptors
StmtExecContext(context.Context, driver.StmtExecContext, string, []driver.NamedValue) (driver.Result, error)
StmtQueryContext(context.Context, driver.StmtQueryContext, string, []driver.NamedValue) (driver.Rows, error)
StmtClose(context.Context, driver.Stmt) error
// Tx interceptors
TxCommit(context.Context, driver.Tx) error
TxRollback(context.Context, driver.Tx) error
}
var _ Interceptor = NullInterceptor{}
// NullInterceptor is a complete passthrough interceptor that implements every method of the Interceptor
// interface and performs no additional logic. Users should Embed it in their own interceptor so that they
// only need to define the specific functions they are interested in intercepting.
type NullInterceptor struct{}
func (NullInterceptor) ConnBeginTx(ctx context.Context, conn driver.ConnBeginTx, txOpts driver.TxOptions) (driver.Tx, error) {
return conn.BeginTx(ctx, txOpts)
}
func (NullInterceptor) ConnPrepareContext(ctx context.Context, conn driver.ConnPrepareContext, query string) (driver.Stmt, error) {
return conn.PrepareContext(ctx, query)
}
func (NullInterceptor) ConnPing(ctx context.Context, conn driver.Pinger) error {
return conn.Ping(ctx)
}
func (NullInterceptor) ConnExecContext(ctx context.Context, conn driver.ExecerContext, query string, args []driver.NamedValue) (driver.Result, error) {
return conn.ExecContext(ctx, query, args)
}
func (NullInterceptor) ConnQueryContext(ctx context.Context, conn driver.QueryerContext, query string, args []driver.NamedValue) (driver.Rows, error) {
return conn.QueryContext(ctx, query, args)
}
func (NullInterceptor) ConnectorConnect(ctx context.Context, connect driver.Connector) (driver.Conn, error) {
return connect.Connect(ctx)
}
func (NullInterceptor) ResultLastInsertId(res driver.Result) (int64, error) {
return res.LastInsertId()
}
func (NullInterceptor) ResultRowsAffected(res driver.Result) (int64, error) {
return res.RowsAffected()
}
func (NullInterceptor) RowsNext(ctx context.Context, rows driver.Rows, dest []driver.Value) error {
return rows.Next(dest)
}
func (NullInterceptor) RowsClose(ctx context.Context, rows driver.Rows) error {
return rows.Close()
}
func (NullInterceptor) StmtExecContext(ctx context.Context, stmt driver.StmtExecContext, _ string, args []driver.NamedValue) (driver.Result, error) {
return stmt.ExecContext(ctx, args)
}
func (NullInterceptor) StmtQueryContext(ctx context.Context, stmt driver.StmtQueryContext, _ string, args []driver.NamedValue) (driver.Rows, error) {
return stmt.QueryContext(ctx, args)
}
func (NullInterceptor) StmtClose(ctx context.Context, stmt driver.Stmt) error {
return stmt.Close()
}
func (NullInterceptor) TxCommit(ctx context.Context, tx driver.Tx) error {
return tx.Commit()
}
func (NullInterceptor) TxRollback(ctx context.Context, tx driver.Tx) error {
return tx.Rollback()
}

20
server/vendor/github.com/ngrok/sqlmw/result.go generated vendored Normal file
View File

@@ -0,0 +1,20 @@
package sqlmw
import (
"context"
"database/sql/driver"
)
type wrappedResult struct {
intr Interceptor
ctx context.Context
parent driver.Result
}
func (r wrappedResult) LastInsertId() (id int64, err error) {
return r.intr.ResultLastInsertId(r.parent)
}
func (r wrappedResult) RowsAffected() (num int64, err error) {
return r.intr.ResultRowsAffected(r.parent)
}

97
server/vendor/github.com/ngrok/sqlmw/rows.go generated vendored Normal file
View File

@@ -0,0 +1,97 @@
package sqlmw
import (
"context"
"database/sql/driver"
"reflect"
)
//go:generate go run ./tools/rows_picker_gen.go -o rows_picker.go
// RowsUnwrapper must be used by any middleware that provides its own wrapping
// for driver.Rows. Unwrap should return the original driver.Rows the
// middleware received. You may wish to wrap the driver.Rows returned by the
// Query methods if you want to pass extra information from the Query call to
// the subsequent RowsNext and RowsClose calls.
//
// sqlmw needs to retrieve the original driver.Rows in order to determine the
// original set of optional methods supported by the driver.Rows of the
// database driver in use by the caller.
//
// If a middleware returns a custom driver.Rows, the custom implmentation
// must support all the driver.Rows optional interfaces that are supported by
// by the drivers that will be used with it. To support any arbitrary driver
// all the optional methods must be supported.
type RowsUnwrapper interface {
Unwrap() driver.Rows
}
type wrappedRows struct {
intr Interceptor
ctx context.Context
parent driver.Rows
}
func (r wrappedRows) Columns() []string {
return r.parent.Columns()
}
func (r wrappedRows) Close() error {
return r.intr.RowsClose(r.ctx, r.parent)
}
func (r wrappedRows) Next(dest []driver.Value) (err error) {
return r.intr.RowsNext(r.ctx, r.parent, dest)
}
type wrappedRowsNextResultSet struct {
rows driver.Rows
}
func (r wrappedRowsNextResultSet) HasNextResultSet() bool {
return r.rows.(driver.RowsNextResultSet).HasNextResultSet()
}
func (r wrappedRowsNextResultSet) NextResultSet() error {
return r.rows.(driver.RowsNextResultSet).NextResultSet()
}
type wrappedRowsColumnTypeDatabaseTypeName struct {
rows driver.Rows
}
func (r wrappedRowsColumnTypeDatabaseTypeName) ColumnTypeDatabaseTypeName(index int) string {
return r.rows.(driver.RowsColumnTypeDatabaseTypeName).ColumnTypeDatabaseTypeName(index)
}
type wrappedRowsColumnTypeLength struct {
rows driver.Rows
}
func (r wrappedRowsColumnTypeLength) ColumnTypeLength(index int) (length int64, ok bool) {
return r.rows.(driver.RowsColumnTypeLength).ColumnTypeLength(index)
}
type wrappedRowsColumnTypeNullable struct {
rows driver.Rows
}
func (r wrappedRowsColumnTypeNullable) ColumnTypeNullable(index int) (nullable, ok bool) {
return r.rows.(driver.RowsColumnTypeNullable).ColumnTypeNullable(index)
}
type wrappedRowsColumnTypePrecisionScale struct {
rows driver.Rows
}
func (r wrappedRowsColumnTypePrecisionScale) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) {
return r.rows.(driver.RowsColumnTypePrecisionScale).ColumnTypePrecisionScale(index)
}
type wrappedRowsColumnTypeScanType struct {
rows driver.Rows
}
func (r wrappedRowsColumnTypeScanType) ColumnTypeScanType(index int) reflect.Type {
return r.rows.(driver.RowsColumnTypeScanType).ColumnTypeScanType(index)
}

1017
server/vendor/github.com/ngrok/sqlmw/rows_picker.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

110
server/vendor/github.com/ngrok/sqlmw/stmt.go generated vendored Normal file
View File

@@ -0,0 +1,110 @@
package sqlmw
import (
"context"
"database/sql/driver"
)
type wrappedStmt struct {
intr Interceptor
ctx context.Context
query string
parent driver.Stmt
conn wrappedConn
}
// Compile time validation that our types implement the expected interfaces
var (
_ driver.Stmt = wrappedStmt{}
_ driver.StmtExecContext = wrappedStmt{}
_ driver.StmtQueryContext = wrappedStmt{}
_ driver.ColumnConverter = wrappedStmt{}
)
func (s wrappedStmt) Close() (err error) {
return s.intr.StmtClose(s.ctx, s.parent)
}
func (s wrappedStmt) NumInput() int {
return s.parent.NumInput()
}
func (s wrappedStmt) Exec(args []driver.Value) (res driver.Result, err error) {
res, err = s.parent.Exec(args)
if err != nil {
return nil, err
}
return wrappedResult{intr: s.intr, ctx: s.ctx, parent: res}, nil
}
func (s wrappedStmt) Query(args []driver.Value) (rows driver.Rows, err error) {
rows, err = s.parent.Query(args)
if err != nil {
return nil, err
}
return wrapRows(s.ctx, s.intr, rows), nil
}
func (s wrappedStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (res driver.Result, err error) {
wrappedParent := wrappedParentStmt{Stmt: s.parent}
res, err = s.intr.StmtExecContext(ctx, wrappedParent, s.query, args)
if err != nil {
return nil, err
}
return wrappedResult{intr: s.intr, ctx: ctx, parent: res}, nil
}
func (s wrappedStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (rows driver.Rows, err error) {
wrappedParent := wrappedParentStmt{Stmt: s.parent}
rows, err = s.intr.StmtQueryContext(ctx, wrappedParent, s.query, args)
if err != nil {
return nil, err
}
return wrapRows(ctx, s.intr, rows), nil
}
func (s wrappedStmt) ColumnConverter(idx int) driver.ValueConverter {
if converter, ok := s.parent.(driver.ColumnConverter); ok {
return converter.ColumnConverter(idx)
}
return driver.DefaultParameterConverter
}
type wrappedParentStmt struct {
driver.Stmt
}
func (s wrappedParentStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (rows driver.Rows, err error) {
if stmtQueryContext, ok := s.Stmt.(driver.StmtQueryContext); ok {
return stmtQueryContext.QueryContext(ctx, args)
}
// Fallback implementation
dargs, err := namedValueToValue(args)
if err != nil {
return nil, err
}
select {
default:
case <-ctx.Done():
return nil, ctx.Err()
}
return s.Stmt.Query(dargs)
}
func (s wrappedParentStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (res driver.Result, err error) {
if stmtExecContext, ok := s.Stmt.(driver.StmtExecContext); ok {
return stmtExecContext.ExecContext(ctx, args)
}
// Fallback implementation
dargs, err := namedValueToValue(args)
if err != nil {
return nil, err
}
select {
default:
case <-ctx.Done():
return nil, ctx.Err()
}
return s.Stmt.Exec(dargs)
}

17
server/vendor/github.com/ngrok/sqlmw/stmt_go19.go generated vendored Normal file
View File

@@ -0,0 +1,17 @@
package sqlmw
import "database/sql/driver"
var _ driver.NamedValueChecker = wrappedStmt{}
func (s wrappedStmt) CheckNamedValue(v *driver.NamedValue) error {
if checker, ok := s.parent.(driver.NamedValueChecker); ok {
return checker.CheckNamedValue(v)
}
if checker, ok := s.conn.parent.(driver.NamedValueChecker); ok {
return checker.CheckNamedValue(v)
}
return defaultCheckNamedValue(v)
}

25
server/vendor/github.com/ngrok/sqlmw/tx.go generated vendored Normal file
View File

@@ -0,0 +1,25 @@
package sqlmw
import (
"context"
"database/sql/driver"
)
type wrappedTx struct {
intr Interceptor
ctx context.Context
parent driver.Tx
}
// Compile time validation that our types implement the expected interfaces
var (
_ driver.Tx = wrappedTx{}
)
func (t wrappedTx) Commit() (err error) {
return t.intr.TxCommit(t.ctx, t.parent)
}
func (t wrappedTx) Rollback() (err error) {
return t.intr.TxRollback(t.ctx, t.parent)
}