Skip to content
This repository has been archived by the owner. It is now read-only.

Commit 2b04a61

Browse files
Add tags for Horizon
1 parent 8428e45 commit 2b04a61

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

src/Scraper/Events/InvalidConfiguration.php

+18
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,22 @@ public function __construct(ScrapeRequest $scrapeRequest)
1313
{
1414
$this->scrapeRequest = $scrapeRequest;
1515
}
16+
17+
/**
18+
* Get the tags that should be assigned to the job.
19+
*
20+
* Only if you are using Horizon
21+
*
22+
* @see https://laravel.com/docs/5.8/horizon#tags
23+
*
24+
* @return array
25+
*/
26+
public function tags()
27+
{
28+
$type = $this->scrapeRequest->type;
29+
30+
return [
31+
"reconfigure_type:$type",
32+
];
33+
}
1634
}

src/Scraper/Events/ScrapeFailed.php

+18
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,22 @@ public function __construct(ScrapeRequest $scrapeRequest)
2323
{
2424
$this->scrapeRequest = $scrapeRequest;
2525
}
26+
27+
/**
28+
* Get the tags that should be assigned to the job.
29+
*
30+
* Only if you are using Horizon
31+
*
32+
* @see https://laravel.com/docs/5.8/horizon#tags
33+
*
34+
* @return array
35+
*/
36+
public function tags()
37+
{
38+
$type = $this->scrapeRequest->type;
39+
40+
return [
41+
"failed_type:$type",
42+
];
43+
}
2644
}

src/Scraper/Events/ScrapeRequest.php

+18
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,22 @@ public function __construct(string $url, string $type)
3030
$this->url = $url;
3131
$this->type = $type;
3232
}
33+
34+
/**
35+
* Get the tags that should be assigned to the job.
36+
*
37+
* Only if you are using Horizon
38+
*
39+
* @see https://laravel.com/docs/5.8/horizon#tags
40+
*
41+
* @return array
42+
*/
43+
public function tags()
44+
{
45+
$type = $this->type;
46+
47+
return [
48+
"request_type:$type",
49+
];
50+
}
3351
}

src/Scraper/Events/Scraped.php

+20
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,24 @@ public function __construct(ScrapeRequest $scrapeRequest, array $data, string $v
3737
$this->data = $data;
3838
$this->variant = $variant;
3939
}
40+
41+
/**
42+
* Get the tags that should be assigned to the job.
43+
*
44+
* Only if you are using Horizon
45+
*
46+
* @see https://laravel.com/docs/5.8/horizon#tags
47+
*
48+
* @return array
49+
*/
50+
public function tags()
51+
{
52+
$type = $this->scrapeRequest->type;
53+
$variant = $this->variant;
54+
55+
return [
56+
"scraped_type:$type",
57+
"scraped_variant:$variant",
58+
];
59+
}
4060
}

0 commit comments

Comments
 (0)