Skip to content

Instantly share code, notes, and snippets.

View j5ik2o's full-sized avatar

Junichi Kato j5ik2o

View GitHub Profile
object PersistentWalletAggregate {
def behaviorProxy(
id: WalletId,
chargesLimit: Int = Int.MaxValue
): Behavior[CommandRequest] =
Behaviors
.supervise(Behaviors.setup[CommandRequest] { ctx =>
val childRef: ActorRef[CommandRequest] =
ctx.spawn(WalletAggregate.behavior(id, chargesLimit), WalletAggregate.name(id))
object TestMain extends App {
import akka.stream.scaladsl._
import akka.actor._
import akka.stream.ActorMaterializer
import scala.concurrent._
import scala.concurrent.duration._
implicit val system = ActorSystem()
implicit val ec = system.dispatcher
implicit val mat = ActorMaterializer()
curl -v -X GET https://oss.sonatype.org/content/repositories/releases/com/github/j5ik2o/reactive-redis-core_2.12/1.0.20/reactive-redis-core_2.12-1.0.20.pom                        INT(-2) ↵  3243  22:31:44
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 23.22.160.79...
* TCP_NODELAY set
* Connected to oss.sonatype.org (23.22.160.79) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
@j5ik2o
j5ik2o / btree.go
Last active December 21, 2018 08:37
package btree
package btree
type Node interface {
Size() int
Sum() int64
Min() int64
Max() int64
Find(value int64) *int64
trait BTree {
fn size(&self) -> i32;
fn sum(&self) -> i64;
fn min(&self) -> i64;
fn max(&self) -> i64;
fn find(&self, value: i64) -> Option<i64>;
}
enum Node {
Leaf {
// 絵の具を表すオブジェクト(副作用が伴う可変オブジェクト)
public class Paint {
private int volume;
private PigmentColor pigmentColor;
// getter, setter 省略
public Paint(PigmentColor pigmentColor, int volume) {
this.volume = volume;
this.pigmentColor = pigmentColor;
}
case class Money(amount: BigDecimal,
currency: Currency) {
def plus(other: Money): Money = {
require(currency == other.currency)
new Money(amount = amount.add(other.amount), currency)
}
}
case class UserAcount(id: Long, name: String, groupId: Long) {
// ...
def groupName(groupRepository: GroupRepository): Task[GroupName] = groupRepository.resolveBy(groupId).map(_.name)
}
package domain
trait Money {
def plus(other: Money): Money
def minus(other: Money): Money
// ...
}
@j5ik2o
j5ik2o / q1.md
Last active September 7, 2018 17:20

型パラメータが高階型の場合のDIについて

トレイト: UserAccountRepository[M[_]] https://github.com/j5ik2o/scala-ddd-base/blob/master/example/src/main/scala/com/github/j5ik2o/dddbase/example/repository/UserAccountRepository.scala

実装: UserAccountRepositoryBySkinny https://github.com/j5ik2o/scala-ddd-base/blob/master/example/src/main/scala/com/github/j5ik2o/dddbase/example/repository/skinny/UserAccountRepositoryBySkinny.scala

があったとして、以下のようなDIをさせたいのですが、