• Use in combination with various webhook such as IFTTT, Jenkins • Available for @everyone • Please try using this!! firestarter is made for simple working example of Layered architecture in Go. https://s.juntaki.com/sVd
want to do Domain / Repository What business/software want to do Infrastructure How software is implemented Data Layer API input / output (xml, json, protobuf, ...) Persistent storage format (DB schema, File format, ...) On memory structure Controller (IDL definition) Deserialized API input / output UI What end user want to do Translator Translator Are there too many layers?
/ Repository What business/software want to do Infrastructure How software is implemented Controller (IDL definition) UI What end user want to do The upper side of the figure is the High-level modules. There are more components in higher-level modules, which may change frequently. Flow of control Modules example
MVC POV Modules should rely on the layer to less frequently change. High-level changes make just local impacts. However, If there is a change in the Low-level module, the impact propagates extensively. Application What API user want to do Domain / Repository What business/software want to do Infrastructure How software is implemented Controller (IDL definition) UI What end user want to do Modules example
What business/software want to do Infrastructure How software is implemented Controller (IDL definition) UI What end user want to do Dependency inversion principle point of view Layer Logic Presentation Data DIP POV Abstructions Abstructions High-level modules should not depend on low-level modules. ...means, reducing dependence to modules with many dependencies. High-level changes affect low levels, but the propagation range of change is measurable. Modules example
the purpose of software. • For speed at initial stage, MVC like arch. • For maintainability, DIP approach. You should consider some benefit of original module may be lost by excessive abstraction. (e.g. performance) Gopher may prefer robust DIP approach, layered architecture. • Easy to test by mocking • Interfaces implicitly decide each modules responsibility
to be injected is the source of inverted dependency. Where to inject it from? • DI container • main() • (or another choice) Application What API user want to do Domain / Repository What business/software want to do Infrastructure How software is implemented Controller (IDL definition) UI What end user want to do
...) Persistent storage format (DB schema, File format, ...) On memory structure Deserialized API input / output Application What API user want to do Domain / Repository What business/software want to do Infrastructure How software is implemented Translator Translator Translating is troublesome, but it is necessary for layer decoupling. The structure of each layer may be approximately the same at the initial stage. Generated code by protobuf Anticorruption, or..
schema, File format, ...) On memory structure Deserialized API input / output Application What API user want to do Domain / Repository What business/software want to do Infrastructure How software is implemented Translator Translator Command / Query Instead of increasing complexity, it will be more robust architecture.
• Data translation is important for layer decounpling. • No silver bullet Go API implementation is not easy but simple. It’s ideal for implementing complex architecture.
Takahashi https://speakerdeck.com/timakin/challenge-to-advanced-api-architecture-in-go GoにおけるDI http://inukirom.hatenablog.com/entry/di-in-go The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/) The design is licensed under the Creative Commons 3.0 Attributions license.