2019-06-11 16:23:20 +00:00
|
|
|
package handler
|
2016-02-21 22:25:35 +00:00
|
|
|
|
2016-03-11 19:17:43 +00:00
|
|
|
// StoreComposer represents a composable data store. It consists of the core
|
|
|
|
// data store and optional extensions. Please consult the package's overview
|
|
|
|
// for a more detailed introduction in how to use this structure.
|
2016-02-21 22:25:35 +00:00
|
|
|
type StoreComposer struct {
|
|
|
|
Core DataStore
|
|
|
|
|
2018-05-13 14:27:38 +00:00
|
|
|
UsesTerminater bool
|
|
|
|
Terminater TerminaterDataStore
|
|
|
|
UsesLocker bool
|
2019-09-12 10:37:43 +00:00
|
|
|
Locker Locker
|
2018-05-13 14:27:38 +00:00
|
|
|
UsesConcater bool
|
|
|
|
Concater ConcaterDataStore
|
|
|
|
UsesLengthDeferrer bool
|
|
|
|
LengthDeferrer LengthDeferrerDataStore
|
2016-02-21 22:25:35 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 19:17:43 +00:00
|
|
|
// NewStoreComposer creates a new and empty store composer.
|
2016-02-21 22:25:35 +00:00
|
|
|
func NewStoreComposer() *StoreComposer {
|
|
|
|
return &StoreComposer{}
|
|
|
|
}
|
|
|
|
|
2016-03-11 19:17:43 +00:00
|
|
|
// Capabilities returns a string representing the provided extensions in a
|
|
|
|
// human-readable format meant for debugging.
|
2016-02-22 10:00:20 +00:00
|
|
|
func (store *StoreComposer) Capabilities() string {
|
|
|
|
str := "Core: "
|
|
|
|
|
|
|
|
if store.Core != nil {
|
|
|
|
str += "✓"
|
|
|
|
} else {
|
|
|
|
str += "✗"
|
|
|
|
}
|
|
|
|
|
|
|
|
str += ` Terminater: `
|
|
|
|
if store.UsesTerminater {
|
|
|
|
str += "✓"
|
|
|
|
} else {
|
|
|
|
str += "✗"
|
|
|
|
}
|
|
|
|
str += ` Locker: `
|
|
|
|
if store.UsesLocker {
|
|
|
|
str += "✓"
|
|
|
|
} else {
|
|
|
|
str += "✗"
|
|
|
|
}
|
|
|
|
str += ` Concater: `
|
|
|
|
if store.UsesConcater {
|
|
|
|
str += "✓"
|
|
|
|
} else {
|
|
|
|
str += "✗"
|
|
|
|
}
|
2018-05-13 14:27:38 +00:00
|
|
|
str += ` LengthDeferrer: `
|
|
|
|
if store.UsesLengthDeferrer {
|
|
|
|
str += "✓"
|
|
|
|
} else {
|
|
|
|
str += "✗"
|
|
|
|
}
|
2016-02-22 10:00:20 +00:00
|
|
|
|
|
|
|
return str
|
|
|
|
}
|
|
|
|
|
2016-03-11 19:17:43 +00:00
|
|
|
// UseCore will set the used core data store. If the argument is nil, the
|
|
|
|
// property will be unset.
|
2016-02-21 22:25:35 +00:00
|
|
|
func (store *StoreComposer) UseCore(core DataStore) {
|
|
|
|
store.Core = core
|
|
|
|
}
|
|
|
|
|
2016-03-11 19:17:43 +00:00
|
|
|
func (store *StoreComposer) UseTerminater(ext TerminaterDataStore) {
|
|
|
|
store.UsesTerminater = ext != nil
|
|
|
|
store.Terminater = ext
|
2016-02-21 22:25:35 +00:00
|
|
|
}
|
2019-08-24 13:14:51 +00:00
|
|
|
|
2019-09-12 10:37:43 +00:00
|
|
|
func (store *StoreComposer) UseLocker(ext Locker) {
|
2016-03-11 19:17:43 +00:00
|
|
|
store.UsesLocker = ext != nil
|
|
|
|
store.Locker = ext
|
2016-02-21 22:25:35 +00:00
|
|
|
}
|
2019-08-24 13:14:51 +00:00
|
|
|
|
2016-03-11 19:17:43 +00:00
|
|
|
func (store *StoreComposer) UseConcater(ext ConcaterDataStore) {
|
|
|
|
store.UsesConcater = ext != nil
|
|
|
|
store.Concater = ext
|
2016-02-21 22:25:35 +00:00
|
|
|
}
|
2018-05-13 14:27:38 +00:00
|
|
|
|
|
|
|
func (store *StoreComposer) UseLengthDeferrer(ext LengthDeferrerDataStore) {
|
|
|
|
store.UsesLengthDeferrer = ext != nil
|
|
|
|
store.LengthDeferrer = ext
|
|
|
|
}
|