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

Merge/last integration #159

Merged
merged 4 commits into from
May 25, 2024
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
@@ -1,11 +1,5 @@
package piperkt.common.events

import piperkt.common.ddd.ValueObject
import kotlin.js.ExperimentalJsExport
import kotlin.js.JsExport

@OptIn(ExperimentalJsExport::class)
@JsExport
interface DomainEvent : ValueObject {
val type: String get() = this::class.simpleName!!
}
interface DomainEvent : ValueObject
24 changes: 20 additions & 4 deletions events/src/commonMain/kotlin/piperkt/events/ChannelEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@ import kotlin.js.JsExport
sealed interface ChannelEvent : DomainEvent

@JsExport
data class ChannelCreatedEvent(val serverId: String, val channelId: String) : ChannelEvent
data class ChannelCreatedEvent(val serverId: String, val channelId: String) : ChannelEvent {
companion object {
const val TOPIC = "channel-created"
}
}

@JsExport
data class ChannelUpdatedEvent(val serverId: String, val channelId: String) : ChannelEvent
data class ChannelUpdatedEvent(val serverId: String, val channelId: String) : ChannelEvent {
companion object {
const val TOPIC = "channel-updated"
}
}

@JsExport
data class ChannelDeletedEvent(val serverId: String, val channelId: String) : ChannelEvent
data class ChannelDeletedEvent(val serverId: String, val channelId: String) : ChannelEvent {
companion object {
const val TOPIC = "channel-deleted"
}
}

@JsExport
data class MessageInChannelEvent(
Expand All @@ -23,7 +35,11 @@ data class MessageInChannelEvent(
val messageId: String,
val sender: String,
val content: String
) : ChannelEvent
) : ChannelEvent {
companion object {
const val TOPIC = "message-in-channel"
}
}


interface ChannelEventPublisher : EventPublisher<ChannelEvent>
24 changes: 20 additions & 4 deletions events/src/commonMain/kotlin/piperkt/events/FriendshipEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,36 @@ import kotlin.js.JsExport
sealed interface FriendshipEvent : DomainEvent

@JsExport
data class FriendshipRequestSentEvent(val fromUser: String, val toUser: String) : FriendshipEvent
data class FriendshipRequestSentEvent(val fromUser: String, val toUser: String) : FriendshipEvent {
companion object {
const val TOPIC: String = "friendship-request-sent"
}
}

@JsExport
data class FriendshipRequestAcceptedEvent(val fromUser: String, val toUser: String) : FriendshipEvent
data class FriendshipRequestAcceptedEvent(val fromUser: String, val toUser: String) : FriendshipEvent {
companion object {
const val TOPIC: String = "friendship-request-accepted"
}
}

@JsExport
data class FriendshipRequestRejectedEvent(val fromUser: String, val toUser: String) : FriendshipEvent
data class FriendshipRequestRejectedEvent(val fromUser: String, val toUser: String) : FriendshipEvent {
companion object {
const val TOPIC: String = "friendship-request-rejected"
}
}

@JsExport
data class NewMessageInFriendshipEvent(
val fromUser: String,
val toUser: String,
val messageId: String,
val content: String
) : FriendshipEvent
) : FriendshipEvent {
companion object {
const val TOPIC: String = "new-message-in-friendship"
}
}

interface FriendshipEventPublisher : EventPublisher<FriendshipEvent>
46 changes: 35 additions & 11 deletions events/src/commonMain/kotlin/piperkt/events/ServerEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,40 @@ import kotlin.js.JsExport

@JsExport sealed interface ServerEvent : DomainEvent

@JsExport data class ServerCreatedEvent(val serverId: String, val owner: String) : ServerEvent

@JsExport data class ServerUpdatedEvent(val serverId: String) : ServerEvent

@JsExport data class ServerUserAddedEvent(val serverId: String, val username: String) : ServerEvent

@JsExport data class ServerUserRemovedEvent(val serverId: String, val username: String) : ServerEvent

@JsExport data class ServerUserKickedEvent(val serverId: String, val username: String) : ServerEvent

@JsExport data class ServerDeletedEvent(val serverId: String) : ServerEvent
@JsExport data class ServerCreatedEvent(val serverId: String, val owner: String) : ServerEvent {
companion object {
const val TOPIC = "server-created"
}
}

@JsExport data class ServerUpdatedEvent(val serverId: String) : ServerEvent {
companion object {
const val TOPIC = "server-updated"
}
}

@JsExport data class ServerUserAddedEvent(val serverId: String, val username: String) : ServerEvent {
companion object {
const val TOPIC = "server-user-added"
}
}

@JsExport data class ServerUserRemovedEvent(val serverId: String, val username: String) : ServerEvent {
companion object {
const val TOPIC = "server-user-removed"
}
}

@JsExport data class ServerUserKickedEvent(val serverId: String, val username: String) : ServerEvent {
companion object {
const val TOPIC = "server-user-kicked"
}
}

