Skip to content

Commit a843839

Browse files
committed
TASK: add current release identifier as argument to release pipeline
1 parent 45375a4 commit a843839

4 files changed

Lines changed: 26 additions & 7 deletions

File tree

Classes/ContentReleaseManager.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Flowpack\DecoupledContentStore;
66

7+
use Flowpack\DecoupledContentStore\Core\Infrastructure\RedisClientManager;
78
use Neos\Flow\Annotations as Flow;
89
use Flowpack\Prunner\PrunnerApiService;
910
use Flowpack\Prunner\ValueObject\PipelineName;
@@ -26,16 +27,29 @@ class ContentReleaseManager
2627
*/
2728
protected $prunnerApiService;
2829

30+
/**
31+
* @Flow\Inject
32+
* @var RedisClientManager
33+
*/
34+
protected $redisClientManager;
35+
36+
const REDIS_CURRENT_RELEASE_KEY = 'contentStore:current';
37+
const NO_PREVIOUS_RELEASE = 'NO_PREVIOUS_RELEASE';
2938

3039
public function startIncrementalContentRelease()
3140
{
32-
$this->prunnerApiService->schedulePipeline(PipelineName::create('do_content_release'), ['contentReleaseId' => (string)time()]);
41+
$redis = $this->redisClientManager->getPrimaryRedis();
42+
$currentContentReleaseId = $redis->get(self::REDIS_CURRENT_RELEASE_KEY);
43+
44+
// the currentContentReleaseId is not used in any pipeline step in this package, but is a common need in other
45+
// use cases in extensions, e.g. calculating the differences between current and new release
46+
$this->prunnerApiService->schedulePipeline(PipelineName::create('do_content_release'), ['contentReleaseId' => (string)time(), 'currentContentReleaseId' => $currentContentReleaseId ?: self::NO_PREVIOUS_RELEASE]);
3347
}
3448

3549
public function startFullContentRelease()
3650
{
3751
$this->contentCache->flush();
38-
$this->prunnerApiService->schedulePipeline(PipelineName::create('do_content_release'), ['contentReleaseId' => (string)time()]);
52+
$this->prunnerApiService->schedulePipeline(PipelineName::create('do_content_release'), ['contentReleaseId' => (string)time(), 'currentContentReleaseId' => self::NO_PREVIOUS_RELEASE]);
3953
}
4054

4155
public function cancelAllRunningContentReleases()
@@ -46,4 +60,4 @@ public function cancelAllRunningContentReleases()
4660
$this->prunnerApiService->cancelJob($job);
4761
}
4862
}
49-
}
63+
}

Classes/Controller/BackendController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ public function switchAction(string $contentReleaseIdentifier, string $redisInst
159159

160160
public function switchContentReleaseOnOtherInstanceAction(string $targetRedisInstanceIdentifier, string $contentReleaseIdentifier)
161161
{
162+
$redis = $this->redisClientManager->getPrimaryRedis();
163+
$currentContentReleaseId = $redis->get('contentStore:current');
164+
162165
$this->prunnerApiService->schedulePipeline(PipelineName::create('manually_transfer_content_release'),
163-
['contentReleaseId' => $contentReleaseIdentifier, 'redisInstanceId' => $targetRedisInstanceIdentifier]);
166+
['contentReleaseId' => $contentReleaseIdentifier, 'currentContentReleaseId' => $currentContentReleaseId ?: ContentReleaseManager::NO_PREVIOUS_RELEASE, 'redisInstanceId' => $targetRedisInstanceIdentifier]);
164167

165168
$this->redirect('index', null, null, ['contentStore' => $targetRedisInstanceIdentifier]);
166169
}

Resources/Private/BackendFusion/Integration/Backend.Details.fusion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ prototype(Flowpack.DecoupledContentStore:DetailsFooter) < prototype(Neos.Fusion:
393393

394394
renderer = afx`
395395
<button form="postHelper" formaction={props._switchUri} type="submit" class="neos-button neos-button-warning neos-pull-right" @if.isNotPrimary={item != "primary"}>
396-
Transfer to {item}
396+
Transfer and switch on {item}
397397
</button>
398398
`
399399
}

pipelines_template.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
# The contents of this file is read by [prunner](https://github.com/Flowpack/prunner).
1010
#
1111
pipelines:
12-
# ARG: contentReleaseId
12+
# ARG: contentReleaseId, currentContentReleaseId
13+
# the currentContentReleaseId is not used in any pipeline step here in the template, but is a common need in other
14+
# use cases in extensions, e.g. calculating the differences between current and new release
1315
do_content_release:
1416

1517
# crucial settings for incremental rendering to work
@@ -200,7 +202,7 @@ pipelines:
200202

201203
# this subset of the pipeline above is running when a release is manually transfered and switched live
202204
# from the primary content store to any other content store
203-
# ARG: contentReleaseId, redisInstanceId
205+
# ARG: contentReleaseId, currentContentReleaseId, redisInstanceId
204206
manually_transfer_content_release:
205207
# just to be safe, we want to run manual transfers one-by-one (without concurrency)
206208
concurrency: 1

0 commit comments

Comments
 (0)