whilenull / 7777-support

Documentation and support for 7777.
https://port7777.com
53 stars 3 forks source link

Show role when choosing database #54

Open slootjes opened 1 month ago

slootjes commented 1 month ago

When using Port 7777 on an RDS cluster with multiple instances the output looks something like this:

Listing databases.
Which database would you like to connect to?

[1] some-service-databaseinstance1-azznqqajdhkm
[2] some-service-databaseinstance2-cqtwprntcl09

but based on this names I don't know which of the 2 is a reader or a writer. When making changes I obviously need a writer and while just doing some queries I prefer using a reader instance. Currently I always need to login to AWS to see which one I need. It would be very nice to see the role of the instance in this selection, perhaps like this:

Listing databases.
Which database would you like to connect to?

[1] some-service-databaseinstance1-azznoqajd0km (Writer instance)
[2] some-service-databaseinstance2-cqtwprbtdl09 (Reader instance)

While writing this, maybe also add the instance size to it as well:

Listing databases.
Which database would you like to connect to?

[1] some-service-databaseinstance1-azznoqajd0km (Writer instance / Serverless v2 (0.5 - 16 ACUs))
[2] some-service-databaseinstance2-cqtwprbtdl09 (Reader instance / tg4.medium)

What do you think?

mnapoli commented 1 month ago

Sounds like a great improvement idea, thanks for opening this. Naive question: is the reader/writer status exposed via the RDS API?

In any case I'm taking note of the idea (no promise on an implementation date ^^)

slootjes commented 1 month ago

The information is returned in the describe db clusters API endpoint which is already used as far as I know by this app, this is the relevant output for my cluster:

<DBClusterMembers>
    <DBClusterMember>
        <DBInstanceIdentifier>some-service-databaseinstance1-azznoqajd0km</DBInstanceIdentifier>
        <DBClusterParameterGroupStatus>in-sync</DBClusterParameterGroupStatus>
        <PromotionTier>1</PromotionTier>
        <IsClusterWriter>true</IsClusterWriter>
    </DBClusterMember>
    <DBClusterMember>
        <DBInstanceIdentifier>some-service-databaseinstance2-cqtwprbtdl09</DBInstanceIdentifier>
        <DBClusterParameterGroupStatus>in-sync</DBClusterParameterGroupStatus>
        <PromotionTier>1</PromotionTier>
        <IsClusterWriter>false</IsClusterWriter>
    </DBClusterMember>
</DBClusterMembers>

The "IsClusterWriter" returns the relevant information if it's read/write or read only.

The instance type is available in the Describe Db Instances API call:

<DBInstanceClass>db.serverless</DBInstanceClass>

Maybe returning it as a table would be prettier even when adding more information.