-
Notifications
You must be signed in to change notification settings - Fork 6
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
Schedule messages #2
Changes from 19 commits
f397574
b0d1a69
b115607
b9a321b
26c540e
fe9469d
5f6bbcd
b18e3ec
b84b948
3355089
1f04e03
2958a7b
a5e304c
ab143f5
1063f0c
a81702d
33e3e35
229013a
3b12464
39063b9
3a81593
837e36c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
scheduler { | ||
shutdown-timeout { | ||
stream = 10 seconds | ||
system = 10 seconds | ||
} | ||
queue-buffer-size = 100 | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sky.kms | ||
|
||
import akka.actor.ActorSystem | ||
import akka.stream.Supervision.Restart | ||
import akka.stream.{ActorMaterializer, ActorMaterializerSettings, Supervision} | ||
import com.typesafe.scalalogging.LazyLogging | ||
|
||
trait AkkaComponents extends LazyLogging with Monitoring { | ||
|
||
implicit val system = ActorSystem("kafka-message-scheduler") | ||
|
||
val decider: Supervision.Decider = { t => | ||
recordException(t) | ||
logger.error(s"Supervision failed.", t) | ||
Restart | ||
} | ||
|
||
val settings = ActorMaterializerSettings(system) | ||
.withSupervisionStrategy(decider) | ||
|
||
implicit val materializer = ActorMaterializer(settings) | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.sky.kms | ||
|
||
import kamon.Kamon | ||
import kamon.metric.MetricsModule | ||
|
||
trait Monitoring { | ||
|
||
val metrics: MetricsModule = Kamon.metrics | ||
|
||
def increment(key: String) = metrics.counter(key).increment() | ||
|
||
def recordException(throwable: Throwable) = { | ||
val key = generateKeyFromException(throwable) | ||
metrics.counter(key).increment() | ||
} | ||
|
||
private def generateKeyFromException(throwable: Throwable): String = { | ||
return s"exception.${throwable.getClass.getName.replace(".", "_")}" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.sky.kms | ||
|
||
import com.sky.kms.config.AppConfig | ||
import com.sky.kms.streams.ScheduleReader | ||
import com.typesafe.scalalogging.LazyLogging | ||
import kamon.Kamon | ||
import org.zalando.grafter._ | ||
import pureconfig._ | ||
|
||
import scala.concurrent.Await | ||
|
||
object SchedulerApp extends App with LazyLogging with AkkaComponents { | ||
|
||
val conf = loadConfigOrThrow[AppConfig] | ||
Kamon.start() | ||
|
||
logger.info("Kafka Message Scheduler starting up...") | ||
val app = ScheduleReader.reader.run(conf) | ||
|
||
sys.addShutdownHook { | ||
logger.info("Kafka Message Scheduler shutting down...") | ||
Rewriter.stop(app).value | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restoring @paoloambrosio-skyuk's comment:
If we're not addressing that in this PR, perhaps create an issue or at least an issue comment to track, and link to it from here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created #8 |
||
|
||
materializer.shutdown() | ||
Await.result(system.terminate(), conf.scheduler.shutdownTimeout.system) | ||
|
||
Kamon.shutdown() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we're a new module I see no reason not to use SLF4J
1.7.25