Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb0bf0f

Browse files
committed
remove deleted pipelines from global active pipeline list
1 parent59bb2bf commiteb0bf0f

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

‎pipeline/pipeline.go‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ func (ap *ActivePipelines) Append(p gaia.Pipeline) {
8787
ap.Pipelines=append(ap.Pipelines,p)
8888
}
8989

90+
// Remove removes a pipeline at the given index from ActivePipelines.
91+
func (ap*ActivePipelines)Remove(indexint) {
92+
ap.Lock()
93+
deferap.Unlock()
94+
95+
ap.Pipelines=append(ap.Pipelines[:index],ap.Pipelines[index+1:]...)
96+
}
97+
9098
// GetByName looks up the pipeline by the given name.
9199
func (ap*ActivePipelines)GetByName(nstring)*gaia.Pipeline {
92100
varfoundPipeline gaia.Pipeline
@@ -157,6 +165,23 @@ func (ap *ActivePipelines) Contains(n string) bool {
157165
returnfoundPipeline
158166
}
159167

168+
// RemoveDeletedPipelines removes the pipelines whose names are NOT
169+
// present in `existingPipelineNames` from the given ActivePipelines instance.
170+
func (ap*ActivePipelines)RemoveDeletedPipelines(existingPipelineNames []string) {
171+
fori,pipeline:=rangeap.Pipelines {
172+
found:=false
173+
for_,name:=rangeexistingPipelineNames {
174+
ifpipeline.Name==name {
175+
found=true
176+
break
177+
}
178+
}
179+
if!found {
180+
ap.Remove(i)
181+
}
182+
}
183+
}
184+
160185
// appendTypeToName appends the type to the output binary name.
161186
// This allows us later to define the pipeline type by the name.
162187
funcappendTypeToName(nstring,pType gaia.PipelineType)string {

‎pipeline/ticker.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func InitTicker(store *store.Store, scheduler *scheduler.Scheduler) {
5858
// Every file will be handled as an active pipeline and therefore
5959
// saved in the global active pipelines slice.
6060
funccheckActivePipelines() {
61+
varexistingPipelineNames []string
6162
files,err:=ioutil.ReadDir(gaia.Cfg.PipelinePath)
6263
iferr!=nil {
6364
gaia.Cfg.Logger.Error("cannot read pipelines folder","error",err.Error(),"path",gaia.Cfg.PipelinePath)
@@ -78,6 +79,8 @@ func checkActivePipelines() {
7879
// Get real pipeline name and check if the global active pipelines slice
7980
// already contains it.
8081
pName:=getRealPipelineName(n,pType)
82+
// Add the real pipeline name to the slice of existing pipeline names.
83+
existingPipelineNames=append(existingPipelineNames,pName)
8184
ifGlobalActivePipelines.Contains(pName) {
8285
// If SHA256Sum is set, we should check if pipeline has been changed.
8386
p:=GlobalActivePipelines.GetByName(pName)
@@ -113,7 +116,7 @@ func checkActivePipelines() {
113116
continue
114117
}
115118

116-
// We couldn'tfinde the pipeline. Create a new one.
119+
// We couldn'tfind the pipeline. Create a new one.
117120
varshouldStore=false
118121
ifpipeline==nil {
119122
// Create pipeline object and fill it with information
@@ -152,6 +155,7 @@ func checkActivePipelines() {
152155
GlobalActivePipelines.Append(*pipeline)
153156
}
154157
}
158+
GlobalActivePipelines.RemoveDeletedPipelines(existingPipelineNames)
155159
}
156160

157161
// getPipelineType looks up for specific suffix on the given file name.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp