This file contains hidden or 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
game | |
├── application | |
│ ├── deckselection | |
│ │ ├── commands.go # all commands | |
│ │ ├── commands_test.go # unit tests | |
│ │ ├── integration_test.go # driver adapter | |
│ │ ├── select_deck_command_handler.go # driver port definition and implementation | |
│ │ ├── select_deck_command_handler_test.go # driver adapter | |
│ │ ├── select_deck.go # domain logic | |
│ │ ├── select_deck_http_handler.go # driver adapter |
This file contains hidden or 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
game | |
├── application | |
│ ├── forselectingdecks | |
│ │ ├── command_handler.go # driver port definition and implementation | |
│ │ ├── command_handler_test.go # driver adapter | |
│ │ ├── command.go # command | |
│ │ ├── commandstest.go # unit tests | |
│ │ ├── http_handler.go # driver adapter | |
│ │ ├── integration_test.go # driver adapter | |
│ │ ├── select_deck.go # domain logic |
This file contains hidden or 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
# the coarse-grained version | |
type ForStoringEvents interface { | |
CreateEventStream(streamID lib.StreamID, event lib.Event) error | |
AppendEventsToStream( | |
streamID lib.StreamID, | |
expectedRevision uint64, | |
recordedEvents ...lib.Event, | |
) error | |
ReadEventStream(streamID lib.StreamID) (lib.EventStream, error) |
This file contains hidden or 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
# With function types instead of interfaces all ports are automatically fine-grained | |
type ForSelectingDecks func(command SelectDeckCommand) error | |
type ForUnselectingDecks func(command UnselectDeckCommand) error |
This file contains hidden or 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
# the coarse-grained version | |
type ForSelectingDecks interface { | |
Select(command SelectDeckCommand) error | |
Unselect(command UnselectDeckCommand) error | |
} | |
# the fine-grained version | |
type ForSelectingDecks interface { |
This file contains hidden or 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
package finishcard | |
import ( | |
"ace-life/hexagon/domain" | |
"ace-life/hexagon/usecases" | |
) | |
type CommandHandler struct { | |
drawReplacementCard usecases.ForDrawingReplacementCards | |
loadEventStream usecases.ForLoadingEventStreams |
This file contains hidden or 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
package finishcard | |
import ( | |
"ace-life/errtypes" | |
"ace-life/hexagon/domain" | |
"ace-life/hexagon/domain/player" | |
"ace-life/hexagon/events" | |
"ace-life/hexagon/usecases" | |
) |
This file contains hidden or 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
package functionsandinterfaces_test | |
import ( | |
"testing" | |
"github.com/matryer/is" | |
. "go-bits/magic-with-functions/functionsandinterfaces" | |
) |
This file contains hidden or 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
package functionsandinterfaces | |
type ForRegisteringCustomers interface { | |
Register(name, emailAddress string) error | |
} | |
type ForRegisteringCustomersFunc func(name, emailAddress string) error | |
// Register is a receiver method for the ForRegisteringCustomersFunc | |
// type that fullfills the ForRegisteringCustomers interface |
This file contains hidden or 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
type Handler interface { | |
ServeHTTP(ResponseWriter, *Request) | |
} |