Skip to content

Instantly share code, notes, and snippets.

View shivam-880's full-sized avatar
🔬

Shivam shivam-880

🔬
View GitHub Profile

Keybase proof

I hereby claim:

  • I am codingkapoor on github.
  • I am codingkapoor (https://keybase.io/codingkapoor) on keybase.
  • I have a public key ASAIu7upmPE-iMZKalV1vCG7Yd5q19rqwCcrYCxCnFlqfgo

To claim this, I am signing this object:

@shivam-880
shivam-880 / reactive-architecture-ddd-notes.md
Last active March 20, 2024 22:00
Reactive Architecture: Domain Driven Design Course Notes

Domain Driven Design

What is a Domain?

  • A domain is a sphere of knowlege.
  • In the context of software, it refers to the business or idea that we are modeling.
  • Experts in the domain are people who understand the business, not necessarily the software.
  • Key goal of DDD is to build a model that the domain experts understand.
  • The model is not the software.
    • The model represents our understanding of the domain.
    • The software is an implementation of the model.
@shivam-880
shivam-880 / reactive-architecture-reactive-microservices-notes.md
Last active July 27, 2020 09:20
Reactive Architecture: Reactive Microservices Course Notes

Monolith

The Monolithic Ball of Mud

  • The Ball Of Mud represents the worst case scenario for a Monolith. Also called as Spaghetti Code.
  • No clear isolation in the application.
  • Complex dependencies where everything depends on every other thing.
  • Hard to understand and harder to modify.

Cleaning Up The Ball Of Mud

  • To clean up the ball of mud we introduce isolation into the application by dividing the application along clear domain boundaries.
  • We introduce packages and libraries that help isolate related pieces of code. They provide a clean and consistent interface.
libraryDependencies += "org.scala-lang" % "scala-compiler" % "2.12.8"
libraryDependencies += compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
@EnableServiceDiscovery
object MyService extends App {}
@compileTimeOnly("enable macro paradise to expand macro annotations")
class EnableServiceDiscovery extends StaticAnnotation {
def macroTransform(annottees: Any*): Any = macro EnableServiceDiscovery.impl
}
object EnableServiceDiscovery {
def impl(c: blackbox.Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {
import c.universe._
val result = {
@EnableServiceDiscovery
object MyService extends App {
implicit val system = ActorSystem("myservice-actor-system")
implicit val materializer = ActorMaterializer()
implicit val executionContext: ExecutionContext = system.dispatcher
val interface = RuntimeEnvironment.appConfig.getString("myservice.http.interface")
val port = RuntimeEnvironment.appConfig.getString("myservice.http.port").toInt
$ git clone [email protected]:codingkapoor/consul-scala-macro-annotations.git
$ cd consul-scala-macro-annotations
$ sbt> project myservice
$ sbt> universal:packageBin
$ cd consul-scala-macro-annotations/myservice/target/universal
$ unzip myservice-0.1.0-SNAPSHOT.zip
$ cd myservice-0.1.0-SNAPSHOT
$ bin/start.sh
$ tail -f logs/stdout.log