( endpoints: string[], random: () => number = Math.random, )
| 43 | }; |
| 44 | |
| 45 | export const pickRandomEndpoint = ( |
| 46 | endpoints: string[], |
| 47 | random: () => number = Math.random, |
| 48 | ) => { |
| 49 | if (!endpoints.length) { |
| 50 | throw new Error('No endpoints configured'); |
| 51 | } |
| 52 | return endpoints[Math.floor(random() * endpoints.length)]; |
| 53 | }; |
| 54 | |
| 55 | export async function selectFastestSuccessfulEndpoint<T>( |
| 56 | endpoints: string[], |
no outgoing calls
no test coverage detected