-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
72 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package cloud.cosmin.checklister.service | ||
|
||
interface EventSink { | ||
fun accept(event: ItemEvent) | ||
fun accept(event: ItemUpdateEvent) | ||
fun accept(event: ItemRankEvent) | ||
} |
8 changes: 3 additions & 5 deletions
8
src/main/kotlin/cloud/cosmin/checklister/service/ItemEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
package cloud.cosmin.checklister.service | ||
|
||
import cloud.cosmin.checklister.dto.ItemUpdateDto | ||
import cloud.cosmin.checklister.dto.ItemPostDto | ||
import java.util.* | ||
|
||
enum class ItemEventType { | ||
UPDATE, RANK | ||
} | ||
|
||
abstract class ItemEvent(val type: ItemEventType, val id: UUID) | ||
data class ItemUpdateEvent(val type: ItemEventType, val id: UUID, val item: ItemPostDto) | ||
|
||
data class ItemUpdateEvent(val payload: ItemUpdateDto) : ItemEvent(ItemEventType.UPDATE, payload.id) | ||
|
||
data class ItemRankEvent(val payload: UUID, val op: RankOperation) : ItemEvent(ItemEventType.RANK, payload) | ||
data class ItemRankEvent(val type: ItemEventType, val id: UUID, val op: RankOperation, val newRank: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/main/kotlin/cloud/cosmin/checklister/service/ItemEvents.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package cloud.cosmin.checklister.service | ||
|
||
import cloud.cosmin.checklister.dto.ItemUpdateDto | ||
import cloud.cosmin.checklister.dto.ItemPostDto | ||
import java.util.* | ||
|
||
/** | ||
* Actions on items that can be audited. | ||
*/ | ||
interface ItemEvents { | ||
fun update(dto: ItemUpdateDto): Unit | ||
fun rank(id: UUID, op: RankOperation): Unit | ||
fun update(id: UUID, dto: ItemPostDto): Unit | ||
fun rank(id: UUID, op: RankOperation, newRank: Int): Unit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
src/main/kotlin/cloud/cosmin/checklister/service/eventsink/LoggerEventSink.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
package cloud.cosmin.checklister.service.eventsink | ||
|
||
import cloud.cosmin.checklister.service.EventSink | ||
import cloud.cosmin.checklister.service.ItemEvent | ||
import cloud.cosmin.checklister.service.ItemRankEvent | ||
import cloud.cosmin.checklister.service.ItemUpdateEvent | ||
import org.apache.logging.log4j.LogManager | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class LoggerEventSink : EventSink { | ||
private val log = LogManager.getLogger(javaClass) | ||
|
||
override fun accept(event: ItemEvent) { | ||
override fun accept(event: ItemUpdateEvent) { | ||
log.info("ItemEvent: {}", event) | ||
} | ||
|
||
override fun accept(event: ItemRankEvent) { | ||
log.info("ItemEvent: {}", event) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Configuration status="WARN"> | ||
<Appenders> | ||
<Console name="Console" target="SYSTEM_OUT"> | ||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> | ||
</Console> | ||
</Appenders> | ||
<Loggers> | ||
<Root level="error"> | ||
<AppenderRef ref="Console"/> | ||
</Root> | ||
<Logger name="cloud.cosmin.checklister.service.eventsink.LoggerEventSink" level="info"/> | ||
</Loggers> | ||
</Configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters