class

Vug::Config

Inherits Reference < Object

Configuration for Vug favicon fetching.

NOTE: This is a class rather than a record because it contains Proc callbacks (on_save, on_load, on_debug, etc.) which are not comparable and cannot be used in Crystal records. If callback support is ever removed, consider converting to a record to gain automatic copy_with support.

MAINTENANCE: When adding/removing config fields, update all 3 locations:

  1. getter declaration (above)
  2. initialize method parameters and body
  3. copy_with method parameters and body

Constants

DEFAULT = Config.new
DEFAULT_ACCEPT_LANGUAGE = "en-US,en;q=0.9"
DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
GOOGLE_PLACEHOLDER_SIZE = 198

Google favicon API returns a 198-byte SVG placeholder when no real favicon exists for a domain.

Constructors

default
Source
new(timeout : Time::Span | Nil = nil, html_fetch_timeout : Time::Span | Nil = nil, connect_timeout : Time::Span | Nil = nil, write_timeout : Time::Span | Nil = nil, max_redirects : Int32 | Nil = nil, max_size : Int32 | Nil = nil, user_agent : String | Nil = nil, accept_language : String | Nil = nil, cache_size_limit : Int32 | Nil = nil, cache_entry_ttl : Time::Span | Nil = nil, gray_placeholder_size : Int32 | Nil = nil, max_concurrent_requests : Int32 | Nil = nil, max_retries : Int32 | Nil = nil, retry_base_delay : Time::Span | Nil = nil, retry_max_delay : Time::Span | Nil = nil, on_save : Proc(String, Bytes, String, String | Nil) | Nil = nil, on_load : Proc(String, String | Nil) | Nil = nil, on_debug : Proc(String, Nil) | Nil = nil, on_error : Proc(String, String, Nil) | Nil = nil, on_warning : Proc(String, Nil) | Nil = nil, on_log : Proc(LogEntry, Nil) | Nil = nil)
Source

Instance methods

accept_language
Source
cache_entry_ttl
Source
cache_size_limit
Source
connect_timeout
Source
copy_with(timeout : Time::Span | Nil = nil, html_fetch_timeout : Time::Span | Nil = nil, connect_timeout : Time::Span | Nil = nil, write_timeout : Time::Span | Nil = nil, max_redirects : Int32 | Nil = nil, max_size : Int32 | Nil = nil, user_agent : String | Nil = nil, accept_language : String | Nil = nil, cache_size_limit : Int32 | Nil = nil, cache_entry_ttl : Time::Span | Nil = nil, gray_placeholder_size : Int32 | Nil = nil, max_concurrent_requests : Int32 | Nil = nil, max_retries : Int32 | Nil = nil, retry_base_delay : Time::Span | Nil = nil, retry_max_delay : Time::Span | Nil = nil, on_save : Proc(String, Bytes, String, String | Nil) | Nil | Unset = Unset.instance, on_load : Proc(String, String | Nil) | Nil | Unset = Unset.instance, on_debug : Proc(String, Nil) | Nil | Unset = Unset.instance, on_error : Proc(String, String, Nil) | Nil | Unset = Unset.instance, on_warning : Proc(String, Nil) | Nil | Unset = Unset.instance, on_log : Proc(LogEntry, Nil) | Nil | Unset = Unset.instance) : Config

ameba:disable Metrics/CyclomaticComplexity

Source
debug(message : String) : Nil
Source
error(context : String, message : String) : Nil
Source
gray_placeholder_size

Google SVG placeholders are exactly 198 bytes when fetched from google.com/s2/favicons. Detecting this size allows us to fall back to a larger resolution.

Source
html_fetch_timeout
Source
image_validation_hard?
Source
load(url : String) : String | Nil
Source
max_concurrent_requests

NOTE: This setting controls the process-wide semaphore limit. Only the first-initialized value takes effect; subsequent Fetcher instances with different values will share the existing semaphore.

Source
max_redirects
Source
max_retries

Retry settings for transient failures (timeouts, socket errors, etc.)

Source
max_size
Source
on_debug
Source
on_error
Source
on_load
Source
on_log

Optional structured logging callback. When set, receives LogEntry objects alongside the existing level-specific callbacks.

Source
on_save
Source
on_warning
Source
retry_base_delay
Source
retry_max_delay
Source
save(url : String, data : Bytes, content_type : String) : String | Nil
Source
timeout
Source
user_agent
Source
warning(message : String) : Nil
Source
write_timeout
Source