-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- skip inserting transactions - add manual toggle in Site Admin tasks
- Loading branch information
1 parent
42dd82e
commit d30f6c9
Showing
3 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
html-templates/site-admin/tasks/configuration/skip-insert-transactions.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{extends "task.tpl"} | ||
|
||
{block content} | ||
<h4> | ||
<b>Skip Insert Transaction (Degradation Mode):</b> <u>{tif $enabled ? Active : Inactive}</u> | ||
</h4> | ||
|
||
<form method="post"> | ||
<div class="checkbox"> | ||
<label>Enable | ||
<input type="radio" name="status" value="enable" placeholder="Enabled" {tif $enabled ? checked} /> | ||
</label> | ||
<label>Disable | ||
<input type="radio" name="status" value="disable" placeholder="Disabled" {tif $enabled == false ? checked} /> | ||
</label> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label>TTL | ||
<input type="number" min="60" name="ttl" placeholder="ttl seconds" value="{$ttl}"> | ||
</label> | ||
</div> | ||
|
||
<button type="submit" class="btn btn-primary">{tif $enabled ? Dis : En}able Degradation Mode</button> | ||
</form> | ||
{/block} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
return [ | ||
'title' => 'Skip Transaction Inserts (Degradation Mode)', | ||
'description' => 'Enable or disable degredation mode which skips saving transactions to the DB. This functionality aids with the speed of requests with sites while under failure or high load', | ||
'icon' => 'power-off', | ||
'handler' => function () { | ||
$flag = 'flags/gatekeeper/skip-insert-transaction'; | ||
$ttl = $_REQUEST['ttl'] ?: Gatekeeper\ApiRequestHandler::$degradationTimeout; | ||
|
||
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | ||
if ($_REQUEST['status'] == 'enable') { | ||
Cache::store($flag, true, $ttl); | ||
} else { | ||
Cache::delete($flag); | ||
} | ||
} | ||
|
||
return static::respond('skip-insert-transactions', [ | ||
'ttl' => $ttl, | ||
'enabled' => !!Cache::fetch($flag) | ||
]); | ||
} | ||
]; |