はてなにおけるマイクロサービスとScala / Microservices and Scala at Hatena

3f4be9784f765877f444bc839de29888?s=47 aereal
October 08, 2016

はてなにおけるマイクロサービスとScala / Microservices and Scala at Hatena

Scala関西Summit 2016 (http://summit.scala-kansai.org/) の発表資料です。

3f4be9784f765877f444bc839de29888?s=128

aereal

October 08, 2016
Tweet

Transcript

  1. 13.

    ݱߦܾࡁγεςϜͷվम • ΄ͱΜͲݱ࣮తͰ͸ͳ͍ • ޓ׵ੑʹؔ͢ΔεΩʔϜ͕ͳ͍ • ׬શޙํޓ׵ or die •

    ෳ਺ͷυϝΠϯ͕ೖΓཚΕ͍ͯΔ • ݱࡏͷ࢓༷ʹӨڹΛڧ͘ड͚Δ • վળ͕·ΘΒͳ͍
  2. 17.
  3. 18.

    ׬

  4. 22.

    ࣋ଓՄೳʹ࡞Γ (ͳ͓͠) ͍ͨ • είʔϓΛখ͘͞໌ྎʹอͭ • ૄ݁߹ (ʰϚΠΫϩαʔϏεΞʔΩςΫνϟʱ3.2.1) • ߴڽूੑ

    (ʰϚΠΫϩαʔϏεΞʔΩςΫνϟʱ3.2.2) • ෼ׂ౷࣏͢Δ • ٕज़ҟ࣭ੑ (͍ͭ·Ͱ΋Perl͸ݫ͍͠) • σϓϩΠͷϥΠϑαΠΫϧΛૣΊΔ
  5. 26.

    ׬

  6. 30.

    ඇػೳཁٻΛఆΊΔ • ISO 9126 • functionality: ػೳੑ • reliability: ৴པੑ

    • usability: ࢖༻ੑ • efficiency: ޮ཰ੑ • maintainability: อकੑ • portability: Ҡ২ੑ
  7. 31.

    ඇػೳཁٻΛఆΊΔ • ISO 9126 • functionality: ػೳੑ • reliability: ৴པੑ

    • usability: ࢖༻ੑ • efficiency: ޮ཰ੑ • maintainability: อकੑ • portability: Ҡ২ੑ
  8. 34.

    ঢ়ଶΛྻڍܕͰදݱ͢Δ sealed trait State object State { case object Requested

    extends State case object Paid extends State case object Failed extends State } ※࣮ࡍ͸΋͏ͪΐͬͱ͍Ζ͍Ζ͋Γ·͢
  9. 35.

    ঢ়ଶΛྻڍܕͰදݱ͢Δ case class Payment(state: State) { def charged: Boolean =

    state match { case State.Paid => true case _ => false } }
  10. 41.

    ׬

  11. 47.
  12. 57.

    ΤϯςΟςΟͷදݱ • ΤϯςΟςΟ = ID + υϝΠϯϞσϧ • ܕ΋ύϥϝʔλԽ͞Ε͍ͯΔ •

    υϝΠϯϞσϧʹରͯ͠ڞม • ಉ͡IDܕ͕ͩυϝΠϯϞσϧ͕ҟͳΔ
 ΤϯςΟςΟΛఆٛͰ͖Δ
  13. 58.

    ίʔυྫ case class EntityKey[ID]( val repr: String ) extends AnyVal

    abstract class Entity[K, +V]( val id: EntityKey[K], val value: V )(implicit ev: V <:< K)
  14. 59.

    ίʔυྫ case class EntityKey[ID]( val repr: String ) extends AnyVal

    abstract class Entity[K, +V]( val id: EntityKey[K], val value: V )(implicit ev: V <:< K) phantom type
  15. 60.

    ίʔυྫ case class EntityKey[ID]( val repr: String ) extends AnyVal

    abstract class Entity[K, +V]( val id: EntityKey[K], val value: V )(implicit ev: V <:< K) ஋ܕΛڞมʹ
  16. 61.

    ίʔυྫ case class EntityKey[ID]( val repr: String ) extends AnyVal

    abstract class Entity[K, +V]( val id: EntityKey[K], val value: V )(implicit ev: V <:< K) ஋ͷܕ͕IDͷܕͷαϒΫϥεͰ͋Δ
 ܕύϥϝʔλ੍໿
  17. 64.

    ࣮૷ package infra.db trait AccountComponent extends repo.AccountComponent { def accountLoader:

    AccountLoader = AccountDB object AccountDB extends AccountLoader { ... } }
  18. 69.

    ׬