diff --git a/examples/manual_routing.Caddyfile b/examples/manual_routing.Caddyfile
index 5ebad0b36394483a3195efe5185bb1c12fd064a6..169bbd22df13a4eba2c93a8b68fdfc0ff52aa21c 100644
--- a/examples/manual_routing.Caddyfile
+++ b/examples/manual_routing.Caddyfile
@@ -27,7 +27,7 @@
pool /bobland localhost:5432 bobland postgres password
pool /jeffland {
- pooler session
+ pool basic session
address localhost:5432
ssl require insecure_skip_verify
diff --git a/lib/gat/handlers/pool/pool.go b/lib/gat/handlers/pool/pool.go
index d8dc16a9262e681260ec023ef4431258d4b38466..026cd752b133894f137fc90a0fdf641e5fdcd484 100644
--- a/lib/gat/handlers/pool/pool.go
+++ b/lib/gat/handlers/pool/pool.go
@@ -16,6 +16,13 @@ type Pool interface {
Close()
}
+type ReplicaPool interface {
+ Pool
+
+ AddReplicaRecipe(name string, recipe *Recipe)
+ RemoveReplicaRecipe(name string)
+}
+
type PoolFactory interface {
NewPool() Pool
}
diff --git a/lib/gat/handlers/pool/pools/hybrid/factory.go b/lib/gat/handlers/pool/pools/hybrid/factory.go
new file mode 100644
index 0000000000000000000000000000000000000000..14a625dafd18792ba7eadc27d2432f21c2ee1595
--- /dev/null
+++ b/lib/gat/handlers/pool/pools/hybrid/factory.go
@@ -0,0 +1,30 @@
+package hybrid
+
+import (
+ "github.com/caddyserver/caddy/v2"
+
+ "gfx.cafe/gfx/pggat/lib/gat/handlers/pool"
+)
+
+func init() {
+ caddy.RegisterModule((*Factory)(nil))
+}
+
+type Factory struct {
+}
+
+func (T *Factory) CaddyModule() caddy.ModuleInfo {
+ return caddy.ModuleInfo{
+ ID: "pggat.handlers.pool.pools.hybrid",
+ New: func() caddy.Module {
+ return new(Factory)
+ },
+ }
+}
+
+func (T *Factory) NewPool() pool.Pool {
+ return new(Pool)
+}
+
+var _ pool.PoolFactory = (*Factory)(nil)
+var _ caddy.Module = (*Factory)(nil)
diff --git a/lib/gat/handlers/pool/pools/hybrid/pool.go b/lib/gat/handlers/pool/pools/hybrid/pool.go
new file mode 100644
index 0000000000000000000000000000000000000000..92cb728e75197d9353cbee51993a65fb39446f51
--- /dev/null
+++ b/lib/gat/handlers/pool/pools/hybrid/pool.go
@@ -0,0 +1,52 @@
+package hybrid
+
+import (
+ "gfx.cafe/gfx/pggat/lib/fed"
+ "gfx.cafe/gfx/pggat/lib/gat/handlers/pool"
+ "gfx.cafe/gfx/pggat/lib/gat/handlers/pool/spool"
+ "gfx.cafe/gfx/pggat/lib/gat/metrics"
+)
+
+type Pool struct {
+ primary spool.Pool
+ replica spool.Pool
+}
+
+func (T *Pool) AddReplicaRecipe(name string, recipe *pool.Recipe) {
+ T.replica.AddRecipe(name, recipe)
+}
+
+func (T *Pool) RemoveReplicaRecipe(name string) {
+ T.replica.RemoveRecipe(name)
+}
+
+func (T *Pool) AddRecipe(name string, recipe *pool.Recipe) {
+ T.primary.AddRecipe(name, recipe)
+}
+
+func (T *Pool) RemoveRecipe(name string) {
+ T.primary.RemoveRecipe(name)
+}
+
+func (T *Pool) Serve(conn *fed.Conn) error {
+ // TODO implement me
+ panic("implement me")
+}
+
+func (T *Pool) Cancel(key fed.BackendKey) {
+ // TODO implement me
+ panic("implement me")
+}
+
+func (T *Pool) ReadMetrics(m *metrics.Pool) {
+ T.primary.ReadMetrics(m)
+ T.replica.ReadMetrics(m)
+}
+
+func (T *Pool) Close() {
+ T.primary.Close()
+ T.replica.Close()
+}
+
+var _ pool.Pool = (*Pool)(nil)
+var _ pool.ReplicaPool = (*Pool)(nil)