Skip to content

Commit

Permalink
Add length deferrer support to composer
Browse files Browse the repository at this point in the history
  • Loading branch information
acj committed Jun 3, 2018
1 parent 55f99cb commit d40c50f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
36 changes: 26 additions & 10 deletions composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ package tusd
type StoreComposer struct {
Core DataStore

UsesTerminater bool
Terminater TerminaterDataStore
UsesFinisher bool
Finisher FinisherDataStore
UsesLocker bool
Locker LockerDataStore
UsesGetReader bool
GetReader GetReaderDataStore
UsesConcater bool
Concater ConcaterDataStore
UsesTerminater bool
Terminater TerminaterDataStore
UsesFinisher bool
Finisher FinisherDataStore
UsesLocker bool
Locker LockerDataStore
UsesGetReader bool
GetReader GetReaderDataStore
UsesConcater bool
Concater ConcaterDataStore
UsesLengthDeferrer bool
LengthDeferrer LengthDeferrerDataStore
}

// NewStoreComposer creates a new and empty store composer.
Expand Down Expand Up @@ -45,6 +47,9 @@ func newStoreComposerFromDataStore(store DataStore) *StoreComposer {
if mod, ok := store.(ConcaterDataStore); ok {
composer.UseConcater(mod)
}
if mod, ok := store.(LengthDeferrerDataStore); ok {
composer.UseLengthDeferrer(mod)
}

return composer
}
Expand Down Expand Up @@ -90,6 +95,12 @@ func (store *StoreComposer) Capabilities() string {
} else {
str += "✗"
}
str += ` LengthDeferrer: `
if store.UsesLengthDeferrer {
str += "✓"
} else {
str += "✗"
}

return str
}
Expand Down Expand Up @@ -120,3 +131,8 @@ func (store *StoreComposer) UseConcater(ext ConcaterDataStore) {
store.UsesConcater = ext != nil
store.Concater = ext
}

func (store *StoreComposer) UseLengthDeferrer(ext LengthDeferrerDataStore) {
store.UsesLengthDeferrer = ext != nil
store.LengthDeferrer = ext
}
4 changes: 4 additions & 0 deletions composer.mgo
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type StoreComposer struct {
USE_FIELD(Locker)
USE_FIELD(GetReader)
USE_FIELD(Concater)
USE_FIELD(LengthDeferrer)
}

// NewStoreComposer creates a new and empty store composer.
Expand All @@ -50,6 +51,7 @@ func newStoreComposerFromDataStore(store DataStore) *StoreComposer {
USE_FROM(Locker)
USE_FROM(GetReader)
USE_FROM(Concater)
USE_FROM(LengthDeferrer)

return composer
}
Expand All @@ -70,6 +72,7 @@ func (store *StoreComposer) Capabilities() string {
USE_CAP(Locker)
USE_CAP(GetReader)
USE_CAP(Concater)
USE_CAP(LengthDeferrer)

return str
}
Expand All @@ -85,3 +88,4 @@ USE_FUNC(Finisher)
USE_FUNC(Locker)
USE_FUNC(GetReader)
USE_FUNC(Concater)
USE_FUNC(LengthDeferrer)

0 comments on commit d40c50f

Please sign in to comment.