@JsExport data class ServerDeletedEvent(val serverId: String) : ServerEvent {
companion object {
const val TOPIC = "server-deleted"
}
}

interface ServerEventPublisher : EventPublisher<ServerEvent>
46 changes: 35 additions & 11 deletions events/src/commonMain/kotlin/piperkt/events/SessionEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,40 @@ import kotlin.js.JsExport

@JsExport sealed interface SessionEvent : DomainEvent

@JsExport data class SessionCreatedEvent(val sessionId: String, val allowedUsers: Set<String>) : SessionEvent

@JsExport data class SessionDeletedEvent(val sessionId: String) : SessionEvent

@JsExport data class AllowedUserAddedEvent(val sessionId: String, val username: String) : SessionEvent

@JsExport data class AllowedUserRemovedEvent(val sessionId: String, val user: String) : SessionEvent

@JsExport data class ParticipantJoinedEvent(val sessionId: String, val user: String) : SessionEvent

@JsExport data class ParticipantLeftEvent(val sessionId: String, val user: String) : SessionEvent
@JsExport data class SessionCreatedEvent(val sessionId: String, val allowedUsers: Set<String>) : SessionEvent {
companion object {
const val TOPIC = "session-created"
}
}

@JsExport data class SessionDeletedEvent(val sessionId: String) : SessionEvent {
companion object {
const val TOPIC = "session-deleted"
}
}

@JsExport data class AllowedUserAddedEvent(val sessionId: String, val username: String) : SessionEvent {
companion object {
const val TOPIC = "allowed-user-added"
}
}

@JsExport data class AllowedUserRemovedEvent(val sessionId: String, val user: String) : SessionEvent {
companion object {
const val TOPIC = "allowed-user-removed"
}
}

@JsExport data class ParticipantJoinedEvent(val sessionId: String, val user: String) : SessionEvent {
companion object {
const val TOPIC = "participant-joined"
}
}

@JsExport data class ParticipantLeftEvent(val sessionId: String, val user: String) : SessionEvent {
companion object {
const val TOPIC = "participant-left"
}
}

interface SessionEventPublisher : EventPublisher<SessionEvent>
36 changes: 30 additions & 6 deletions events/src/commonMain/kotlin/piperkt/events/UserEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import kotlin.js.JsExport
val email: String? = null,
val description: String? = null,
val profilePicture: String? = null,
) : UserEvent
) : UserEvent {
companion object {
const val TOPIC = "user-created"
}
}

