mirror of
https://github.com/vacp2p/linea-monorepo.git
synced 2026-01-09 15:38:06 -05:00
feat: delete duplicated HttpJsonRpcServer and use the one from jvm-libs (#340)
* feat: delete duplicated HttpJsonRpcServer and use the one from jvm-libs * feat: update tx-exclusion-api image tag
This commit is contained in:
@@ -309,7 +309,7 @@ services:
|
||||
transaction-exclusion-api:
|
||||
hostname: transaction-exclusion-api
|
||||
container_name: transaction-exclusion-api
|
||||
image: consensys/linea-transaction-exclusion-api:${TRANSACTION_EXCLUSION_API_TAG:-cd58916}
|
||||
image: consensys/linea-transaction-exclusion-api:${TRANSACTION_EXCLUSION_API_TAG:-8749f92}
|
||||
profiles: [ "l2", "debug" ]
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
|
||||
@@ -10,7 +10,6 @@ import io.vertx.ext.web.Router
|
||||
import io.vertx.ext.web.RoutingContext
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import org.apache.logging.log4j.Logger
|
||||
import java.lang.Void
|
||||
|
||||
class HttpJsonRpcServer(
|
||||
private val port: UInt,
|
||||
@@ -20,6 +19,13 @@ class HttpJsonRpcServer(
|
||||
private val log: Logger = LogManager.getLogger(this.javaClass)
|
||||
private lateinit var httpServer: HttpServer
|
||||
|
||||
val bindedPort: Int
|
||||
get() = if (this::httpServer.isInitialized) {
|
||||
httpServer.actualPort()
|
||||
} else {
|
||||
throw IllegalStateException("Http server not started")
|
||||
}
|
||||
|
||||
override fun start(startPromise: Promise<Void>) {
|
||||
val options = HttpServerOptions().setPort(port.toInt()).setReusePort(true)
|
||||
log.debug("Creating Http server on port {}", port)
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.consensys.linea.jsonrpc.HttpRequestHandler
|
||||
import net.consensys.linea.jsonrpc.JsonRpcMessageHandler
|
||||
import net.consensys.linea.jsonrpc.JsonRpcMessageProcessor
|
||||
import net.consensys.linea.jsonrpc.JsonRpcRequestRouter
|
||||
import net.consensys.linea.jsonrpc.httpserver.HttpJsonRpcServer
|
||||
import net.consensys.linea.vertx.ObservabilityServer
|
||||
|
||||
data class ApiConfig(
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package net.consensys.linea.traces.app.api
|
||||
|
||||
import io.vertx.core.AbstractVerticle
|
||||
import io.vertx.core.AsyncResult
|
||||
import io.vertx.core.Handler
|
||||
import io.vertx.core.Promise
|
||||
import io.vertx.core.http.HttpServer
|
||||
import io.vertx.core.http.HttpServerOptions
|
||||
import io.vertx.ext.web.Router
|
||||
import io.vertx.ext.web.RoutingContext
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import org.apache.logging.log4j.Logger
|
||||
import java.lang.Void
|
||||
|
||||
class HttpJsonRpcServer(
|
||||
private val port: UInt,
|
||||
private val path: String,
|
||||
private val requestHandler: Handler<RoutingContext>
|
||||
) : AbstractVerticle() {
|
||||
private val log: Logger = LogManager.getLogger(this.javaClass)
|
||||
private lateinit var httpServer: HttpServer
|
||||
|
||||
override fun start(startPromise: Promise<Void>) {
|
||||
val options = HttpServerOptions().setPort(port.toInt()).setReusePort(true)
|
||||
log.debug("Creating Http server on port {}", port)
|
||||
httpServer = vertx.createHttpServer(options)
|
||||
httpServer.requestHandler(buildRouter())
|
||||
httpServer.listen { res: AsyncResult<HttpServer> ->
|
||||
if (res.succeeded()) {
|
||||
log.info("Http server started and listening on port {}", res.result().actualPort())
|
||||
startPromise.complete()
|
||||
} else {
|
||||
log.error("Creating Http server: {}", res.cause())
|
||||
startPromise.fail(res.cause())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildRouter(): Router {
|
||||
val router = Router.router(vertx)
|
||||
router.route(path).produces("application/json").handler(requestHandler)
|
||||
return router
|
||||
}
|
||||
|
||||
override fun stop(endFuture: Promise<Void>) {
|
||||
httpServer.close(endFuture)
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import net.consensys.linea.jsonrpc.HttpRequestHandler
|
||||
import net.consensys.linea.jsonrpc.JsonRpcMessageHandler
|
||||
import net.consensys.linea.jsonrpc.JsonRpcMessageProcessor
|
||||
import net.consensys.linea.jsonrpc.JsonRpcRequestRouter
|
||||
import net.consensys.linea.jsonrpc.httpserver.HttpJsonRpcServer
|
||||
import net.consensys.linea.transactionexclusion.TransactionExclusionServiceV1
|
||||
import net.consensys.linea.vertx.ObservabilityServer
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package net.consensys.linea.transactionexclusion.app.api
|
||||
|
||||
import io.vertx.core.AbstractVerticle
|
||||
import io.vertx.core.AsyncResult
|
||||
import io.vertx.core.Handler
|
||||
import io.vertx.core.Promise
|
||||
import io.vertx.core.http.HttpServer
|
||||
import io.vertx.core.http.HttpServerOptions
|
||||
import io.vertx.ext.web.Router
|
||||
import io.vertx.ext.web.RoutingContext
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import org.apache.logging.log4j.Logger
|
||||
|
||||
class HttpJsonRpcServer(
|
||||
private val port: UInt,
|
||||
private val path: String,
|
||||
private val requestHandler: Handler<RoutingContext>
|
||||
) : AbstractVerticle() {
|
||||
private val log: Logger = LogManager.getLogger(this.javaClass)
|
||||
private lateinit var httpServer: HttpServer
|
||||
val bindedPort: Int
|
||||
get() = if (this::httpServer.isInitialized) {
|
||||
httpServer.actualPort()
|
||||
} else {
|
||||
throw IllegalStateException("Http server not started")
|
||||
}
|
||||
|
||||
override fun start(startPromise: Promise<Void>) {
|
||||
val options = HttpServerOptions().setPort(port.toInt()).setReusePort(true)
|
||||
log.debug("Creating Http server on port {}", port)
|
||||
httpServer = vertx.createHttpServer(options)
|
||||
httpServer.requestHandler(buildRouter())
|
||||
httpServer.listen { res: AsyncResult<HttpServer> ->
|
||||
if (res.succeeded()) {
|
||||
log.info("Http server started and listening on port {}", res.result().actualPort())
|
||||
startPromise.complete()
|
||||
} else {
|
||||
log.error("Creating Http server: {}", res.cause())
|
||||
startPromise.fail(res.cause())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildRouter(): Router {
|
||||
val router = Router.router(vertx)
|
||||
router.route(path).produces("application/json").handler(requestHandler)
|
||||
return router
|
||||
}
|
||||
|
||||
override fun stop(endFuture: Promise<Void>) {
|
||||
httpServer.close(endFuture)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user