Print capabilities of data store at start time

This commit is contained in:
Marius 2016-02-22 11:00:20 +01:00
parent 27866110c3
commit aaf36de210
3 changed files with 70 additions and 0 deletions

View File

@ -106,6 +106,8 @@ func main() {
address := httpHost + ":" + httpPort address := httpHost + ":" + httpPort
stdout.Printf("Using %s as address to listen.\n", address) stdout.Printf("Using %s as address to listen.\n", address)
stdout.Printf(composer.Capabilities())
go func() { go func() {
for { for {
select { select {

View File

@ -42,6 +42,49 @@ func NewStoreComposerFromDataStore(store DataStore) *StoreComposer {
return composer return composer
} }
func (store *StoreComposer) Capabilities() string {
str := "Core: "
if store.Core != nil {
str += "✓"
} else {
str += "✗"
}
str += ` Terminater: `
if store.UsesTerminater {
str += "✓"
} else {
str += "✗"
}
str += ` Finisher: `
if store.UsesFinisher {
str += "✓"
} else {
str += "✗"
}
str += ` Locker: `
if store.UsesLocker {
str += "✓"
} else {
str += "✗"
}
str += ` GetReader: `
if store.UsesGetReader {
str += "✓"
} else {
str += "✗"
}
str += ` Concater: `
if store.UsesConcater {
str += "✓"
} else {
str += "✗"
}
return str
}
func (store *StoreComposer) UseCore(core DataStore) { func (store *StoreComposer) UseCore(core DataStore) {
store.Core = core store.Core = core
} }

View File

@ -12,6 +12,13 @@ package tusd
composer.Use ## TYPE (mod) \ composer.Use ## TYPE (mod) \
} }
#define USE_CAP(TYPE) str += ` TYPE: `; \
if store.Uses ## TYPE { \
str += "✓" \
} else { \
str += "✗" \
}
type StoreComposer struct { type StoreComposer struct {
Core DataStore Core DataStore
@ -39,6 +46,24 @@ func NewStoreComposerFromDataStore(store DataStore) *StoreComposer {
return composer return composer
} }
func (store *StoreComposer) Capabilities() string {
str := "Core: "
if store.Core != nil {
str += "✓"
} else {
str += "✗"
}
USE_CAP(Terminater)
USE_CAP(Finisher)
USE_CAP(Locker)
USE_CAP(GetReader)
USE_CAP(Concater)
return str
}
func (store *StoreComposer) UseCore(core DataStore) { func (store *StoreComposer) UseCore(core DataStore) {
store.Core = core store.Core = core
} }