Skip to content
This repository was archived by the owner on Nov 9, 2020. It is now read-only.

Commit 08d1fad

Browse files
committed
Switch over to a generic remote queue package
1 parent e6bd75a commit 08d1fad

22 files changed

+4268
-476
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

README.md

Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,36 @@
1-
# BIIGLE GPU Module
1+
# Remote Queue
22

3-
Handle communication between BIIGLE and the BIIGLE GPU server.
3+
Submit jobs to other Laravel or Lumen instances.
44

55
## Installation
66

7-
This module needs to be installed both for the BIIGLE instance and the GPU server.
8-
97
```
10-
composer config repositories.gpu vcs https://github.com/biigle/gpu
11-
composer require biigle/gpu
8+
composer config repositories.laravel-remote-queue vcs https://github.com/biigle/larave-remote-queue
9+
composer require biigle/laravel-remote-queue
1210
```
1311

14-
### BIIGLE
12+
### Laravel
1513

16-
The service provider and `Gpu` facade are auto discovered by BIIGLE.
14+
The service provider is auto-discovered by Laravel.
1715

18-
### GPU Server
16+
### Lumen
1917

20-
Add `$app->register(Biigle\Modules\Gpu\GpuServerServiceProvider::class);` to `bootstrap/app.php`.
18+
Add `$app->register(Biigle\RemoteQueue\RemoteQueueServiceProvider::class);` to `bootstrap/app.php`.
2119

2220
## Configuration
2321

2422
todo
2523

2624
## Usage
2725

28-
To submit a job to the GPU server, it must extend `Biigle\Modules\Gpu\Jobs\GpuJob`. A job instance can be submitted with `Gpu::push($job)` and will be executed on the GPU server. To return the result data back to the BIIGLE instance, the job must call `$this->submitResponse($response)` at the end of its `handle` method. The response object must extend `Biigle\Jobs\Job` and will be executed on the BIIGLE instance where it can handle storage of the result data.
29-
30-
Be aware that the GPU server has no database access. All required information needs to be stored in the `GpuJob`.
31-
32-
**Example:**
33-
3426
```php
35-
use Gpu;
36-
use Biigle\Jobs\Job;
37-
use Biigle\Modules\Gpu\Jobs\GpuJob;
27+
use App\Jobs\MyJob;
3828

39-
/*
40-
* Instances of this class are submitted to the GPU server with Gpu::push().
41-
*/
42-
class MyGpuJob extends GpuJob
43-
{
44-
/*
45-
* Instances of this class are created in BIIGLE.
46-
*/
47-
public function __construct($data)
48-
{
49-
$this->data = $data;
50-
}
51-
52-
/*
53-
* But the handle() method is executed on the GPU server.
54-
*/
55-
public function handle()
56-
{
57-
$result = $this->computeGpuStuff($data);
58-
$this->submitResponse(new MyGpuResponse($result));
59-
}
60-
}
29+
MyJob::dispatch($data)->onConnection('remote');
30+
```
6131

62-
/*
63-
* Instances of this class are used as argument for GpuJob::submitResponse.
64-
*/
65-
class MyGpuResponse extends Job
66-
{
67-
/*
68-
* Instances of this class are created on the GPU server.
69-
*/
70-
public function __construct($result)
71-
{
72-
$this->result = $result;
73-
}
32+
## Submit/Response Pattern
7433

75-
/*
76-
* But the handle() method is executed in BIIGLE.
77-
*/
78-
public function handle()
79-
{
80-
$this->storeResultInDatabase($this->result);
81-
}
82-
}
34+
We developed this package to be able to process jobs on a remote machine with GPU. To return the computed results, we applied what we call the "submit/response" pattern.
8335

84-
// In the BIIGLE instance:
85-
Gpu::push(new MyGpuJob('some data'));
86-
```
36+
In this pattern, this package is installed on both Laravel/Lumen instances (let's call them A and B). In instance A, the remote queue is configured to push jobs to instance B (the one with the GPU). In instance B, the remote queue is configured to push jobs to instance A. New GPU jobs are submitted from instance A to the remote queue on instance B. Once the results are computed, they are returned as a "response job" to the remote queue on instance A where the results can be further processed.

composer.json

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "biigle/gpu",
3-
"description": "Handle communication between BIIGLE and the BIIGLE GPU server.",
2+
"name": "biigle/laravel-remote-queue",
3+
"description": "Submit jobs to another Laravel or Lumen instance.",
44
"type": "library",
55
"authors": [
66
{
@@ -9,21 +9,33 @@
99
}
1010
],
1111
"require": {
12-
"guzzlehttp/guzzle": "~6.0"
12+
"guzzlehttp/guzzle": "~6.0",
13+
"illuminate/queue": "^5.5",
14+
"illuminate/support": "^5.5",
15+
"illuminate/contracts": "^5.5"
1316
},
1417
"autoload": {
1518
"psr-4": {
16-
"Biigle\\Modules\\Gpu\\": "src"
19+
"Biigle\\RemoteQueue\\": "src"
1720
}
1821
},
22+
"autoload-dev": {
23+
"psr-4": {
24+
"Biigle\\RemoteQueue\\Tests\\": "tests/"
25+
},
26+
"classmap": [
27+
"tests/TestCase.php"
28+
]
29+
},
1930
"extra": {
2031
"laravel": {
2132
"providers": [
22-
"Biigle\\Modules\\Gpu\\GpuServiceProvider"
23-
],
24-
"aliases": {
25-
"Gpu": "Biigle\\Modules\\Gpu\\Facades\\Gpu"
26-
}
33+
"Biigle\\RemoteQueue\\RemoteQueueServiceProvider"
34+
]
2735
}
36+
},
37+
"require-dev": {
38+
"laravel/laravel": "^5.5",
39+
"phpunit/phpunit": "^7.4"
2840
}
2941
}

0 commit comments

Comments
 (0)