From 2af5d53faf36af263ad859df94e786062f2084a3 Mon Sep 17 00:00:00 2001 From: Garet Halliday <me@garet.holiday> Date: Wed, 6 Sep 2023 16:53:19 -0500 Subject: [PATCH] . --- lib/gat/modes/pgbouncer/pools.go | 8 ++++---- lib/gat/pool/recipe.go | 4 +++- lib/gat/pool/{ => recipe}/dialer/dialer.go | 0 lib/gat/pool/{ => recipe}/dialer/net.go | 0 lib/gat/pool/recipe/options.go | 13 +++++++++++++ lib/gat/pool/recipe/recipe.go | 15 +++++++++++++++ lib/gat/pool/recipe/server.go | 4 ++++ 7 files changed, 39 insertions(+), 5 deletions(-) rename lib/gat/pool/{ => recipe}/dialer/dialer.go (100%) rename lib/gat/pool/{ => recipe}/dialer/net.go (100%) create mode 100644 lib/gat/pool/recipe/options.go create mode 100644 lib/gat/pool/recipe/recipe.go create mode 100644 lib/gat/pool/recipe/server.go diff --git a/lib/gat/modes/pgbouncer/pools.go b/lib/gat/modes/pgbouncer/pools.go index 5ecc862b..db7858cb 100644 --- a/lib/gat/modes/pgbouncer/pools.go +++ b/lib/gat/modes/pgbouncer/pools.go @@ -15,9 +15,9 @@ import ( "pggat2/lib/bouncer/frontends/v0" "pggat2/lib/gat" "pggat2/lib/gat/pool" - "pggat2/lib/gat/pool/dialer" "pggat2/lib/gat/pool/pools/session" "pggat2/lib/gat/pool/pools/transaction" + dialer2 "pggat2/lib/gat/pool/recipe/dialer" "pggat2/lib/gsql" "pggat2/lib/util/maps" "pggat2/lib/util/strutil" @@ -173,7 +173,7 @@ func (T *Pools) Lookup(user, database string) *pool.Pool { Database: database, }, p) - var d dialer.Dialer + var d dialer2.Dialer dbCreds := creds if db.Password != "" { @@ -205,7 +205,7 @@ func (T *Pools) Lookup(user, database string) *pool.Pool { dir = dir + ".s.PGSQL." + strconv.Itoa(port) - d = dialer.Net{ + d = dialer2.Net{ Network: "unix", Address: dir, AcceptOptions: acceptOptions, @@ -219,7 +219,7 @@ func (T *Pools) Lookup(user, database string) *pool.Pool { } // connect over tcp - d = dialer.Net{ + d = dialer2.Net{ Network: "tcp", Address: address, AcceptOptions: acceptOptions, diff --git a/lib/gat/pool/recipe.go b/lib/gat/pool/recipe.go index d7d98703..0dc7acfc 100644 --- a/lib/gat/pool/recipe.go +++ b/lib/gat/pool/recipe.go @@ -1,6 +1,8 @@ package pool -import "pggat2/lib/gat/pool/dialer" +import ( + "pggat2/lib/gat/pool/recipe/dialer" +) type Recipe struct { Dialer dialer.Dialer diff --git a/lib/gat/pool/dialer/dialer.go b/lib/gat/pool/recipe/dialer/dialer.go similarity index 100% rename from lib/gat/pool/dialer/dialer.go rename to lib/gat/pool/recipe/dialer/dialer.go diff --git a/lib/gat/pool/dialer/net.go b/lib/gat/pool/recipe/dialer/net.go similarity index 100% rename from lib/gat/pool/dialer/net.go rename to lib/gat/pool/recipe/dialer/net.go diff --git a/lib/gat/pool/recipe/options.go b/lib/gat/pool/recipe/options.go new file mode 100644 index 00000000..07b21307 --- /dev/null +++ b/lib/gat/pool/recipe/options.go @@ -0,0 +1,13 @@ +package recipe + +import ( + "pggat2/lib/gat/pool/recipe/dialer" +) + +type Options struct { + Dialer dialer.Dialer + + MinConnections int + // MaxConnections is the max number of simultaneous connections from this recipe. 0 = unlimited + MaxConnections int +} diff --git a/lib/gat/pool/recipe/recipe.go b/lib/gat/pool/recipe/recipe.go new file mode 100644 index 00000000..2e807759 --- /dev/null +++ b/lib/gat/pool/recipe/recipe.go @@ -0,0 +1,15 @@ +package recipe + +type Recipe struct { + options Options +} + +func NewRecipe(options Options) *Recipe { + return &Recipe{ + options: options, + } +} + +func (T *Recipe) Dial() { + +} diff --git a/lib/gat/pool/recipe/server.go b/lib/gat/pool/recipe/server.go new file mode 100644 index 00000000..95bf6346 --- /dev/null +++ b/lib/gat/pool/recipe/server.go @@ -0,0 +1,4 @@ +package recipe + +type Server struct { +} -- GitLab