akka

How to increase default timeout for ScalaTestWithActorTestKit

柔情痞子 提交于 2021-01-07 02:41:11
问题 I have a test which constructs another event sourcing actor from inside message handler and this construction is taking more than 3 seconds. Below is current configuration, how can I increase default timeout? extends ScalaTestWithActorTestKit( ConfigFactory.parseString(""" akka.persistence.testkit.events.serialize = off akka.actor.allow-java-serialization = on akka.test.single-expect-default = 999s """).withFallback(PersistenceTestKitPlugin.config).withFallback(ManualTime.config) Here is the

How do I compute an aggregation inside a GraphStage in Akka Streams?

女生的网名这么多〃 提交于 2021-01-07 01:42:37
问题 I have an operator/component in Akka stream that aims to compute a value within a window of 5 seconds. So, I created my operator/component using TimerGraphStageLogic which you can see on the code below. In order to test it I created 2 sources, one that increments and the other that decrements, then I merge them using the Merge shape, then I use my windowFlowShape , and finally emit them in a Sink shape. I ensure that the TimerGraphStageLogic is working because I tested it in another PoC. In

成功入职字节跳动,分享我的八面面经心得!

余生颓废 提交于 2021-01-02 22:58:52
今天正式入职了字节跳动。办公环境也很好,这边一栋楼都是办公区域。公司内部配备各种小零食、饮料,还有免费的咖啡。15楼还有健身房。而且公司包三餐来着。下午三点半左右还会有阿姨推着小车给大家送下午茶。听说入职以后很容易长胖来着。不过如果想要保持身材的话,公司二楼还提供专门的健身餐。周二周四还可以预约专业的按摩服务,有效调理颈椎和腰椎。生活服务得这么贴心,感觉在这里就只需要好好工作就好了吧,哈哈 为什么想去字节跳动 实际上,这次的工作变动并不在我计划中。只是在四月份的时候偶然得知字节跳动上海要搬到合川路地铁站附近,我就忽然心动了。为什么呢,因为我家距离合川路地铁站步行只要十分钟。本身宇宙条待遇高名声在外,也就是说,只要我能来这里的话,人生最美满的钱多事少离家近的不可能三角我能拿俩。所以在五月份的时候我就开始悄摸摸地准备面试头条了。为的就是以后可以过上早上八点半起床,然后慢慢悠悠走到公司还不迟到(可能还是很早来的人之一)的生活。 当然,这是我为什么想去字节跳动的原因。换算到你们自己的时候,你们也要想一想是因为什么想要换一份工作、想要去某个公司。为了薪资?环境?平台?还是大公司的名头?记住,不管是为了哪一个,都OK的。谈钱不伤感情,目标明确,心智坚定以后,才好围绕着这个目标做一系列的准备。面试的过程中每次面试官问我为什么想来字节跳动,我都是直截了当地说离家近,还说假如这次面不上,准备准备

Scala Futures and java 8 CompletableFuture

岁酱吖の 提交于 2020-12-27 17:07:47
问题 The introduction of CompletableFutures in Java 8 brought to the language features available in the scala.concurrent.Future such as monadic transformations. What are the differences, and why a Scala developer should prefer Scala Futures over java 8 CompletableFuture ? Are there still good reasons to use the scala.concurrent.Future in Java through akka.dispatch bridge? 回答1: What are the differences, and why a Scala developer should prefer Scala Futures over java 8 CompletableFuture ? Rephrasing

how to resolve conflict of ActorSystem in akka http test and akka test kit

▼魔方 西西 提交于 2020-12-26 11:11:17
问题 i have a test class in which i need to use both akka testkit and akka http test kit so i am doing it like this class MyTest extends TestKit(ActorSystem("testsys")) with ScalaFutures with ImplicitSender with AnyWordSpecLike with Matchers with BeforeAndAfterAll with ScalatestRouteTest { //tests here } but i am getting a compile time error implicit val system: akka.actor.ActorSystem (defined in class TestKit) and [error] implicit val system: akka.actor.ActorSystem (defined in trait RouteTest)

how to resolve conflict of ActorSystem in akka http test and akka test kit

雨燕双飞 提交于 2020-12-26 11:08:14
问题 i have a test class in which i need to use both akka testkit and akka http test kit so i am doing it like this class MyTest extends TestKit(ActorSystem("testsys")) with ScalaFutures with ImplicitSender with AnyWordSpecLike with Matchers with BeforeAndAfterAll with ScalatestRouteTest { //tests here } but i am getting a compile time error implicit val system: akka.actor.ActorSystem (defined in class TestKit) and [error] implicit val system: akka.actor.ActorSystem (defined in trait RouteTest)

Scala学习之路 (十)Scala的Actor

限于喜欢 提交于 2020-12-18 13:55:14
一、Scala中的并发编程 1、Java中的并发编程 ①Java中的并发编程基本上满足了事件之间相互独立,但是事件能够同时发生的场景的需要。 ②Java中的并发编程是基于共享数据和加锁的一种机制,即会有一个共享的数据,然后有若干个线程去访问这个共享的数据(主要是对这个共享的数据进行修改),同时Java利用加锁的机制(即synchronized)来确保同一时间只有一个线程对我们的共享数据进行访问,进而保证共享数据的一致性。 ③Java中的并发编程存在资源争夺和死锁等多种问题,因此程序越大问题越麻烦。 2、Scala中的并发编程 ①Scala中的并发编程思想与Java中的并发编程思想完全不一样,Scala中的Actor是一种不共享数据,依赖于消息传递的一种并发编程模式, 避免了死锁、资源争夺等情况。在具体实现的过程中,Scala中的Actor会不断的循环自己的邮箱,并通过receive偏函数进行消息的模式匹配并进行相应的处理。 ②如果Actor A和 Actor B要相互沟通的话,首先A要给B传递一个消息,B会有一个收件箱,然后B会不断的循环自己的收件箱, 若看见A发过来的消息,B就会解析A的消息并执行,处理完之后就有可能将处理的结果通过邮件的方式发送给A。 二、Scala中的Actor 1、什么是Actor 一个actor是一个容器,它包含 状态, 行为,信箱,子Actor 和

.NET分布式大规模计算利器-Orleans(一)

南楼画角 提交于 2020-12-13 14:30:52
写在前面 Orleans是基于Actor模型思想的.NET领域的框架,它提供了一种直接而简单的方法来构建分布式大规模计算应用程序,而无需学习和应用复杂的并发或其他扩展模式。我在2015年下半年开始应用Orleans,当时公司的交易系统采用的架构就是基于Orleans框架的,其展现出来的高性能、高并发以及惊人的稳定性深深地吸引了我,也让我认识到了传统三层无状态架构的缺陷。本文主要关注Orleans的思想基础,Actor模型及其应用。 Orleans思想基础:Actor模型 传统三层无状态架构的缺陷 在讨论Actor模型之前,我们可以先讨论一下传统三层架构在当前高并发环境中所面临的尴尬境遇。 三层架构包括表示层、业务逻辑层或者叫做中间层、数据访问层(也就是存储层),其架构图如下所示: 正如我们在实践中所知道的那样,中间层和数据访问层在伸缩性方面有着很大的限制,同时存储层常常会成为系统的瓶颈,这就意味着整套系统也会因为存储层的限制而变得低效。通常的做法是在中间层与存储层中间加一层缓存逻辑出来,以提升系统性能,但是很快就会遇到存储层与缓存层的数据一致性问题,这无疑为开发人员和运维人员增加了额外的工作量。 试想一下,如果我们中间层本身就携带着状态或者简单来说中间层与缓存层是合二为一的,那么我们的系统性能是不是就提升了一个级别,答案是肯定的。那么该如何去做呢

use a partition to decide if a flow should go to next flow and if not have the stream pick it up next tick from the beginning (Akka)

怎甘沉沦 提交于 2020-12-13 04:57:05
问题 I want to create a Flow that have 4 main steps (FlowShapes), and after the first and the second I want to have partition that will decide if there is a reason to go to the next, and if not to sink it so the stream will pick it up later and start from beginning, but im not sure this is the way, cause I just used Sink.ignore, it looks like this: def mainFlow: Flow[MyGraphElement, MyGraphElement, NotUsed] = Flow.fromGraph(GraphDSL.create() { implicit builder => // FlowShape's // those flow

use a partition to decide if a flow should go to next flow and if not have the stream pick it up next tick from the beginning (Akka)

若如初见. 提交于 2020-12-13 04:57:04
问题 I want to create a Flow that have 4 main steps (FlowShapes), and after the first and the second I want to have partition that will decide if there is a reason to go to the next, and if not to sink it so the stream will pick it up later and start from beginning, but im not sure this is the way, cause I just used Sink.ignore, it looks like this: def mainFlow: Flow[MyGraphElement, MyGraphElement, NotUsed] = Flow.fromGraph(GraphDSL.create() { implicit builder => // FlowShape's // those flow