/**
* User updated event.
Expand All @@ -33,14 +37,34 @@ import kotlin.js.JsExport
val email: String? = null,
val description: String? = null,
val profilePicture: String? = null,
) : UserEvent
) : UserEvent {
companion object {
const val TOPIC = "user-updated"
}
}

@JsExport data class UserLoggedInEvent(val username: String) : UserEvent
@JsExport data class UserLoggedInEvent(val username: String) : UserEvent {
companion object {
const val TOPIC = "user-logged-in"
}
}

@JsExport data class UserLoggedOutEvent(val username: String) : UserEvent
@JsExport data class UserLoggedOutEvent(val username: String) : UserEvent {
companion object {
const val TOPIC = "user-logged-out"
}
}

@JsExport data class UserOnlineEvent(val username: String) : UserEvent
@JsExport data class UserOnlineEvent(val username: String) : UserEvent {
companion object {
const val TOPIC = "user-online"
}
}

@JsExport data class UserOfflineEvent(val username: String) : UserEvent
@JsExport data class UserOfflineEvent(val username: String) : UserEvent {
companion object {
const val TOPIC = "user-offline"
}
}

interface UserEventPublisher : EventPublisher<UserEvent>
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import piperkt.events.*
@KafkaClient
interface KafkaFriendshipEventPublisher {

@Topic("friendship-events") fun publish(event: FriendshipRequestSentEvent)
@Topic(FriendshipRequestSentEvent.TOPIC) fun publish(event: FriendshipRequestSentEvent)

@Topic("friendship-events") fun publish(event: FriendshipRequestAcceptedEvent)
@Topic(FriendshipRequestAcceptedEvent.TOPIC) fun publish(event: FriendshipRequestAcceptedEvent)

@Topic("friendship-events") fun publish(event: NewMessageInFriendshipEvent)
@Topic(NewMessageInFriendshipEvent.TOPIC) fun publish(event: NewMessageInFriendshipEvent)

@Topic("friendship-events") fun publish(event: FriendshipRequestRejectedEvent)
@Topic(FriendshipRequestRejectedEvent.TOPIC) fun publish(event: FriendshipRequestRejectedEvent)
}

@Singleton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package piperkt.services.friendships.infrastructure.events

import io.micronaut.serde.annotation.SerdeImport
import piperkt.events.FriendshipEvent
import piperkt.events.FriendshipRequestAcceptedEvent
import piperkt.events.FriendshipRequestRejectedEvent
import piperkt.events.FriendshipRequestSentEvent
import piperkt.events.NewMessageInFriendshipEvent

@SerdeImport(FriendshipEvent::class) object SerializableFriendshipEvents
@SerdeImport(FriendshipRequestSentEvent::class)
@SerdeImport(FriendshipRequestAcceptedEvent::class)
@SerdeImport(FriendshipRequestRejectedEvent::class)
@SerdeImport(NewMessageInFriendshipEvent::class)
object SerializableFriendshipEvents
8 changes: 4 additions & 4 deletions kubernetes/helm-chart/piper-chart/templates/micronaut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ spec:
failureThreshold: 10
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"
cpu: "200m"
cpu: "500m"
limits:
memory: "2048Mi"
cpu: "1000m"
---
apiVersion: v1
kind: Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import piperkt.services.multimedia.application.server.ChannelEventsListener

@KafkaListener
class ChannelEventsKafkaListener(private val channelEventsListener: ChannelEventsListener) {
@Topic("channel-created")
@Topic(ChannelCreatedEvent.TOPIC)
fun onChannelCreated(event: ChannelCreatedEvent) = channelEventsListener.handle(event)

@Topic("channel-deleted")
@Topic(ChannelDeletedEvent.TOPIC)
fun onChannelDeleted(event: ChannelDeletedEvent) = channelEventsListener.handle(event)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import piperkt.services.multimedia.application.direct.DirectEventsListener

@KafkaListener
class DirectEventsKafkaListener(private val directEventsListener: DirectEventsListener) {
@Topic("friend-request-accepted")
@Topic(FriendshipRequestAcceptedEvent.TOPIC)
fun onFriendRequestAccepted(event: FriendshipRequestAcceptedEvent) =
directEventsListener.handle(event)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import piperkt.services.multimedia.application.server.ServerEventsListener

@KafkaListener
class ServerEventsKafkaListener(private val serverEventsListener: ServerEventsListener) {
@Topic("server-created")
@Topic(ServerCreatedEvent.TOPIC)
fun onServerCreated(event: ServerCreatedEvent) = serverEventsListener.handle(event)

@Topic("server-deleted")
@Topic(ServerDeletedEvent.TOPIC)
fun onServerDeleted(event: ServerDeletedEvent) = serverEventsListener.handle(event)

@Topic("user-joined-server")
@Topic(ServerUserAddedEvent.TOPIC)
fun onUserJoinedServer(event: ServerUserAddedEvent) = serverEventsListener.handle(event)

@Topic("user-left-server")
@Topic(ServerUserRemovedEvent.TOPIC)
fun onUserLeftServer(event: ServerUserRemovedEvent) = serverEventsListener.handle(event)

@Topic("user-kicked-from-server")
@Topic(ServerUserKickedEvent.TOPIC)
fun onUserKickedFromServer(event: ServerUserKickedEvent) = serverEventsListener.handle(event)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ interface SessionEventKafkaPublisher : SessionEventPublisher {
}
}

@Topic("session-created") fun publishSessionCreated(event: SessionCreatedEvent)
@Topic(SessionCreatedEvent.TOPIC) fun publishSessionCreated(event: SessionCreatedEvent)

@Topic("session-deleted") fun publishSessionDeleted(event: SessionDeletedEvent)
@Topic(SessionDeletedEvent.TOPIC) fun publishSessionDeleted(event: SessionDeletedEvent)

@Topic("allowed-user-added") fun publishAllowedUserAdded(event: AllowedUserAddedEvent)
@Topic(AllowedUserAddedEvent.TOPIC) fun publishAllowedUserAdded(event: AllowedUserAddedEvent)

@Topic("allowed-user-removed") fun publishAllowedUserRemoved(event: AllowedUserRemovedEvent)
@Topic(AllowedUserRemovedEvent.TOPIC)
fun publishAllowedUserRemoved(event: AllowedUserRemovedEvent)

@Topic("participant-joined") fun publishParticipantJoined(event: ParticipantJoinedEvent)
@Topic(ParticipantJoinedEvent.TOPIC) fun publishParticipantJoined(event: ParticipantJoinedEvent)

@Topic("participant-left") fun publishParticipantLeft(event: ParticipantLeftEvent)
@Topic(ParticipantLeftEvent.TOPIC) fun publishParticipantLeft(event: ParticipantLeftEvent)
}
5 changes: 5 additions & 0 deletions notifications-service/src/main/typescript/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { Microservice } from "./commons/service";
import { NotificationsServiceConfiguration } from "./configuration";

process.on("SIGTERM", async () => {
console.log("Shutting down notifications service");
process.exit(0);
});

const service = new Microservice(NotificationsServiceConfiguration);
service.start();
Loading
Loading