1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.user
21 
22 import akka.actor.typed.Behavior
23 import org.make.api.technical.KafkaProducerBehavior
24 import org.make.api.userhistory.{UserEvent, UserEventWrapper}
25 
26 class UserProducerBehavior extends KafkaProducerBehavior[UserEvent, UserEventWrapper] {
27   override protected val topicKey: String = UserProducerBehavior.topicKey
28   override protected def wrapEvent(event: UserEvent): UserEventWrapper = {
29     UserEventWrapper(
30       version = event.version(),
31       id = event.userId.value,
32       date = event.eventDate,
33       eventType = event.getClass.getSimpleName,
34       event = event,
35       eventId = event.eventId
36     )
37   }
38 }
39 
40 object UserProducerBehavior {
41   def apply(): Behavior[UserEvent] = new UserProducerBehavior().createBehavior(name)
42   val name: String = "users-producer"
43   val topicKey: String = "users"
44 }
Line Stmt Id Pos Tree Symbol Tests Code
27 6372 1052 - 1081 Select org.make.api.user.UserProducerBehavior.topicKey UserProducerBehavior.topicKey
29 6208 1161 - 1377 Apply org.make.api.userhistory.UserEventWrapper.apply org.make.api.userhistory.UserEventWrapper.apply(event.version(), event.userId.value, event.eventDate, event.getClass().getSimpleName(), event, event.eventId)
30 7733 1195 - 1210 Apply org.make.api.userhistory.UserEvent.version event.version()
31 7041 1223 - 1241 Select org.make.core.user.UserId.value event.userId.value
32 6173 1256 - 1271 Select org.make.api.userhistory.UserEvent.eventDate event.eventDate
33 7591 1291 - 1319 Apply java.lang.Class.getSimpleName event.getClass().getSimpleName()
35 7086 1358 - 1371 Select org.make.api.userhistory.UserEvent.eventId event.eventId
41 6880 1452 - 1499 Apply org.make.api.technical.KafkaProducerBehavior.createBehavior new UserProducerBehavior().createBehavior(UserProducerBehavior.this.name)
41 7614 1494 - 1498 Select org.make.api.user.UserProducerBehavior.name UserProducerBehavior.this.name
42 6473 1521 - 1537 Literal <nosymbol> "users-producer"
43 7844 1563 - 1570 Literal <nosymbol> "users"