• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

sgerber-hyperanna/ktor-hexagonal-multi-module-template: An example service using ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

sgerber-hyperanna/ktor-hexagonal-multi-module-template

开源软件地址(OpenSource Url):

https://github.com/sgerber-hyperanna/ktor-hexagonal-multi-module-template

开源编程语言(OpenSource Language):

Kotlin 99.4%

开源软件介绍(OpenSource Introduction):

Ktor Ports and Adapters Multi Module Template

A dummy services that illustrates:

  • Ports and Adapters
  • Multi-module gradle kotlin dsl
  • Guice injection with Ktor

Testing

Run ./gradlew clean test to run all the tests

Running locally

Create the directory /app/lib/conf and add a file called 'jwt-secret.conf'

jwt.secret = 1234-1234-1234-1234

Run ./gradlew :app:run to run the service

Project Structure

This project follows a 'ports and adapters' (a.k.a. hexagonal) architecture and is divided into modules

Domain

The centre of the hexagon, contains core business logic.

Depends on

  • Ports

What goes here?

  • Classes and functions related to business logic.

What does not go here?

  • Transport layer concerns, e.g. JSON transformation,
  • Frameworks (arguable - but try to avoid)
  • Databases (arguable - but lets try to be pure)

Adapters

Everything outside the hexagon. Nothing related to business logic.

Depends on

  • Ports

What goes here?

  • JSON serializers/deserializers
  • REST clients
  • RabbitMQ senders/receivers (if applicable)
  • Framework code, e.g. ktor routes
  • DAOs, data layer

What does not go here?

  • Business logic

Ports

The 'ports' layer is the only way 'domain' and 'adapters' interact. It is divided into:

  • Provided (by domain)
  • Required (by domain

Depends on

  • Nothing

Provided ports

Interfaces (and data classes) implemented by the domain sub-project. The adapter layer uses this to communicate with domain code.

What goes here?
  • Interfaces for domain services

What does not go here?

  • Anything else

Required ports

Interfaces (and data classes) implemented by the adapters sub-project. The domain layer uses this to communicate with adapter layer.

What goes here?
  • Interfaces for remote services, message brokers, repositories, etc.
What does not go here?
  • Anything else

App

This layer can see all other layers and is responsible for bootstrapping the running application

Depends on

  • Ports
  • Adapters
  • Domain

What goes here?

  • The 'main method'
  • Framework configuration needed to glue the other layers together, e.g. initializing Guice modules
  • Build configuration needed to create a deployable service.

What does not go here?

  • Anything that otherwise fits into the 'ports', 'adapters' or 'domain' buckets



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap