good morning!!!!

Skip to content
Snippets Groups Projects
Commit c62ab03b authored by Garet Halliday's avatar Garet Halliday
Browse files

wip debug stuff

parent 6ae0fe09
Branches
Tags
No related merge requests found
...@@ -34,11 +34,6 @@ pools: ...@@ -34,11 +34,6 @@ pools:
role: primary role: primary
username: ENV$PSQL_DB_USER_RW username: ENV$PSQL_DB_USER_RW
password: ENV$PSQL_DB_PASS_RW password: ENV$PSQL_DB_PASS_RW
- host: ENV$PSQL_REP_DB_HOST
port: 5432
role: replica
username: ENV$PSQL_DB_USER_RO
password: ENV$PSQL_DB_PASS_RO
prest: prest:
pool_mode: transaction pool_mode: transaction
default_role: primary default_role: primary
...@@ -61,11 +56,6 @@ pools: ...@@ -61,11 +56,6 @@ pools:
role: primary role: primary
username: ENV$PSQL_DB_USER_RW username: ENV$PSQL_DB_USER_RW
password: ENV$PSQL_DB_PASS_RW password: ENV$PSQL_DB_PASS_RW
- host: ENV$PSQL_REP_DB_HOST
port: 5432
role: replica
username: ENV$PSQL_DB_USER_RO
password: ENV$PSQL_DB_PASS_RO
# poolname OR databasename: # poolname OR databasename:
# pool_mode: session OR transaction # pool_mode: session OR transaction
# default_role: primary OR replica # default_role: primary OR replica
......
...@@ -3,6 +3,7 @@ package admin ...@@ -3,6 +3,7 @@ package admin
import ( import (
"context" "context"
"errors" "errors"
"gfx.cafe/gfx/pggat/lib/util/gatutil"
"gfx.cafe/gfx/pggat/lib/config" "gfx.cafe/gfx/pggat/lib/config"
"gfx.cafe/gfx/pggat/lib/gat" "gfx.cafe/gfx/pggat/lib/gat"
...@@ -92,8 +93,45 @@ func New(g gat.Gat) *Database { ...@@ -92,8 +93,45 @@ func New(g gat.Gat) *Database {
out.r.Register([]string{"show", "clients"}, func(_ gat.Client, _ []string) error { out.r.Register([]string{"show", "clients"}, func(_ gat.Client, _ []string) error {
return nil return nil
}) })
out.r.Register([]string{"show", "pools"}, func(_ gat.Client, _ []string) error { out.r.Register([]string{"show", "pools"}, func(c gat.Client, _ []string) error {
return nil table := gatutil.Table{
Header: gatutil.TableHeader{
Columns: []gatutil.TableHeaderColumn{
{
Name: "Table name",
Type: gatutil.Text{},
},
{
Name: "Min latency",
Type: gatutil.Float64{},
},
{
Name: "Max latency",
Type: gatutil.Float64{},
},
{
Name: "Avg latency",
Type: gatutil.Float64{},
},
{
Name: "Request Count",
Type: gatutil.Int64{},
},
},
},
Rows: []gatutil.TableRow{
{
Columns: []any{
"Test",
float64(1.0),
float64(2.0),
float64(3.0),
int64(123),
},
},
},
}
return table.Send(c)
}) })
out.r.Register([]string{"show", "lists"}, func(_ gat.Client, _ []string) error { out.r.Register([]string{"show", "lists"}, func(_ gat.Client, _ []string) error {
return nil return nil
......
package gatutil
import (
"fmt"
"gfx.cafe/gfx/pggat/lib/gat"
"gfx.cafe/gfx/pggat/lib/gat/protocol"
)
type TableHeaderColumn struct {
Name string
Type Type
}
func (T *TableHeaderColumn) RowDescription() protocol.FieldsRowDescriptionFields {
return protocol.FieldsRowDescriptionFields{
Name: T.Name,
DataType: T.Type.OID(),
DataTypeSize: T.Type.Len(),
FormatCode: 0,
}
}
type TableHeader struct {
Columns []TableHeaderColumn
}
func (T *TableHeader) RowDescription() (pkt protocol.RowDescription) {
for _, col := range T.Columns {
pkt.Fields.Fields = append(pkt.Fields.Fields, col.RowDescription())
}
return
}
type TableRow struct {
Columns []any
}
func (T *TableRow) DataRow() (pkt protocol.DataRow) {
for _, col := range T.Columns {
pkt.Fields.Columns = append(pkt.Fields.Columns, protocol.FieldsDataRowColumns{
Bytes: []byte(fmt.Sprintf("%v\x00", col)),
})
}
return
}
type Table struct {
Header TableHeader
Rows []TableRow
}
func (T *Table) Send(client gat.Client) error {
rowDescription := T.Header.RowDescription()
err := client.Send(&rowDescription)
if err != nil {
return err
}
for _, row := range T.Rows {
dataRow := row.DataRow()
err = client.Send(&dataRow)
if err != nil {
return err
}
}
return nil
}
package gatutil
type Type interface {
OID() int32
Len() int16
}
type Text struct{}
func (Text) OID() int32 {
return 25
}
func (Text) Len() int16 {
return -1
}
type Int16 struct{}
func (Int16) OID() int32 {
return 21
}
func (Int16) Len() int16 {
return 2
}
type Int32 struct{}
func (Int32) OID() int32 {
return 23
}
func (Int32) Len() int16 {
return 4
}
type Int64 struct{}
func (Int64) OID() int32 {
return 20
}
func (Int64) Len() int16 {
return 8
}
type Char struct{}
func (Char) OID() int32 {
return 18
}
func (Char) Len() int16 {
return 1
}
type Bool struct{}
func (Bool) OID() int32 {
return 16
}
func (Bool) Len() int16 {
return 1
}
type Float32 struct{}
func (Float32) OID() int32 {
return 700
}
func (Float32) Len() int16 {
return 4
}
type Float64 struct{}
func (Float64) OID() int32 {
return 701
}
func (Float64) Len() int16 {
return 8
}
...@@ -24,7 +24,7 @@ const PrestHost = "http://localhost:3000" ...@@ -24,7 +24,7 @@ const PrestHost = "http://localhost:3000"
const PostgresHost = "postgres://dev_rw:pGf63Aq0M5ck@pggat-dev.gfx.town:6432/prest" const PostgresHost = "postgres://dev_rw:pGf63Aq0M5ck@pggat-dev.gfx.town:6432/prest"
// ThreadCount how many concurrent spammers to run at once // ThreadCount how many concurrent spammers to run at once
const ThreadCount = 4 const ThreadCount = 1000
// TestTime how long to run the test. Set to 0 to run forever // TestTime how long to run the test. Set to 0 to run forever
const TestTime = 30 * time.Second const TestTime = 30 * time.Second
......
...@@ -15,10 +15,10 @@ services: ...@@ -15,10 +15,10 @@ services:
build: ../ build: ../
restart: always restart: always
environment: environment:
PSQL_DB_ADMIN_USER: postgres
PSQL_DB_ADMIN_PASS: example
PSQL_DB_USER_RW: postgres PSQL_DB_USER_RW: postgres
PSQL_DB_PASS_RW: example PSQL_DB_PASS_RW: example
PSQL_DB_USER_RO: postgres
PSQL_DB_PASS_RO: example
PSQL_PRI_DB_HOST: db PSQL_PRI_DB_HOST: db
PSQL_REP_DB_HOST: db PSQL_REP_DB_HOST: db
ports: ports:
...@@ -30,7 +30,7 @@ services: ...@@ -30,7 +30,7 @@ services:
image: prest/prest image: prest/prest
restart: always restart: always
environment: environment:
PREST_PG_URL: postgres://postgres:example@pggat:6432/prest PREST_PG_URL: postgres://postgres:example@db:5432/prest
PREST_DEBUG: true PREST_DEBUG: true
PREST_SSL_MODE: disable PREST_SSL_MODE: disable
ports: ports:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment