aboutsummaryrefslogtreecommitdiff
path: root/link_queue.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2025-05-31 16:35:27 +0700
committerShulhan <ms@kilabit.info>2025-05-31 17:03:29 +0700
commitfea6f2115088c676902a22e154562e36acc3eaa1 (patch)
treeb70de00dabc73c0adc2cbb3e9ef01e29dc1196aa /link_queue.go
parente332a3351ab1c82dc18b62e3c251447a7020a280 (diff)
downloadjarink-fea6f2115088c676902a22e154562e36acc3eaa1.tar.xz
all: refactoring the scan work without sync.Mutex
When using goroutine to process a link, the result than passed to main goroutine through channel. The main goroutine then process the result one by one, check if its has been seen, error, or need to be scanned. In that way, we don't need mutex to guard if link has been seen or not.
Diffstat (limited to 'link_queue.go')
-rw-r--r--link_queue.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/link_queue.go b/link_queue.go
index 9987586..10dbfff 100644
--- a/link_queue.go
+++ b/link_queue.go
@@ -11,6 +11,21 @@ import (
type linkQueue struct {
parentUrl *url.URL
- url string
- kind atom.Atom
+
+ // The error from scan.
+ errScan error
+
+ // url being scanned.
+ url string
+
+ // kind of url, its either an anchor or image.
+ // It set to 0 if url is the first URL being scanned.
+ kind atom.Atom
+
+ // Status of link after scan, its mostly used the HTTP status code.
+ // 0: link is the result of scan, not processed yet.
+ // StatusBadLink: link is invalid, not parseable or unreachable.
+ // 200 - 211: OK.
+ // 400 - 511: Error.
+ status int
}