diff options
author | 2024-08-06 17:16:35 -0700 | |
---|---|---|
committer | 2024-08-06 17:16:35 -0700 | |
commit | 961f9e0a76c3cfe9ae92ca8da0531790e0610b69 (patch) | |
tree | f6de4ed36c3f48ee94ecd524dedeb0d7c84b72e5 /backend/internal/ibd/options.go | |
parent | 641c81198d7fed7138bb482f226e54bd703094ab (diff) | |
download | ibd-trader-961f9e0a76c3cfe9ae92ca8da0531790e0610b69.tar.gz ibd-trader-961f9e0a76c3cfe9ae92ca8da0531790e0610b69.tar.zst ibd-trader-961f9e0a76c3cfe9ae92ca8da0531790e0610b69.zip |
Modify IBD to accept various transport backends
This allows IBD to try using faster and cheaper transports first with
fallback to more reliable and expensive transports later.
Diffstat (limited to 'backend/internal/ibd/options.go')
-rw-r--r-- | backend/internal/ibd/options.go | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/backend/internal/ibd/options.go b/backend/internal/ibd/options.go deleted file mode 100644 index a07241e..0000000 --- a/backend/internal/ibd/options.go +++ /dev/null @@ -1,84 +0,0 @@ -package ibd - -const BaseURL = "https://api.scrapfly.io/scrape" - -var defaultScrapeOptions = ScrapeOptions{ - baseURL: BaseURL, - country: nil, - asp: true, - proxyPool: ProxyPoolDatacenter, - renderJS: false, - cache: false, -} - -type ScrapeOption func(*ScrapeOptions) - -type ScrapeOptions struct { - baseURL string - country *string - asp bool - proxyPool ProxyPool - renderJS bool - cache bool - debug bool -} - -type ProxyPool uint8 - -const ( - ProxyPoolDatacenter ProxyPool = iota - ProxyPoolResidential -) - -func (p ProxyPool) String() string { - switch p { - case ProxyPoolDatacenter: - return "public_datacenter_pool" - case ProxyPoolResidential: - return "public_residential_pool" - default: - panic("invalid proxy pool") - } -} - -func WithCountry(country string) ScrapeOption { - return func(o *ScrapeOptions) { - o.country = &country - } -} - -func WithASP(asp bool) ScrapeOption { - return func(o *ScrapeOptions) { - o.asp = asp - } -} - -func WithProxyPool(proxyPool ProxyPool) ScrapeOption { - return func(o *ScrapeOptions) { - o.proxyPool = proxyPool - } -} - -func WithRenderJS(jsRender bool) ScrapeOption { - return func(o *ScrapeOptions) { - o.renderJS = jsRender - } -} - -func WithCache(cache bool) ScrapeOption { - return func(o *ScrapeOptions) { - o.cache = cache - } -} - -func WithDebug(debug bool) ScrapeOption { - return func(o *ScrapeOptions) { - o.debug = debug - } -} - -func WithBaseURL(baseURL string) ScrapeOption { - return func(o *ScrapeOptions) { - o.baseURL = baseURL - } -} |