updating username/password after initialisation #889
-
Hi, I would like to apply a multi-user strategy for dealing with database secret rotation. At the moment, some period of time after the database secrets are rotated, the server stops working and I have to manually knock over the pods to get them started again. My plan is to have the module that creates the database object setup a new user/password when it starts, then use that for the life of the pod. I've write a basic implementation below, however at the moment when I update the pool properties for the new creds, I get an error "too many connections for database". The docs describes the $pool as readonly, so I'm not really surprised it didn't work but haven't found any other clues about how I might mutate the auth after it's exported. The complicating factor here, I think, is that the database object is exported immediately, so the timing is key if I want all the other places that database is used to have a different connection pool object.
Is there a way to update the user/password? why is it me telling me too many connection (if I comment the function the application works normally)? Any help greatly appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The functionality has always been there - see password definition: https://github.com/vitaly-t/pg-promise/blob/master/typescript/pg-subset.d.ts#L84C27-L84C27. The type already tells you that it can be: string, sync function or async function. |
Beta Was this translation helpful? Give feedback.
-
@tobywilliams Is this resolved now? |
Beta Was this translation helpful? Give feedback.
Thanks for the reminder, impressive how this repo is maintained!
The solution was a mix of small issues which I'll put here so it might help somebody.