Akka actor查找或依赖项注入 [英] Akka actor lookup or dependency injection

查看:106
本文介绍了Akka actor查找或依赖项注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始与Akka合作,我无法决定是否应该使用依赖项注入(例如蛋糕模式)或演员查找来使演员彼此脱钩。首选方法是什么?

I'm just starting to work with Akka and I can't decide if I should use dependency injection (like cake pattern) or actor lookup in order to decouple the actors from each others. What is the preferred method?

推荐答案

您应该更喜欢相互介绍actor,这意味着要在其中或与之一起发送ActorRef消息或将其传递给构造函数。后者可能涉及您选择的蛋糕模式,但是查找要昂贵得多,因此您应尽可能使用真实的ActorRef。

You should prefer to introduce actors to each other, which means to send an ActorRef in or with a message or to pass it into a constructor. The latter may involve the cake pattern of you so choose, but lookup is much more expensive and therefore you should use real ActorRef whenever possible.

这篇关于Akka actor查找或依赖项注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