Skip to content

Commit

Permalink
Merge pull request #523 from guardian/pre-scala-2.13-use-procedure-sy…
Browse files Browse the repository at this point in the history
…ntax

Pre-Scala 2.13: Remove deprecated `ProcedureSyntax` - use `def x(): Unit = {...}`
  • Loading branch information
rtyley authored Aug 7, 2024
2 parents fe988c5 + 9dfce52 commit e2462c4
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/model/jobs/JobRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class JobRunner @Inject() (lifecycle: ApplicationLifecycle)(implicit ec: Executi
lifecycle.addStopHook{ () => Future.successful(stop) }
serviceManager.startAsync()

def stop {
def stop: Unit = {
serviceManager.stopAsync()
serviceManager.awaitStopped(20, TimeUnit.SECONDS)
}
Expand Down
4 changes: 2 additions & 2 deletions app/model/jobs/Step.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ trait Step extends Logging {

// Inner details
/** Do work. */
protected def process(implicit ec: ExecutionContext)
protected def process(implicit ec: ExecutionContext): Unit

/** Confirm this check ran successfully */
protected def check(implicit ec: ExecutionContext): Boolean

/** Undo this step */
protected def rollback
protected def rollback: Unit

// Public methods that wrap the status updates
def processStep(implicit ec: ExecutionContext) = {
Expand Down
6 changes: 3 additions & 3 deletions app/modules/clustersync/ClusterSynchronisation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ClusterSynchronisation @Inject() (lifecycle: ApplicationLifecycle) extends

initialise

def initialise {
def initialise: Unit = {
try {
logger.info("starting sync components...")
val ns = NodeStatusRepository.register()
Expand All @@ -57,7 +57,7 @@ class ClusterSynchronisation @Inject() (lifecycle: ApplicationLifecycle) extends
}
}

def pause {
def pause: Unit = {
logger.warn("pausing cluster synchronisation")
tagCacheSynchroniser.get.foreach{consumer =>
logger.warn("stopping consumer")
Expand All @@ -72,7 +72,7 @@ class ClusterSynchronisation @Inject() (lifecycle: ApplicationLifecycle) extends
}
}

def heartbeat {
def heartbeat: Unit = {
try {
reservation.get() match {
case Some(ns) => {
Expand Down
2 changes: 1 addition & 1 deletion app/modules/clustersync/NodeStatusRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ object NodeStatusRepository extends Logging {
}
}

def deregister(nodeStatus: NodeStatus) {
def deregister(nodeStatus: NodeStatus): Unit = {

logger.info(s"deregistering as node ${nodeStatus.nodeId}")

Expand Down
2 changes: 1 addition & 1 deletion app/modules/clustersync/SectionSyncUpdateProcessor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object SectionSyncUpdateProcessor extends KinesisStreamRecordProcessor with Logg

}

private def updateSectionLookupCache(sectionEvent: SectionEvent) {
private def updateSectionLookupCache(sectionEvent: SectionEvent): Unit = {
sectionEvent.eventType match {
case EventType.Update =>
logger.info(s"inserting updated section ${sectionEvent.sectionId} into lookup cache")
Expand Down
2 changes: 1 addition & 1 deletion app/modules/clustersync/TagSyncUpdateProcessor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object TagEventDeserialiser {

object TagSyncUpdateProcessor extends KinesisStreamRecordProcessor with Logging {

override def process(record: Record) {
override def process(record: Record): Unit = {
logger.info(s"Kinesis consumer receives record \n $record")
TagEventDeserialiser.deserialise(record) match {
case Success(tagEvent) => updateTagsLookupCache(tagEvent)
Expand Down
2 changes: 1 addition & 1 deletion app/repositories/Sequences.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DynamoSequence(sequenceTable: Table, sequenceName: String) {
Dynamo.sequenceTable.getItem("sequenceName", sequenceName).getLong("value")
}

def setCurrentId(v: Long) {
def setCurrentId(v: Long): Unit = {
Dynamo.sequenceTable.putItem(new Item().withString("sequenceName", sequenceName).withLong("value", v))
}
}
8 changes: 4 additions & 4 deletions app/services/AWS.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,21 @@ object SQS {

class KinesisStreamProducer(streamName: String, requireCompressionByte: Boolean = false) extends Logging {

def publishUpdate(key: String, data: String) {
def publishUpdate(key: String, data: String): Unit = {
publishUpdate(key, ByteBuffer.wrap(data.getBytes("UTF-8")))
}

def publishUpdate(key: String, data: Array[Byte]) {
def publishUpdate(key: String, data: Array[Byte]): Unit = {
publishUpdate(key, ByteBuffer.wrap(data))
}

def publishUpdate(key: String, struct: ThriftStruct) {
def publishUpdate(key: String, struct: ThriftStruct): Unit = {
logger.info(s"Kinesis Producer publishUpdate for streamName: $streamName")
val thriftKinesisEvent: Array[Byte] = ThriftSerializer.serializeToBytes(struct, requireCompressionByte)
publishUpdate(key, ByteBuffer.wrap(thriftKinesisEvent))
}

def publishUpdate(key: String, dataBuffer: ByteBuffer) {
def publishUpdate(key: String, dataBuffer: ByteBuffer): Unit = {
AWS.Kinesis.putRecord(streamName, dataBuffer, key)
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/services/KinesisConsumer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class KinesisConsumer(streamName: String, appName: String, processor: KinesisStr
.config(kinesisClientLibConfiguration)
.build()

def start() { Future{ worker.run() } }
def stop() { worker.shutdown() }
def start(): Unit = { Future{ worker.run() } }
def stop(): Unit = { worker.shutdown() }
}

class KinesisProcessorConsumerFactory(appName: String, processor: KinesisStreamRecordProcessor) extends IRecordProcessorFactory {
Expand Down
2 changes: 1 addition & 1 deletion app/services/SQSQueue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SQSQueue(val queueName: String) {
response.getMessages.asScala.toList
}

def deleteMessage(message: Message) {
def deleteMessage(message: Message): Unit = {
SQS.SQSClient.deleteMessage(
new DeleteMessageRequest(queueUrl, message.getReceiptHandle)
)
Expand Down

0 comments on commit e2462c4

Please sign in to comment.