Skip to content

Commit

Permalink
playground: add tiproxy to dsn
Browse files Browse the repository at this point in the history
Signed-off-by: xhe <[email protected]>
  • Loading branch information
xhebox committed Nov 12, 2024
1 parent 775384c commit 78fc06d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion components/playground/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,14 @@ func loadPort(dir string) (port int, err error) {
return
}

func dumpDSN(fname string, dbs []*instance.TiDBInstance) {
func dumpDSN(fname string, dbs []*instance.TiDBInstance, tdbs []*instance.TiProxy) {
var dsn []string
for _, db := range dbs {
dsn = append(dsn, fmt.Sprintf("mysql://root@%s", db.Addr()))
}
for _, tdb := range tdbs {
dsn = append(dsn, fmt.Sprintf("mysql://root@%s", tdb.Addr()))
}
_ = utils.WriteFile(fname, []byte(strings.Join(dsn, "\n")), 0644)
}

Expand Down
2 changes: 1 addition & 1 deletion components/playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ func (p *Playground) bootCluster(ctx context.Context, env *environment.Environme
p.updateMonitorTopology(spec.ComponentPrometheus, *monitorInfo)
}

dumpDSN(filepath.Join(p.dataDir, "dsn"), p.tidbs)
dumpDSN(filepath.Join(p.dataDir, "dsn"), p.tidbs, p.tiproxys)

go func() {
// fmt.Printf("serve at :%d\n", p.port)
Expand Down

0 comments on commit 78fc06d

Please sign in to comment.