GithubHelp home page GithubHelp logo

ddd's Introduction

ddd

Hexagonal, DDD, RabbitMQ, PHP

3 sketchy bounded contexts: idaccess, report, shop

Commands arrive in the application through adapters. These could translate an user interface action, a REST call or a message from the queue. In the example provided only the shop context has an user interface for the customer login. The reporting and the idaccess contexts receive input only on their message queues.

The customer login user action is routed through the UIAdapter into the CustomerController which translates it to a LoginCustomerCommand for the shop context. Its handler, using a simulated synchronous request over the queue to the idaccess (authorization) context through the UserInRoleAdapter, sends a command to authorize the User into the Customer role by placing it on the idaccess' queue. The idaccess context gets the command on its queue and delegates to its AuthorizeUserCommand. If the authorization is succesful it returns an event containing an authorization token to its client.

From this moment the token will be used by the controllers to authorize the further user actions, and by the shop context to authenticate the commands that it receives. The authorization policy is a deny-default one, in the controllers through the requireAuthentication attribute of the Route which is by default true, and through the SecurityCommandHandler which filters out all not white-listed incoming requests, authorizing them.

The events published by the contexts are sent synchronous over the queue through the DomainEventPublisher which has wired an implementation of ExchangeTopicPublisher - one of the base extensible classes for communicating over the queues.

These are some of the things which were achieved, which are far less than the ones which were left out:

  • using value objects for simple structures
  • validating input data
  • errors
  • exceptions between contexts
  • event receiving order
  • receiving duplicated events
  • command order
  • command retry on fail
  • entity modification concurrency
  • event store and asynchronous dispatching on the queue
  • queue authentication & authorization
  • framework for keeping the deamons alive for listeners and workers, and tuning for performance (http://supervisord.org/)
  • transactions
  • unit tests

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.