Sha256: c4148becd618b85127fa48d420d9f2531b81e86dd79d71534f5f6c50ab0b827e

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

# Jobs

Jobs are Ruby classes that look as follows:

```ruby
class DummyJob < Wayfarer::Base
  route.to :index

  def index
  end
end
```

## Current task

Jobs consume [tasks](../tasks) from a message queue. The currently processed
task is accessible like so:

```ruby
class DummyJob < Wayfarer::Base
  route.to :index

  def index
    task.url   # => "https://example.com"
    task.batch # => "55fe80d4-97ce-..."
  end
end
```

## Current page

Once control is handed over to jobs, their task's URL has been retrieved into a
[page](../pages) object:

```ruby
class DummyJob < Wayfarer::Base
  route.to :index

  def index
    page.url  # => "https://example.com"
    page.body # => "<html>..."
  end
end
```

## URL parameters

TODO

```ruby
class DummyJob < Wayfarer::Base
  route.to :index

  def index
    page.url  # => "https://example.com"
    page.body # => "<html>..."
  end
end
```


## Automated browser

When automating browsers, the remote browser process that retrieved the URL is
accessible like so:

```ruby
class DummyJob < Wayfarer::Base
  route.to :index

  def index
    browser # => #<Ferrum::Browser ...> or #<Selenium::WebDriver ...>
  end
end
```

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wayfarer-0.4.1 docs/guides/jobs.md
wayfarer-0.4.0 docs/guides/jobs.md