feat(studio): db-pool postgrest config (#22865)

* feat(studio): db-pool postgrest config

* chore: prettier

* chore: openapi
This commit is contained in:
Bobbie Soedirgo authored and GitHub committed 2024-04-29 18:31:14 +08:00
1 parent 368348abfd
commit 9190bbe206
3 files changed
+18 -1

No files matched your search

@@ -40,7 +40,7 @@ const PostgrestConfig = () => {
)
const formId = 'project-postgres-config'
const initialValues = { db_schema: '', max_rows: '', db_extra_search_path: '' }
const initialValues = { db_schema: '', max_rows: '', db_extra_search_path: '', db_pool: '' }
const updateConfig = async (updatedConfig: typeof initialValues) => {
if (!projectRef) return console.error('Project ref is required')
@@ -49,6 +49,7 @@ const PostgrestConfig = () => {
dbSchema: updatedConfig.db_schema,
maxRows: updatedConfig.max_rows,
dbExtraSearchPath: updatedConfig.db_extra_search_path,
dbPool: updatedConfig.db_pool || null,
})
}
@@ -83,6 +84,7 @@ const PostgrestConfig = () => {
db_schema: config.db_schema,
max_rows: config.max_rows,
db_extra_search_path: config.db_extra_search_path ?? '',
db_pool: config.db_pool || null,
}
resetForm({ values, initialValues: values })
}
@@ -177,6 +179,17 @@ const PostgrestConfig = () => {
/>
</FormSectionContent>
</FormSection>
<FormSection header={<FormSectionLabel>Pool size</FormSectionLabel>}>
<FormSectionContent loading={false}>
<InputNumber
id="db_pool"
size="small"
disabled={!canUpdatePostgrestConfig}
descriptionText="Number of maximum connections to keep open in the Data API server's database pool. Unset to let it be configured automatically based on compute size."
placeholder="Configured automatically based on compute size"
/>
</FormSectionContent>
</FormSection>
</>
)}
</FormPanel>
@@ -13,6 +13,7 @@ export type ProjectPostgrestConfigResponse = {
db_schema: string
db_anon_role: string
db_extra_search_path: string
db_pool: number | null
jwt_secret: string
}
@@ -11,6 +11,7 @@ export type ProjectPostgrestConfigUpdateVariables = {
dbSchema: string
maxRows: string
dbExtraSearchPath: string
dbPool: string | null
}
export async function updateProjectPostgrestConfig({
@@ -18,11 +19,13 @@ export async function updateProjectPostgrestConfig({
dbSchema,
maxRows,
dbExtraSearchPath,
dbPool,
}: ProjectPostgrestConfigUpdateVariables) {
const response = await patch(`${API_URL}/projects/${projectRef}/config/postgrest`, {
db_schema: dbSchema,
max_rows: maxRows,
db_extra_search_path: dbExtraSearchPath,
db_pool: dbPool,
})
if (response.error) throw response.error