Skip to content

Instantly share code, notes, and snippets.

View jaymecd's full-sized avatar

Nikolai Zujev jaymecd

View GitHub Profile
<?php
namespace My\Namespace;
/**
* This Listener listens to the loadClassMetadata event. Upon this event
* it hooks into Doctrine to update discriminator maps. Adding entries
* to the discriminator map at parent level is just not nice. We turn this
* around with this mechanism. In the subclass you will be able to give an
* entry for the discriminator map. In this listener we will retrieve the
* load metadata event to update the parent with a good discriminator map,
curl -XDELETE localhost:9200/test/
curl -XPUT localhost:9200/test/
curl -XPUT localhost:9200/test/son/_mapping -d '{
"son": {
"_parent": {
"type": "mother"
}
}
}'
curl -XPUT localhost:9200/test/daughter/_mapping -d '{
@jaymecd
jaymecd / mongos
Last active August 29, 2015 14:10 — forked from fabioperrella/mongos
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <[email protected]>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
@jaymecd
jaymecd / haproxy.cfg
Last active August 29, 2015 14:10 — forked from dakatsuka/haproxy.cfg
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
daemon
listen rabbitmq 0.0.0.0:5672
mode tcp

CQRS – Greg Young – 8/26/2011

Insurance Domain – Value to Business Model (S-M-L)

  • Claims – L
  • Sales – S-M
  • Accounting – S
  • Actuarials – S
  • Intranet – S
  • Public Web – M-L
@jaymecd
jaymecd / cqrs.md
Last active August 29, 2015 14:14

CQRS - Command Query Responsibility Segregation

Split reads and writes on a architectural level.

It's based on CQS (Command Query Separation) as described by Bertrand Meyer. A method either reads state or mutates state, but not both.

CQRS was discovered by Greg Young.

CQRS enables rich domain models, which are not anaemic.

Rough Notes about CQRS and ES

Once upon a time…

I once took notes (almost sentence by sentence with not much editing) about the architectural design concepts - Command and Query Responsibility Segregation (CQRS) and Event Sourcing (ES) - from a presentation of Greg Young and published it as a gist (with the times when a given sentence was heard).

I then found other summaries of the talk and the gist has since been growing up. See the revisions to know the changes and where they came from (aka the sources).

It seems inevitable to throw Domain Driven Design (DDD) in to the mix.

The differences between a domain service and an application services are subtle but critical:

  • Domain services are very granular where as application services are a facade purposed with providing an API.
  • Domain services contain domain logic that can’t naturally be placed in an entity or value object whereas application services orchestrate the execution of domain logic and don’t themselves implement any domain logic.
  • Domain service methods can have other domain elements as operands and return values whereas application services operate upon trivial operands such as identity values and primitive data structures.
  • Application services declare dependencies on infrastructural services required to execute domain logic.
  • Command handlers are a flavor of application services which focus on handling a single command typically in a CQRS architecture.

Source: http://gorodinski.com/blog/2012/04/14/services-in-domain-driven-design-ddd/

1. Your application consists of three parts. Information always flows
"clockwise": clients, write side, read sides. Clients send Commands
to write side. Write side publishes Events to read sides. Read sides
reply to Queries for client.
2. The interesting logic is all in the write side, but your design may
consist *only* of the totality of Commands, Events, and Queries.
3. Each Command or Event has exactly one aggregate that it's acting on,
identified by unique aggregate ID. There need not be a one-to-one
@jaymecd
jaymecd / .README.md
Last active August 29, 2015 14:14 — forked from gnarf/..git-pr.md

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from GitHub remotes:

  • git pr 4 - creates local branch pr/4 from the origin remote and checks it out
  • git pr 4 upstream - creates local branch pr/4 from upstream remote and checks it out