Package ai.preferred.venom.fetcher
Class AsyncFetcher
- java.lang.Object
-
- ai.preferred.venom.fetcher.AsyncFetcher
-
- All Implemented Interfaces:
Fetcher
,java.lang.AutoCloseable
public final class AsyncFetcher extends java.lang.Object implements Fetcher
This class holds the implementation to provide how items are fetched from the web, to validate the item and to store it if specified.- Author:
- Maksim Tkachenko, Truong Quoc Tuan, Ween Jiann Lee
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AsyncFetcher.Builder
A builder for async fetcher class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AsyncFetcher
buildDefault()
Create an instance of AsyncFetcher with default options.static AsyncFetcher.Builder
builder()
Create an instance of builder.void
close()
java.util.concurrent.Future<Response>
fetch(Request request)
Fetch the desired HTTP page given inRequest
.java.util.concurrent.Future<Response>
fetch(Request request, Callback callback)
Fetch the desired HTTP page given inRequest
.void
start()
Fetcher starter.
-
-
-
Method Detail
-
buildDefault
public static AsyncFetcher buildDefault()
Create an instance of AsyncFetcher with default options.- Returns:
- A new instance of async fetcher
-
builder
public static AsyncFetcher.Builder builder()
Create an instance of builder.- Returns:
- A new instance of builder
-
fetch
public java.util.concurrent.Future<Response> fetch(Request request)
Description copied from interface:Fetcher
Fetch the desired HTTP page given inRequest
.
-
fetch
public java.util.concurrent.Future<Response> fetch(Request request, Callback callback)
Description copied from interface:Fetcher
Fetch the desired HTTP page given inRequest
. Executes callback upon completion.
-
start
public void start()
Description copied from interface:Fetcher
Fetcher starter.
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.io.IOException
-
-