Skip to content

Commit

Permalink
[Demo] random errors in MeetingService - to test metrics (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
mproch authored Apr 27, 2020
1 parent 3a705ba commit 9acceab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import com.cronutils.model.Cron
import javax.annotation.Nullable
import pl.touk.nussknacker.engine.api.editor.{DualEditor, DualEditorMode, SimpleEditor, SimpleEditorType}
import pl.touk.nussknacker.engine.api.{MethodToInvoke, ParamName, Service}
import pl.touk.nussknacker.engine.flink.util.service.TimeMeasuringService

import scala.concurrent.Future
import scala.concurrent.{ExecutionContext, Future}

object MeetingService extends Service with Serializable with TimeMeasuringService {

override protected def serviceName: String = "meetingService"

object MeetingService extends Service with Serializable {
@MethodToInvoke
def invoke(@ParamName("Date") date: LocalDateTime,
@ParamName("EndTime") endTime: LocalTime,
Expand Down Expand Up @@ -47,6 +51,12 @@ object MeetingService extends Service with Serializable {
)
@Nullable
cronScheduler: Cron
): Future[Unit]
= Future.successful(Unit)
)(implicit ec: ExecutionContext): Future[Unit] = measuring {
Thread.sleep((math.random * 10).toLong)
if (math.random < 0.25) {
Future.failed(new IllegalArgumentException("Bad luck, your meeting failed..."))
} else {
Future.successful(())
}
}
}
3 changes: 2 additions & 1 deletion nussknacker-dist/src/universal/conf/dev-application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

base: { include "base-application.conf" }

environment: "test"
//to be consistent with docker/demo
environment: "demo"

categoriesConfig: {
"FraudDetection": "streaming-demo",
Expand Down

0 comments on commit 9acceab

Please sign in to comment.