Home / Function/ calculateComputeSizeRequiredForIops() — supabase Function Reference

calculateComputeSizeRequiredForIops() — supabase Function Reference

Architecture documentation for the calculateComputeSizeRequiredForIops() function in DiskManagement.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  5a5e7bf2_43db_cf41_0d0b_243b77c1d79d["calculateComputeSizeRequiredForIops()"]
  e4f4740e_699b_cee8_77fb_38343fd520bf["IOPSField()"]
  e4f4740e_699b_cee8_77fb_38343fd520bf -->|calls| 5a5e7bf2_43db_cf41_0d0b_243b77c1d79d
  3a156a98_6e20_49a2_bf97_211c04127fcf["ComputeSizeRecommendationSection()"]
  3a156a98_6e20_49a2_bf97_211c04127fcf -->|calls| 5a5e7bf2_43db_cf41_0d0b_243b77c1d79d
  style 5a5e7bf2_43db_cf41_0d0b_243b77c1d79d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/DiskManagement/DiskManagement.utils.ts lines 320–344

export const calculateComputeSizeRequiredForIops = (
  iops: number
): ComputeInstanceAddonVariantId | undefined => {
  type ComputeSizeMax = { size: ComputeInstanceAddonVariantId; maxIops: number }

  const computeSizes: ComputeSizeMax[] = Object.entries(COMPUTE_MAX_IOPS)
    .map((entry) => {
      const [size, maxIops] = entry
      const parsedSize = computeInstanceAddonVariantIdSchema.safeParse(size)
      if (!parsedSize.success) return undefined
      return { size: parsedSize.data, maxIops: Number(maxIops) }
    })
    .filter((value): value is ComputeSizeMax => value !== undefined)
    .sort((a, b) => a.maxIops - b.maxIops)

  for (const { size, maxIops } of computeSizes) {
    if (iops <= maxIops) {
      return size
    }
  }

  const fallbackSize = computeSizes[computeSizes.length - 1]?.size
  if (!fallbackSize) return undefined
  return fallbackSize
}

Subdomains

Frequently Asked Questions

What does calculateComputeSizeRequiredForIops() do?
calculateComputeSizeRequiredForIops() is a function in the supabase codebase.
What calls calculateComputeSizeRequiredForIops()?
calculateComputeSizeRequiredForIops() is called by 2 function(s): ComputeSizeRecommendationSection, IOPSField.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free