-
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
20 changed files
with
242 additions
and
183 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
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
6 changes: 0 additions & 6 deletions
6
src/main/kotlin/cloud/cosmin/checklister/service/EventSink.kt
This file was deleted.
Oops, something went wrong.
36 changes: 32 additions & 4 deletions
36
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,12 +1,40 @@ | ||
package cloud.cosmin.checklister.service | ||
|
||
import cloud.cosmin.checklister.dto.ItemPostDto | ||
import cloud.cosmin.checklister.dto.ItemGetDto | ||
import cloud.cosmin.checklister.service.event.Event | ||
import cloud.cosmin.checklister.service.event.ToStringEventSerializer | ||
import java.util.* | ||
|
||
enum class ListEventType { | ||
CREATE, UPDATE, ADD | ||
} | ||
|
||
enum class ItemEventType { | ||
UPDATE, RANK | ||
CREATE, UPDATE, RANK | ||
} | ||
|
||
abstract class AbstractEvent : Event { | ||
private val eventSerializer = ToStringEventSerializer() | ||
override fun serialize(): ByteArray { | ||
return eventSerializer.serialize(this) | ||
} | ||
} | ||
|
||
data class ItemUpdateEvent(val type: ItemEventType, val id: UUID, val item: ItemPostDto) | ||
data class ListCreateEvent( | ||
val type: ItemEventType) | ||
|
||
data class ItemCreateEvent( | ||
val type: ItemEventType, | ||
val id: UUID, | ||
val item: ItemGetDto) : AbstractEvent() | ||
|
||
data class ItemUpdateEvent( | ||
val type: ItemEventType, | ||
val id: UUID, | ||
val item: ItemGetDto) : AbstractEvent() | ||
|
||
data class ItemRankEvent(val type: ItemEventType, val id: UUID, val op: RankOperation, val newRank: Int) | ||
data class ItemRankEvent( | ||
val type: ItemEventType, | ||
val id: UUID, | ||
val op: RankOperation, | ||
val item: ItemGetDto) : AbstractEvent() |
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
7 changes: 4 additions & 3 deletions
7
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,13 @@ | ||
package cloud.cosmin.checklister.service | ||
|
||
import cloud.cosmin.checklister.dto.ItemPostDto | ||
import cloud.cosmin.checklister.dto.ItemGetDto | ||
import java.util.* | ||
|
||
/** | ||
* Actions on items that can be audited. | ||
*/ | ||
interface ItemEvents { | ||
fun update(id: UUID, dto: ItemPostDto): Unit | ||
fun rank(id: UUID, op: RankOperation, newRank: Int): Unit | ||
fun create(id: UUID, dto: ItemGetDto) | ||
fun update(id: UUID, dto: ItemGetDto) | ||
fun rank(id: UUID, op: RankOperation, dto: ItemGetDto) | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/cloud/cosmin/checklister/service/event/Event.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package cloud.cosmin.checklister.service.event | ||
|
||
interface Event { | ||
fun serialize(): ByteArray | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/cloud/cosmin/checklister/service/event/EventSerializer.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package cloud.cosmin.checklister.service.event | ||
|
||
interface EventSerializer { | ||
fun serialize(event: Event): ByteArray | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/cloud/cosmin/checklister/service/event/EventSink.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package cloud.cosmin.checklister.service.event | ||
|
||
interface EventSink { | ||
fun accept(event: Event) | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/cloud/cosmin/checklister/service/event/ToStringEventSerializer.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package cloud.cosmin.checklister.service.event | ||
|
||
class ToStringEventSerializer : EventSerializer { | ||
override fun serialize(event: Event): ByteArray { | ||
return event.toString().toByteArray(Charsets.UTF_8) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/kotlin/cloud/cosmin/checklister/service/event/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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cloud.cosmin.checklister.service.event.eventsink | ||
|
||
import cloud.cosmin.checklister.service.event.EventSink | ||
import cloud.cosmin.checklister.service.event.Event | ||
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: Event) { | ||
log.info("Event: {}", String(event.serialize())) | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/main/kotlin/cloud/cosmin/checklister/service/eventsink/LoggerEventSink.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.