comparison pkg/imports/queue.go @ 1495:d26e3e1fcff1

The global import queue already knows which kinds of imports it supports. So there is no need to have another table to track these as a list. This is only a thing which can async potentially. So this list is removed.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 04 Dec 2018 18:20:31 +0100
parents 74b0df86b6e6
children b41ad15cc55f
comparison
equal deleted inserted replaced
1494:04967d6565fa 1495:d26e3e1fcff1
151 151
152 func FindJobCreator(kind JobKind) JobCreator { 152 func FindJobCreator(kind JobKind) JobCreator {
153 return iqueue.jobCreator(kind) 153 return iqueue.jobCreator(kind)
154 } 154 }
155 155
156 func ImportKindNames() []string {
157 return iqueue.importKindNames()
158 }
159
156 func RegisterJobCreator(kind JobKind, jc JobCreator) { 160 func RegisterJobCreator(kind JobKind, jc JobCreator) {
157 log.Printf("info: register import job creator for kind '%s'\n", kind) 161 log.Printf("info: register import job creator for kind '%s'\n", kind)
158 iqueue.registerJobCreator(kind, jc) 162 iqueue.registerJobCreator(kind, jc)
163 }
164
165 func (q *importQueue) importKindNames() []string {
166 q.creatorsMu.Lock()
167 defer q.creatorsMu.Unlock()
168 names := make([]string, len(q.creators))
169 var i int
170 for kind := range q.creators {
171 names[i] = string(kind)
172 i++
173 }
174 // XXX: Consider using sort.Strings to make output deterministic.
175 return names
159 } 176 }
160 177
161 func (q *importQueue) jobCreator(kind JobKind) JobCreator { 178 func (q *importQueue) jobCreator(kind JobKind) JobCreator {
162 q.creatorsMu.Lock() 179 q.creatorsMu.Lock()
163 defer q.creatorsMu.Unlock() 180 defer q.creatorsMu.Unlock()