Skip to content

Instantly share code, notes, and snippets.

@AntonStoeckl
Last active May 20, 2022 10:58
Show Gist options
  • Save AntonStoeckl/087bdf14fbbf430990005a3697f62002 to your computer and use it in GitHub Desktop.
Save AntonStoeckl/087bdf14fbbf430990005a3697f62002 to your computer and use it in GitHub Desktop.
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity"
# 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)
}
# the fine-grained version
type ForCreatingEventStreams interface {
Create(streamID lib.StreamID, event lib.Event) error
}
type ForAppendingEventsToStreams interface {
Append(
streamID lib.StreamID,
expectedRevision uint64,
recordedEvents ...lib.Event,
) error
}
type ForReadingEventStreams interface {
Read(streamID lib.StreamID) (lib.EventStream, error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment