mirror of https://github.com/dtm-labs/dtm.git
csharpjavadistributed-transactionsdtmgogolangmicroservicenodejsphpdatabasesagaseatatcctransactiontransactionsxapythondistributed
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
449 B
25 lines
449 B
package registry
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/dtm-labs/dtm/dtmsvr/storage"
|
|
)
|
|
|
|
// SingletonFactory is the factory to build store in SINGLETON pattern.
|
|
type SingletonFactory struct {
|
|
once sync.Once
|
|
|
|
store storage.Store
|
|
|
|
creatorFunction func() storage.Store
|
|
}
|
|
|
|
// GetStorage implement the StorageFactory.GetStorage
|
|
func (f *SingletonFactory) GetStorage() storage.Store {
|
|
f.once.Do(func() {
|
|
f.store = f.creatorFunction()
|
|
})
|
|
|
|
return f.store
|
|
}
|
|
|