Skip to content

Commit

Permalink
Merge pull request #2 from asundukov/dev
Browse files Browse the repository at this point in the history
fix maximum connections issue
  • Loading branch information
asundukov authored Jul 25, 2020
2 parents 28b6899 + c1569a9 commit f778472
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,24 @@ import org.apache.http.entity.mime.MultipartEntity
import org.apache.http.entity.mime.content.FileBody
import org.apache.http.entity.mime.content.StringBody
import org.apache.http.impl.client.HttpClientBuilder
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager
import org.slf4j.LoggerFactory


class TelegramApi {
class TelegramApi(
maxConnections: Int = 5000
) {

private val connectionManager = PoolingHttpClientConnectionManager()
init {
connectionManager.maxTotal = maxConnections
connectionManager.defaultMaxPerRoute = maxConnections
}

private val objectMapper = jacksonObjectMapper()
private val httpClient = HttpClientBuilder
.create()
.setConnectionManager(connectionManager)
.build()

fun getMe(token: String): TgUser {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ class StatefulBotExample(
private val token: String,
currentBlock: BotBlock
): StatefulBot(currentBlock) {

override fun getToken(): String {
return token
}

}

0 comments on commit f778472

Please sign in to comment.