ReadReplicaDetails() — supabase Function Reference
Architecture documentation for the ReadReplicaDetails() function in ReadReplicaDetails.tsx from the supabase codebase.
Entity Profile
Relationship Graph
Source Code
apps/studio/components/interfaces/Database/Replication/ReadReplicas/ReadReplicaDetails.tsx lines 33–183
export const ReadReplicaDetails = () => {
const { ref: projectRef, replicaId } = useParams()
const reportGranularityV2 = useFlag('reportGranularityV2')
const { data = [], isPending: isLoadingDatabases } = useReadReplicasQuery({ projectRef })
const replica = data.find((x) => x.identifier === replicaId)
const { identifier, connectionString, status: baseStatus, restUrl, region, size } = replica ?? {}
const regionLabel = Object.values(AWS_REGIONS).find((x) => x.code === region)?.displayName
const { data: statuses = [] } = useReadReplicasStatusesQuery({ projectRef })
const replicaStatus = statuses.find((x) => x.identifier === identifier)
const status = replicaStatus?.status ?? baseStatus
const { data: loadBalancers = [] } = useLoadBalancersQuery({ projectRef })
const loadBalancer = loadBalancers.find((x) =>
x.databases.some((x) => x.identifier === identifier)
)
const { data: lagDuration, isPending: isLoadingLag } = useReplicationLagQuery(
{
id: identifier ?? '',
projectRef,
connectionString,
},
{ enabled: status === REPLICA_STATUS.ACTIVE_HEALTHY }
)
const { selectedDateRange } = useReportDateRange(
REPORT_DATERANGE_HELPER_LABELS.LAST_60_MINUTES,
reportGranularityV2
)
// [Joshen] This is unused but intentional to scaffold the usage for now, refer to comment below
const { data: infraMonitoringData, isPending: isFetchingInfraMonitoring } =
useInfraMonitoringAttributesQuery(
{
projectRef,
attributes: [attribute],
databaseIdentifier: identifier,
startDate: selectedDateRange.period_start.date,
endDate: selectedDateRange.period_end.date,
interval: selectedDateRange.interval,
},
{ enabled: !!replica }
)
const chartData = useMemo(
() =>
infraMonitoringData?.data.map((x) => ({
timestamp: x.period_start,
[attribute]: (x as Record<string, string | number>)[attribute],
})) ?? [],
[infraMonitoringData?.data]
)
return (
<>
<Chart className="mt-6" isLoading={isLoadingLag || isFetchingInfraMonitoring}>
<ChartCard className="rounded-none border-x-0">
<ChartHeader className="px-10">
<ChartMetric
label="Replication lag"
value={lagDuration !== undefined ? `${lagDuration}s` : '-'}
/>
</ChartHeader>
<ChartContent
isEmpty={chartData.length === 0}
emptyState={
<ChartEmptyState
icon={<BarChart2 size={16} />}
title="No data to show"
description="It may take up to 24 hours for data to refresh"
/>
}
loadingState={<ChartLoadingState className="h-[228px]" />}
>
<div className="h-56 px-5">
<ChartLine
showGrid
showYAxis
isFullHeight
data={chartData}
dataKey={attribute}
YAxisProps={{
tickFormatter: (value) => `${value}s`,
width: 80,
}}
config={{
[attribute]: { label: 'Replication lag' },
}}
/>
</div>
</ChartContent>
</ChartCard>
</Chart>
<ScaffoldContainer>
<ScaffoldSection isFullWidth>
<Card>
<CardHeader>
<CardTitle>Replica Information</CardTitle>
</CardHeader>
{isLoadingDatabases ? (
<CardContent>
<GenericSkeletonLoader />
</CardContent>
) : (
<>
<CardContent>
<FormItemLayout
isReactForm={false}
layout="horizontal"
label="Load Balancer URL"
description="RESTful endpoint for querying and managing your databases through your load balancer"
>
<Input readOnly copy className="input-mono" value={loadBalancer?.endpoint} />
</FormItemLayout>
</CardContent>
<CardContent className="flex flex-col gap-y-4">
<FormItemLayout isReactForm={false} layout="horizontal" label="Replica URL">
<Input readOnly copy className="input-mono" value={restUrl} />
</FormItemLayout>
<FormItemLayout isReactForm={false} layout="horizontal" label="Region">
<Input
readOnly
className="input-mono"
value={regionLabel}
icon={
<img
alt="region icon"
className="w-5 rounded-sm"
src={`${BASE_PATH}/img/regions/${region ?? ''}.svg`}
/>
}
/>
</FormItemLayout>
<FormItemLayout
isReactForm={false}
layout="horizontal"
label="Compute Size"
description="Size of replica will be identical to the primary database"
>
<Input readOnly className="input-mono" value={size} />
</FormItemLayout>
</CardContent>
</>
)}
</Card>
</ScaffoldSection>
</ScaffoldContainer>
</>
)
}
Domain
Subdomains
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free