Skip to content

Instantly share code, notes, and snippets.

@adamw
Created June 14, 2018 15:36
Show Gist options
  • Save adamw/bb178a51870b53a53d62d356f3c3e4ba to your computer and use it in GitHub Desktop.
Save adamw/bb178a51870b53a53d62d356f3c3e4ba to your computer and use it in GitHub Desktop.
def crawlUrl(data: CrawlerData, url: Url): IO[Nothing, CrawlerData] = {
if (!data.visitedLinks.contains(url)) {
workerFor(data, url.host).flatMap {
case (data2, workerQueue) =>
workerQueue.offer(url).map { _ =>
data2.copy(
visitedLinks = data.visitedLinks + url,
inProgress = data.inProgress + url
)
}
}
} else IO.now(data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment