@@ -26,6 +26,7 @@ import { InstanceDocsPopover } from '~/components/InstanceDocsPopover'
2626import { RefreshButton } from '~/components/RefreshButton'
2727import { getProjectSelector , useProjectSelector } from '~/hooks/use-params'
2828import { useQuickActions } from '~/hooks/use-quick-actions'
29+ import { ExternalIpsCell } from '~/table/cells/ExternalIpsCell'
2930import { InstanceStateCell } from '~/table/cells/InstanceStateCell'
3031import { makeLinkCell } from '~/table/cells/LinkCell'
3132import { getActionsCol } from '~/table/columns/action-col'
@@ -67,13 +68,32 @@ const instanceList = (
6768
6869export async function clientLoader ( { params } : LoaderFunctionArgs ) {
6970 const { project } = getProjectSelector ( params )
70- await queryClient . prefetchQuery ( instanceList ( project ) . optionsFn ( ) )
71+ const instances = await queryClient . fetchQuery ( instanceList ( project ) . optionsFn ( ) )
72+ // Warm the external IP cache for each instance in parallel as the route
73+ // loads. This doesn't add requests: ExternalIpsCell would issue the same
74+ // ones on mount, showing a skeleton until its list arrives. Prefetching
75+ // just starts them earlier.
76+ const ipPrefetches = instances . items . map ( ( { name : instance } ) =>
77+ queryClient . prefetchQuery (
78+ q ( api . instanceExternalIpList , { path : { instance } , query : { project } } )
79+ )
80+ )
81+ // Block render on the first few so the top of the table doesn't flash
82+ // skeletons, but let the rest roll in after. Awaiting all of them would
83+ // block render on the slowest of up to 50 requests, and the odds of hitting
84+ // a slow one (while low) grow with N. 6 is a magic number: enough to usually
85+ // paint the top of the table without skeletons, but still small. It happens
86+ // to match the browser's per-host connection limit, but that only applies
87+ // over HTTP/1.1; in production, Nexus uses HTTP/2, so requests multiplex and
88+ // that limit shouldn't matter.
89+ await Promise . all ( ipPrefetches . slice ( 0 , 6 ) )
7190 return null
7291}
7392
7493const refetchInstances = ( ) =>
7594 Promise . all ( [
7695 queryClient . invalidateEndpoint ( 'instanceList' ) ,
96+ queryClient . invalidateEndpoint ( 'instanceExternalIpList' ) ,
7797 queryClient . invalidateEndpoint ( 'antiAffinityGroupMemberList' ) ,
7898 ] )
7999
@@ -101,6 +121,13 @@ export default function InstancesPage() {
101121 colHelper . accessor ( 'name' , {
102122 cell : makeLinkCell ( ( instance ) => pb . instance ( { project, instance } ) ) ,
103123 } ) ,
124+ colHelper . accessor (
125+ ( i ) => ( { runState : i . runState , timeRunStateUpdated : i . timeRunStateUpdated } ) ,
126+ {
127+ header : 'state' ,
128+ cell : ( info ) => < InstanceStateCell value = { info . getValue ( ) } /> ,
129+ }
130+ ) ,
104131 colHelper . accessor ( 'ncpus' , {
105132 header : 'CPU' ,
106133 cell : ( info ) => (
@@ -121,13 +148,13 @@ export default function InstancesPage() {
121148 )
122149 } ,
123150 } ) ,
124- colHelper . accessor (
125- ( i ) => ( { runState : i . runState , timeRunStateUpdated : i . timeRunStateUpdated } ) ,
126- {
127- header : 'state' ,
128- cell : ( info ) => < InstanceStateCell value = { info . getValue ( ) } /> ,
129- }
130- ) ,
151+ colHelper . display ( {
152+ id : 'externalIps' ,
153+ header : 'External IPs' ,
154+ cell : ( info ) => (
155+ < ExternalIpsCell project = { project } instance = { info . row . original . name } />
156+ ) ,
157+ } ) ,
131158 colHelper . accessor ( 'timeCreated' , Columns . timeCreated ) ,
132159 getActionsCol ( ( instance : Instance ) => [
133160 ...makeButtonActions ( instance ) ,
0 commit comments