Connector
A single-connection web client that reads a page's html line by line.
A Connector holds at most one open connection at a time. Call open to establish it, read through it with next/hasNext (or by iterating the Connector itself), then release it with close. A second open call blocks until the current connection is closed, so a Connector is safe to share between threads but serializes them.
Stateless one-shot helpers (get, skrape, download) do not use the shared connection and can be called at any time.
Every operation that can fail returns a Result rather than throwing or returning null, so callers decide how to recover:
val connector = Connector()
connector.open("https://example.com")
.flatMap { connector.next() }
.onSuccess { line -> println(line) }
.onFailure { cause -> log.warn("could not read page", cause) }
connector.close()Content copied to clipboard