- Each service represents a bounded context, it is the authority for a business concept and contains the business rules.
- The service has business behaviour and data, exposing one or more resources.
- Services which talk to other services are coupled, instead services should have all the data they need, even if it duplicates of what is contained in other services.
- They must have autonomy, the network and service availability is not reliable.
- Trying to treat services like data sources means using distributed transactions and locks, which are, putting it mildly, difficult.
- Use an event bus to communicate between services:
- decoupled, no need to know about other services
- events are async so can be retried
- events are writtern in past tense
- When a canonical resource has been updated an event is published. The event includes the resource, or an id, or a URL from which it can be retrived. Subscribed services can then update their copy of the data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # manual steps | |
| # Download raw output of master cuke to master-cuke-ci.raw as plain text | |
| # Download raw output of another cuke branch to branch-cuke-js.raw as plain text | |
| set -e | |
| MASTER_RAW_FILE=master-cukes-ci.raw | |
| BRANCH_RAW_FILE=branch-cukes-ci.raw |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| HOST=localhost:3000 | |
| webkit2png -F -o page1 "http://${HOST}/..." | |
| webkit2png -F -o page2 "http://${HOST}/..." | |
| webkit2png -F -o page3 "http://${HOST}/..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="results"> | |
| <div class="result" data-result-id='1'> | |
| <div data-attr="title">Result 1</div> | |
| </div> | |
| <div class="result" data-result-id='2'> | |
| <div data-attr="title">Result 2</div> | |
| </div> | |
| <div class="result" data-result-id='3'> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Double < Hash | |
| def initialize(attrs) | |
| super | |
| attrs.each { |k,v| store(k,v) } | |
| end | |
| def method_missing(_name, *args, &block) | |
| has_key?(_name) ? fetch(_name) : super(_name, *args, &block) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # quickly find a branch, using the team name as the first argument and autocomplete | |
| # to narrow it down further. | |
| # requires "selecta" (garybernhardt/selecta) installable via brew on MacOS | |
| set -e | |
| if [[ -z "$1" ]]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## App | |
| require 'bundler' | |
| Bundler.require | |
| ### Entity | |
| class Person | |
| include Virtus.model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Thoughts on Event Sourcing in Ruby. | |
| # Idea is to have commands which record events in an event store. | |
| # A denormalizer listens to the EventStore for new events and creates highly denormalized record(s) in a relational database. | |
| # Entities are then populated by querying the relational database, since it it totally denormalized no JOIN's are required. | |
| # | |
| # The relational tables serve the same purpose as relation views, the event data might be persisted to multiple tables. | |
| # For example a command might create an event from which the denormalizer will create record in tables which are used for | |
| # persistance of entities and for aggregate reporting. | |
| # The relational data can be recreated using the event store. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # initializer | |
| $event_store = EventStore.new | |
| event_store.subscribe(StudyDenormalizer.new, prefix: ‘on’) | |
| # controller | |
| # push a new event (write database) | |
| uuid = UUID.new | |
| event_store.push(aggregate_id: uuid, event: ‘StudyCreated’, data: { … }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq/9WdnAcWFW720c/kK2Kyo21SD0z2U0xm11cLKdPofxwKvb97H0m+URLAZhsbJ232R7sfQuUfgGSM6Spg+iv5qyo2nEY3ksyGYn5xMfkS1tIkmP+Q69XoEmNjBh3Pon0X0AITi9QGbRdQ/pYoYpNTcjePPC/1dOqnl/HWNuUyx/DglnFnUoedQAufTLsnTV3eySc9tYFUEjYUGrX+EDcAD+Fg2VmHLhGItRe4lnCy2MSbDFeGI8N7te4ZnwuXp6fHIPSDn74UdDRWAdcrtu99ZEvieMA1ONf3p21w/T2QdiWBUokXv6kmkq8BMucmGXxtl7tZt3QMYoL8D8PxNcM7Q== kris |
OlderNewer