Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Demo] random errors in MeetingService - to test metrics #887

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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