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

marcusolsson/goddd: Exploring DDD in Go

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

开源软件名称:

marcusolsson/goddd

开源软件地址:

https://github.com/marcusolsson/goddd

开源编程语言:

Go 69.0%

开源软件介绍:

GoDDD

Build Status GoDoc Go Report Card License MIT stability-unstable

This is an attempt to port the DDD Sample App to idiomatic Go. This project aims to:

  • Demonstrate how the tactical design patterns from Domain Driven Design may be implemented in Go.
  • Serve as an example of a modern production-ready enterprise application.

Important note

This project is intended for inspirational purposes and should not be considered a tutorial, guide or best-practice neither how to implement Domain Driven Design nor enterprise applications in Go. Make sure you adapt the code and ideas to the requirements of your own application.

Porting from Java

The original application is written in Java and much thought has been given to the domain model, code organization and is intended to be an example of what you might find in an enterprise system.

I started out by first rewriting the original application, as is, in Go. The result was hardly idiomatic Go and I have since tried to refactor towards something that is true to the Go way. This means that you will still find oddities due to the application's Java heritage. If you do, please let me know so that we can weed out the remaining Java.

Running the application

Start the application on port 8080 (or whatever the PORT variable is set to).

go run main.go -inmem

If you only want to try it out, this is enough. If you are looking for full functionality, you will need to have a routing service running and start the application with ROUTINGSERVICE_URL (default: http://localhost:7878).

Docker

You can also run the application using Docker.

# Start routing service
docker run --name some-pathfinder marcusolsson/pathfinder

# Start application
docker run --name some-goddd \
  --link some-pathfinder:pathfinder \
  -p 8080:8080 \
  -e ROUTINGSERVICE_URL=http://pathfinder:8080 \
  marcusolsson/goddd -inmem

... or if you're using Docker Compose:

docker-compose up

Try it!

# Check out the sample cargos
curl localhost:8080/booking/v1/cargos

# Book new cargo
curl localhost:8080/booking/v1/cargos -d '{"origin": "SESTO", "destination": "FIHEL", "arrival_deadline": "2016-03-21T19:50:24Z"}'

# Request possible routes for sample cargo ABC123
curl localhost:8080/booking/v1/cargos/ABC123/request_routes

Contributing

If you want to fork the repository, follow these step to avoid having to rewrite the import paths.

go get github.com/marcusolsson/goddd
cd $GOPATH/src/github.com/marcusolsson/goddd
git remote add fork git://github.com:<yourname>/goddd.git

# commit your changes

git push fork

For more information, read this.

Additional resources

For watching

For reading

Related projects

The original application uses a external routing service to demonstrate the use of bounded contexts. For those who are interested, I have ported this service as well:

pathfinder

To accompany this application, there is also an AngularJS-application to demonstrate the intended use-cases.

dddelivery-angularjs

Also, if you want to learn more about Domain Driven Design, I encourage you to take a look at the Domain Driven Design book by Eric Evans.




鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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