-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/flipt-io/flipt
* 'main' of https://github.com/flipt-io/flipt: chore(deps): bump golang.org/x/net from 0.22.0 to 0.23.0 in /sdk/go (#3006) chore(deps): bump golang.org/x/net from 0.22.0 to 0.23.0 in /core (#3005) chore: update changelog for v1.40.2 (#3020) refactor(storage): move from lib/pq to pgx (#2996) fix(cmd/grpc): skip eval data service when evaluation API auth excluded (#3018)
- Loading branch information
Showing
19 changed files
with
422 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ ignore: | |
- "rpc/flipt/flipt.pb.*" | ||
- "rpc/flipt/meta" | ||
- "ui" | ||
- "**/mock_*.go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package sql | ||
|
||
import ( | ||
"context" | ||
"database/sql/driver" | ||
"time" | ||
|
||
pgx "github.com/jackc/pgx/v5/stdlib" | ||
) | ||
|
||
const adaptedDriverOpenTimeout = 60 * time.Second | ||
|
||
// This is the wrapper around sql driver. By default, pgx driver returns connection | ||
// error with the host, username and password. `adaptedDriver` and `postgresConnector` | ||
// allow to customize errors and preventing leakage of the credentials to outside. | ||
func newAdaptedPostgresDriver(d Driver) driver.Driver { | ||
return &adaptedDriver{origin: &pgx.Driver{}, adapter: d} | ||
} | ||
|
||
var _ driver.Driver = (*adaptedDriver)(nil) | ||
var _ driver.DriverContext = (*adaptedDriver)(nil) | ||
|
||
type adaptedDriver struct { | ||
adapter Driver | ||
origin driver.DriverContext | ||
} | ||
|
||
func (d *adaptedDriver) Open(name string) (driver.Conn, error) { | ||
connector, err := d.OpenConnector(name) | ||
if err != nil { | ||
return nil, d.adapter.AdaptError(err) | ||
} | ||
ctx, cancel := context.WithTimeout(context.Background(), adaptedDriverOpenTimeout) | ||
defer cancel() | ||
return connector.Connect(ctx) | ||
} | ||
|
||
func (d *adaptedDriver) OpenConnector(name string) (driver.Connector, error) { | ||
connector, err := d.origin.OpenConnector(name) | ||
if err != nil { | ||
return nil, d.adapter.AdaptError(err) | ||
} | ||
return &adaptedConnector{origin: connector, driver: d, adapter: d.adapter}, nil | ||
} | ||
|
||
var _ driver.Connector = (*adaptedConnector)(nil) | ||
|
||
type adaptedConnector struct { | ||
origin driver.Connector | ||
driver driver.Driver | ||
adapter Driver | ||
} | ||
|
||
func (c *adaptedConnector) Driver() driver.Driver { | ||
return c.driver | ||
} | ||
|
||
func (c *adaptedConnector) Connect(ctx context.Context) (driver.Conn, error) { | ||
conn, err := c.origin.Connect(ctx) | ||
if err != nil { | ||
return nil, c.adapter.AdaptError(err) | ||
} | ||
return conn, nil | ||
} |
Oops, something went wrong.