-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef60a7c
commit 3005ba9
Showing
9 changed files
with
192 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package swipe_manager | ||
|
||
import ( | ||
repository "backend/graph/db" | ||
"github.com/m-mizutani/goerr" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type SwipeStrategy interface { | ||
ChangeState(ctx context.Context, swipeRecords []repository.SwipeRecord) error | ||
IsApplicable(records []repository.SwipeRecord) bool | ||
} | ||
|
||
type strategyExecutor struct { | ||
strategy SwipeStrategy | ||
} | ||
|
||
type StrategyExecutor interface { | ||
ExecuteStrategy(ctx context.Context, swipeRecords []repository.SwipeRecord) ([]repository.Card, error) | ||
} | ||
|
||
func NewStrategyExecutor(strategy SwipeStrategy) StrategyExecutor { | ||
return &strategyExecutor{ | ||
strategy: strategy, | ||
} | ||
} | ||
|
||
func (sc *strategyExecutor) ExecuteStrategy(ctx context.Context, swipeRecords []repository.SwipeRecord) ([]repository.Card, error) { | ||
err := sc.strategy.ChangeState(ctx, swipeRecords) | ||
if err != nil { | ||
return nil, goerr.Wrap(err) | ||
} | ||
return nil, nil | ||
} |