Skip to content

Commit

Permalink
Change usages of resolve to app to avoid conflicts with hoaproject\We…
Browse files Browse the repository at this point in the history
…bsocket
  • Loading branch information
dongilbert committed Jan 4, 2018
1 parent 0979469 commit 99e0ded
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/Console/ContinueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ContinueCommand extends Command
*/
public function handle()
{
$masters = resolve(MasterSupervisorRepository::class)->all();
$masters = app(MasterSupervisorRepository::class)->all();

$masters = collect($masters)->filter(function ($master) {
return Str::startsWith($master->name, MasterSupervisor::basename());
Expand Down
2 changes: 1 addition & 1 deletion src/Console/HorizonCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class HorizonCommand extends Command
*/
public function handle()
{
$repository = resolve(MasterSupervisorRepository::class);
$repository = app(MasterSupervisorRepository::class);

if ($repository->find(MasterSupervisor::name())) {
return $this->comment('A master supervisor is already running on this machine.');
Expand Down
2 changes: 1 addition & 1 deletion src/Console/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ListCommand extends Command
*/
public function handle()
{
$repository = resolve(MasterSupervisorRepository::class);
$repository = app(MasterSupervisorRepository::class);

$masters = $repository->all();

Expand Down
2 changes: 1 addition & 1 deletion src/Console/PauseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PauseCommand extends Command
*/
public function handle()
{
$masters = resolve(MasterSupervisorRepository::class)->all();
$masters = app(MasterSupervisorRepository::class)->all();

$masters = collect($masters)->filter(function ($master) {
return Str::startsWith($master->name, MasterSupervisor::basename());
Expand Down
2 changes: 1 addition & 1 deletion src/Console/PurgeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function purge($master,
protected function recordOrphans($master, ProcessRepository $processes)
{
$processes->orphaned(
$master, $orphans = resolve(ProcessInspector::class)->orphaned()
$master, $orphans = app(ProcessInspector::class)->orphaned()
);

foreach ($orphans as $processId) {
Expand Down
4 changes: 2 additions & 2 deletions src/Console/SnapshotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class SnapshotCommand extends Command
*/
public function handle()
{
if (resolve(Lock::class)->get('metrics:snapshot', 300)) {
resolve(MetricsRepository::class)->snapshot();
if (app(Lock::class)->get('metrics:snapshot', 300)) {
app(MetricsRepository::class)->snapshot();

$this->info('Metrics snapshot stored successfully.');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Console/SupervisorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SupervisorCommand extends Command
*/
public function handle()
{
$supervisor = resolve(SupervisorFactory::class)->make(
$supervisor = app(SupervisorFactory::class)->make(
$this->supervisorOptions()
);

Expand Down
2 changes: 1 addition & 1 deletion src/Console/SupervisorsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SupervisorsCommand extends Command
*/
public function handle()
{
$repository = resolve(SupervisorRepository::class);
$repository = app(SupervisorRepository::class);

$supervisors = $repository->all();

Expand Down
2 changes: 1 addition & 1 deletion src/Console/TerminateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TerminateCommand extends Command
*/
public function handle()
{
$masters = resolve(MasterSupervisorRepository::class)->all();
$masters = app(MasterSupervisorRepository::class)->all();

$masters = collect($masters)->filter(function ($master) {
return Str::startsWith($master->name, MasterSupervisor::basename());
Expand Down
16 changes: 8 additions & 8 deletions src/Http/Controllers/DashboardStatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class DashboardStatsController extends Controller
public function index()
{
return [
'jobsPerMinute' => resolve(MetricsRepository::class)->jobsProcessedPerMinute(),
'jobsPerMinute' => app(MetricsRepository::class)->jobsProcessedPerMinute(),
'processes' => $this->totalProcessCount(),
'queueWithMaxRuntime' => resolve(MetricsRepository::class)->queueWithMaximumRuntime(),
'queueWithMaxThroughput' => resolve(MetricsRepository::class)->queueWithMaximumThroughput(),
'recentlyFailed' => resolve(JobRepository::class)->countRecentlyFailed(),
'recentJobs' => resolve(JobRepository::class)->countRecent(),
'queueWithMaxRuntime' => app(MetricsRepository::class)->queueWithMaximumRuntime(),
'queueWithMaxThroughput' => app(MetricsRepository::class)->queueWithMaximumThroughput(),
'recentlyFailed' => app(JobRepository::class)->countRecentlyFailed(),
'recentJobs' => app(JobRepository::class)->countRecent(),
'status' => $this->currentStatus(),
'wait' => collect(resolve(WaitTimeCalculator::class)->calculate())->take(1),
'wait' => collect(app(WaitTimeCalculator::class)->calculate())->take(1),
];
}

Expand All @@ -36,7 +36,7 @@ public function index()
*/
protected function totalProcessCount()
{
$supervisors = resolve(SupervisorRepository::class)->all();
$supervisors = app(SupervisorRepository::class)->all();

return collect($supervisors)->reduce(function ($carry, $supervisor) {
return $carry + collect($supervisor->processes)->sum();
Expand All @@ -50,7 +50,7 @@ protected function totalProcessCount()
*/
protected function currentStatus()
{
if (! $masters = resolve(MasterSupervisorRepository::class)->all()) {
if (! $masters = app(MasterSupervisorRepository::class)->all()) {
return 'inactive';
}

Expand Down
2 changes: 1 addition & 1 deletion src/JobId.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function generate()
return call_user_func(static::$generator);
}

return resolve(JobRepository::class)->nextJobId();
return app(JobRepository::class)->nextJobId();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Listeners/ExpireSupervisors.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ExpireSupervisors
*/
public function handle(MasterSupervisorLooped $event)
{
resolve(MasterSupervisorRepository::class)->flushExpired();
app(MasterSupervisorRepository::class)->flushExpired();

resolve(SupervisorRepository::class)->flushExpired();
app(SupervisorRepository::class)->flushExpired();
}
}
2 changes: 1 addition & 1 deletion src/Listeners/MonitorWaitTimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function handle(SupervisorLooped $event)
// Here we will calculate the wait time in seconds for each of the queues that
// the application is working. Then, we will filter the results to find the
// queues with the longest wait times and raise events for each of these.
$results = resolve(WaitTimeCalculator::class)->calculate();
$results = app(WaitTimeCalculator::class)->calculate();

$long = collect($results)->filter(function ($wait, $queue) {
return $wait > (config("horizon.waits.{$queue}") ?? 60);
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/SendNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function handle($event)
{
$notification = $event->toNotification();

if (! resolve(Lock::class)->get('notification:'.$notification->signature(), 300)) {
if (! app(Lock::class)->get('notification:'.$notification->signature(), 300)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/TrimFailedJobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function handle(MasterSupervisorLooped $event)
}

if ($this->lastTrimmed->lte(Chronos::now()->subMinutes($this->frequency))) {
resolve(JobRepository::class)->trimFailedJobs();
app(JobRepository::class)->trimFailedJobs();

$this->lastTrimmed = Chronos::now();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/TrimRecentJobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function handle(MasterSupervisorLooped $event)
}

if ($this->lastTrimmed->lte(Chronos::now()->subMinutes($this->frequency))) {
resolve(JobRepository::class)->trimRecentJobs();
app(JobRepository::class)->trimRecentJobs();

$this->lastTrimmed = Chronos::now();
}
Expand Down
18 changes: 9 additions & 9 deletions src/MasterSupervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct()
//
};

resolve(HorizonCommandQueue::class)->flush($this->commandQueue());
app(HorizonCommandQueue::class)->flush($this->commandQueue());
}

/**
Expand Down Expand Up @@ -161,13 +161,13 @@ public function terminate($status = 0)
// active supervisors so we know the maximum amount of time to wait here.
$this->supervisors->each->terminate();

$longest = resolve(SupervisorRepository::class)
$longest = app(SupervisorRepository::class)
->longestActiveTimeout();

// We will go ahead and remove this master supervisor's record from storage so
// another master supervisor could get started in its place without waiting
// for it to really finish terminating all of its underlying supervisors.
resolve(MasterSupervisorRepository::class)
app(MasterSupervisorRepository::class)
->forget($this->name);

$startedTerminating = Chronos::now();
Expand Down Expand Up @@ -215,7 +215,7 @@ public function monitor()
*/
public function ensureNoOtherMasterSupervisors()
{
if (resolve(MasterSupervisorRepository::class)->find($this->name) !== null) {
if (app(MasterSupervisorRepository::class)->find($this->name) !== null) {
throw new Exception('A master supervisor is already running on this machine.');
}
}
Expand All @@ -238,9 +238,9 @@ public function loop()

event(new MasterSupervisorLooped($this));
} catch (Exception $e) {
resolve(ExceptionHandler::class)->report($e);
app(ExceptionHandler::class)->report($e);
} catch (Throwable $e) {
resolve(ExceptionHandler::class)->report(new FatalThrowableError($e));
app(ExceptionHandler::class)->report(new FatalThrowableError($e));
}
}

Expand All @@ -251,8 +251,8 @@ public function loop()
*/
protected function processPendingCommands()
{
foreach (resolve(HorizonCommandQueue::class)->pending($this->commandQueue()) as $command) {
resolve($command->command)->process($this, $command->options);
foreach (app(HorizonCommandQueue::class)->pending($this->commandQueue()) as $command) {
app($command->command)->process($this, $command->options);
}
}

Expand All @@ -275,7 +275,7 @@ protected function monitorSupervisors()
*/
public function persist()
{
resolve(MasterSupervisorRepository::class)->update($this);
app(MasterSupervisorRepository::class)->update($this);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/ProcessInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function orphaned()
*/
public function monitoring()
{
return collect(resolve(SupervisorRepository::class)->all())
return collect(app(SupervisorRepository::class)->all())
->pluck('pid')
->pipe(function ($processes) {
$processes->each(function ($process) use (&$processes) {
Expand All @@ -65,7 +65,7 @@ public function monitoring()
return $processes;
})
->merge(
array_pluck(resolve(MasterSupervisorRepository::class)->all(), 'pid')
array_pluck(app(MasterSupervisorRepository::class)->all(), 'pid')
)->all();
}
}
2 changes: 1 addition & 1 deletion src/ProvisioningPlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function deploy($environment)
*/
protected function add(SupervisorOptions $options)
{
resolve(HorizonCommandQueue::class)->push(
app(HorizonCommandQueue::class)->push(
MasterSupervisor::commandQueueFor($this->master),
AddSupervisor::class,
$options->toArray()
Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/RedisMasterSupervisorRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function forget($name)
return;
}

resolve(SupervisorRepository::class)->forget(
app(SupervisorRepository::class)->forget(
$master->supervisors
);

Expand Down
4 changes: 2 additions & 2 deletions src/Repositories/RedisMetricsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ protected function storeSnapshotForQueue($queue)
'snapshot:'.$key, $time = Chronos::now()->getTimestamp(), json_encode([
'throughput' => $data['throughput'],
'runtime' => $data['runtime'],
'wait' => resolve(WaitTimeCalculator::class)->calculateFor($queue),
'wait' => app(WaitTimeCalculator::class)->calculateFor($queue),
'time' => $time,
])
);
Expand Down Expand Up @@ -358,7 +358,7 @@ protected function storeSnapshotTimestamp()
*/
public function acquireWaitTimeMonitorLock()
{
return resolve(Lock::class)->get('monitor:time-to-clear');
return app(Lock::class)->get('monitor:time-to-clear');
}

/**
Expand Down
20 changes: 10 additions & 10 deletions src/Supervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __construct(SupervisorOptions $options)
//
};

resolve(HorizonCommandQueue::class)->flush($this->name);
app(HorizonCommandQueue::class)->flush($this->name);
}

/**
Expand Down Expand Up @@ -217,7 +217,7 @@ public function terminate($status = 0)
// We will mark this supervisor as terminating so that any user interface can
// correctly show the supervisor's status. Then, we will scale the process
// pools down to zero workers to gracefully terminate them all out here.
resolve(SupervisorRepository::class)
app(SupervisorRepository::class)
->forget($this->name);

$this->processPools->each->scale(0);
Expand Down Expand Up @@ -260,7 +260,7 @@ public function monitor()
*/
public function ensureNoDuplicateSupervisors()
{
if (resolve(SupervisorRepository::class)->find($this->name) !== null) {
if (app(SupervisorRepository::class)->find($this->name) !== null) {
throw new Exception("A supervisor with the name [{$this->name}] is already running.");
}
}
Expand Down Expand Up @@ -291,9 +291,9 @@ public function loop()

event(new SupervisorLooped($this));
} catch (Exception $e) {
resolve(ExceptionHandler::class)->report($e);
app(ExceptionHandler::class)->report($e);
} catch (Throwable $e) {
resolve(ExceptionHandler::class)->report(new FatalThrowableError($e));
app(ExceptionHandler::class)->report(new FatalThrowableError($e));
}
}

Expand All @@ -304,8 +304,8 @@ public function loop()
*/
protected function processPendingCommands()
{
foreach (resolve(HorizonCommandQueue::class)->pending($this->name) as $command) {
resolve($command->command)->process($this, $command->options);
foreach (app(HorizonCommandQueue::class)->pending($this->name) as $command) {
app($command->command)->process($this, $command->options);
}
}

Expand All @@ -322,7 +322,7 @@ protected function autoScale()
if (Chronos::now()->subSeconds($this->autoScaleCooldown)->gte($this->lastAutoScaled)) {
$this->lastAutoScaled = Chronos::now();

resolve(AutoScaler::class)->scale($this);
app(AutoScaler::class)->scale($this);
}
}

Expand All @@ -333,7 +333,7 @@ protected function autoScale()
*/
public function persist()
{
resolve(SupervisorRepository::class)->update($this);
app(SupervisorRepository::class)->update($this);
}

/**
Expand Down Expand Up @@ -395,7 +395,7 @@ public function totalProcessCount()
*/
public function totalSystemProcessCount()
{
return resolve(SystemProcessCounter::class)->get($this->name);
return app(SystemProcessCounter::class)->get($this->name);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/SupervisorProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function monitor()
*/
protected function reprovision()
{
resolve(HorizonCommandQueue::class)->push(
app(HorizonCommandQueue::class)->push(
MasterSupervisor::commandQueue(),
AddSupervisor::class,
$this->options->toArray()
Expand All @@ -127,7 +127,7 @@ protected function reprovision()
*/
public function terminateWithStatus($status)
{
resolve(HorizonCommandQueue::class)->push(
app(HorizonCommandQueue::class)->push(
$this->options->name, Terminate::class, ['status' => $status]
);
}
Expand Down

0 comments on commit 99e0ded

Please sign in to comment.