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.proposal 21 22 import akka.actor.typed.Behavior 23 import org.make.api.technical.KafkaProducerBehavior 24 import org.make.core.DateHelper 25 26 class ProposalKafkaProducerBehavior extends KafkaProducerBehavior[PublishedProposalEvent, ProposalEventWrapper] { 27 28 override val topicKey: String = ProposalKafkaProducerBehavior.topicKey 29 30 override protected def wrapEvent(event: PublishedProposalEvent): ProposalEventWrapper = { 31 ProposalEventWrapper( 32 version = event.version(), 33 id = event.id.value, 34 date = DateHelper.now(), 35 eventType = event.getClass.getSimpleName, 36 event = event, 37 eventId = event.eventId 38 ) 39 } 40 41 } 42 43 object ProposalKafkaProducerBehavior { 44 def apply(): Behavior[PublishedProposalEvent] = { 45 new ProposalKafkaProducerBehavior().createBehavior(name) 46 } 47 48 val name: String = "proposal-producer" 49 val topicKey: String = "proposals" 50 }
| Line | Stmt Id | Pos | Tree | Symbol | Tests | Code |
|---|---|---|---|---|---|---|
| 28 | 7862 | 1043 - 1081 | Select | org.make.api.proposal.ProposalKafkaProducerBehavior.topicKey | org.scalatest.testsuite | ProposalKafkaProducerBehavior.topicKey |
| 31 | 7684 | 1179 - 1396 | Apply | org.make.api.proposal.ProposalEventWrapper.apply | ProposalEventWrapper.apply(event.version(), event.id.value, org.make.core.DateHelper.now(), event.getClass().getSimpleName(), event, event.eventId) | |
| 32 | 6961 | 1217 - 1232 | Apply | org.make.api.proposal.PublishedProposalEvent.version | event.version() | |
| 33 | 6532 | 1245 - 1259 | Select | org.make.core.proposal.ProposalId.value | event.id.value | |
| 34 | 5680 | 1274 - 1290 | Apply | org.make.core.DefaultDateHelper.now | org.make.core.DateHelper.now() | |
| 35 | 7110 | 1310 - 1338 | Apply | java.lang.Class.getSimpleName | event.getClass().getSimpleName() | |
| 37 | 6288 | 1377 - 1390 | Select | org.make.api.proposal.PublishedProposalEvent.eventId | event.eventId | |
| 45 | 7192 | 1551 - 1555 | Select | org.make.api.proposal.ProposalKafkaProducerBehavior.name | org.scalatest.testsuite | ProposalKafkaProducerBehavior.this.name |
| 45 | 6396 | 1500 - 1556 | Apply | org.make.api.technical.KafkaProducerBehavior.createBehavior | org.scalatest.testsuite | new ProposalKafkaProducerBehavior().createBehavior(ProposalKafkaProducerBehavior.this.name) |
| 48 | 7799 | 1583 - 1602 | Literal | <nosymbol> | "proposal-producer" | |
| 49 | 6965 | 1628 - 1639 | Literal | <nosymbol> | "proposals" |