Skip to content
This repository was archived by the owner on Dec 5, 2022. It is now read-only.

Refactor src/events/scraper/load-cache/index.js #204

@jzohrab

Description

@jzohrab

Change API to take the loader, and add tests. Passing in the loader object rather than a boolean should clarify flow. Can also standardize on throwing instead of returning false,

  • How will this make life better?

Clearer code path

  • How big is this change (small/med/large/really large)?

Small

  • How complicated is it?

Medium. Code exists and works, but IMO is hard to follow.

  • What's the test plan?

Dependency inject for unit testing to simulate cache fall through.

e.g:


async function load(params, loader) { ... }

async function loadCache(params) {
  if (isLocal) {
    try {
      let result = await load(params, localLoader)
      return result
    }
    catch {
      ... cache miss
    }
  }

  // S3 load
  try {
    let result = await load(params, S3Loader)
    return result
  }
  catch {
    ... failure
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions