every go routine needs to have its own collection factory

this is needed so concurrent reads and writes are possible.
This commit is contained in:
Oliver Sauder authored and Lorenzo Bolla committed 2022-01-27 09:30:14 +01:00
1 parent 4a6d53e16d
commit 208a2151c1
48 files changed
+305 -387

No files matched your search

+6 -11
View File
@@ -44,7 +44,6 @@ type AptlyContext struct {
database database.Storage
packagePool aptly.PackagePool
publishedStorages map[string]aptly.PublishedStorage
collectionFactory *deb.CollectionFactory
dependencyOptions int
architecturesList []string
// Debug features
@@ -309,20 +308,16 @@ func (context *AptlyContext) ReOpenDatabase() error {
return err
}
// CollectionFactory builds factory producing all kinds of collections
func (context *AptlyContext) CollectionFactory() *deb.CollectionFactory {
// NewCollectionFactory builds factory producing all kinds of collections
func (context *AptlyContext) NewCollectionFactory() *deb.CollectionFactory {
context.Lock()
defer context.Unlock()
if context.collectionFactory == nil {
db, err := context._database()
if err != nil {
Fatal(err)
}
context.collectionFactory = deb.NewCollectionFactory(db)
db, err := context._database()
if err != nil {
Fatal(err)
}
return context.collectionFactory
return deb.NewCollectionFactory(db)
}
// PackagePool returns instance of PackagePool