AppSettings.scala 2.01 KB
Newer Older
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
 * Import Process Delete
 * Copyright (C) 2020 Memoriav
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
19
20
21
22
23
24
25
26
27
package ch.memobase

import java.util.Properties

import scala.util.Random

trait AppSettings {
  val clientId = s"${sys.env("CLIENT_ID")}-${new Random().alphanumeric.take(5).mkString}"
  val inputTopic: String = sys.env("TOPIC_IN")
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
28
  val outputTopic: String = sys.env("TOPIC_OUT")
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  val pollTimeout: Int = sys.env("POLL_TIMEOUT").toInt
  val producerProps: Properties = {
    val props = new Properties()
    props.put("bootstrap.servers", sys.env("KAFKA_BOOTSTRAP_SERVERS"))
    props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer")
    props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer")
    props.put("batch.size", "131072")
    props.put("compression.type", "gzip")
    props
  }
  val consumerProps: Properties = {
    val props = new Properties()
    props.put("bootstrap.servers", sys.env("KAFKA_BOOTSTRAP_SERVERS"))
    props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer")
    props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer")
    props.put("fetch.min.bytes", "1048576")
    props.put("group.id", clientId)
    props.put("allow.auto.create.topics", "false")
    props.put("auto.offset.reset", "earliest")
    props.put("max.poll.records", "5000")
    props
  }
}