Created
June 14, 2018 15:37
-
-
Save adamw/bf11678e5c25c698e426e08752e0514d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handleMessage(msg: CrawlerMessage, | |
data: CrawlerData | |
): IO[Nothing, CrawlerData] = msg match { | |
case Start(url) => | |
crawlUrl(data, url) | |
case CrawlResult(url, links) => | |
val data2 = data.copy(inProgress = data.inProgress - url) | |
links.foldM(data2) { | |
case (d, link) => | |
val d2 = d.copy(referenceCount = d.referenceCount.updated( | |
link.host, d.referenceCount.getOrElse(link.host, 0) + 1)) | |
crawlUrl(d2, link) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment