Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include replica connection info on DBaaS clusters & DBaaS PG pools #663

Merged

Conversation

dwilsondo
Copy link
Contributor

The DO public API now includes standby node hostnames (standby_connection and standby_private_connection) in responses for clusters and pools. This PR adds these fields to GoDo. Note, this change only applies to clusters and postgres pools. Read replicas are currently limited to a single node and thus have no standby nodes.

The script below (run as go run main.go >> env.json) calls Get on an existing DB cluster and prints the result as JSON. When run w. the dev branch (development.json) the script includes these keys while the production (prod.json) omits them.

import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"os"
	"godo" // development godo, replace w. "github.com/digitalocean/godo" for prod
)

func main() {
	var j bytes.Buffer

	cl := godo.NewFromToken(os.Getenv("DIGITALOCEAN_RO_TOKEN"))
	db, _, _ := cl.Databases.Get(context.TODO(), "a_dbaas_cluster_uuid")

	b, _ := json.Marshal(db)
	_ = json.Indent(&j, b, "", "\t")
	fmt.Printf("%+v\n", string(j.Bytes()))
}
diff --git a/development.json b/prod.json
index b2c9ef3..72dbb1a 100644
--- a/development.json
+++ b/prod.json
@@ -21,24 +21,6 @@
 		"user": "doadmin",
 		"ssl": true
 	},
-	"standby_connection": {
-		"protocol": "postgresql",
-		"uri": "postgresql://doadmin:@replica-db-postgresql-nyc3-YYY-do-user-XXX-0.c.db.ondigitalocean.com:25060/defaultdb?sslmode=require",
-		"database": "defaultdb",
-		"host": "replica-db-postgresql-nyc3-YYY-do-user-XXX-0.c.db.ondigitalocean.com",
-		"port": 25060,
-		"user": "doadmin",
-		"ssl": true
-	},
-	"standby_private_connection": {
-		"protocol": "postgresql",
-		"uri": "postgresql://doadmin:@private-replica-db-postgresql-nyc3-YYY-do-user-XXX-0.c.db.ondigitalocean.com:25060/defaultdb?sslmode=require",
-		"database": "defaultdb",
-		"host": "private-replica-db-postgresql-nyc3-YYY-do-user-XXX-0.c.db.ondigitalocean.com",
-		"port": 25060,
-		"user": "doadmin",
-		"ssl": true
-	},

Copy link
Member

@danaelhe danaelhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you for this contribution! I do not see the standby_connection and standby_private_connection response attributes documented in our API docs- could you add them in there as well? at /openapi

@danaelhe danaelhe merged commit e63ec45 into digitalocean:main Jan 22, 2024
7 checks passed
@dwilsondo
Copy link
Contributor Author

Thanks for the review @danaelhe. The OpenAPI PR is WIP. Will link it back to this change when open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants