Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ marketing_diagram_generation/outputs/*
.specstory
project/project
coursier
metals.sbt
metals.sbt
obp-http4s-runner/src/main/resources/git.properties
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ To compile and run Jetty, install Maven 3, create your configuration in `obp-api
mvn install -pl .,obp-commons && mvn jetty:run -pl obp-api
```

### Running http4s server (obp-http4s-runner)

To run the API using the http4s server (without Jetty), use the `obp-http4s-runner` module from the project root:

```sh
MAVEN_OPTS="-Xms3G -Xmx6G -XX:MaxMetaspaceSize=2G" mvn -pl obp-http4s-runner -am clean package -DskipTests=true -Dmaven.test.skip=true && \
java -jar obp-http4s-runner/target/obp-http4s-runner.jar
```

The http4s server binds to `http4s.host` / `http4s.port` as configured in your props file (defaults are `127.0.0.1` and `8181`).

### ZED IDE Setup

For ZED IDE users, we provide a complete development environment with Scala language server support:
Expand Down
80 changes: 18 additions & 62 deletions obp-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,6 @@
<webXmlPath>src/main/resources/web.xml</webXmlPath>
</properties>
</profile>
<profile>
<id>http4s-jar</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${project.artifactId}-http4s</finalName>
<archive>
<manifest>
<mainClass>bootstrap.http4s.Http4sServer</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</configuration>
<executions>
<execution>
<id>http4s-fat-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<pluginRepositories>
<pluginRepository>
Expand All @@ -83,7 +37,8 @@
<groupId>com.tesobe</groupId>
<artifactId>obp-commons</artifactId>
</dependency>
<!--embed akka adapter start-->
<!--embed akka adapter start - COMMENTED OUT FOR PEKKO MIGRATION-->
<!-- TODO: Find or create Pekko equivalent for adapter-akka-commons
<dependency>
<groupId>com.github.OpenBankProject.OBP-Adapter-Akka-SpringBoot</groupId>
<artifactId>adapter-akka-commons</artifactId>
Expand All @@ -95,6 +50,7 @@
</exclusion>
</exclusions>
</dependency>
-->
<!--embed akka adapter end-->
<dependency>
<groupId>com.github.everit-org.json-schema</groupId>
Expand Down Expand Up @@ -288,21 +244,21 @@
<artifactId>signpost-commonshttp4</artifactId>
<version>1.2.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-http-core -->
<!-- https://mvnrepository.com/artifact/org.apache.pekko/pekko-http-core -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-core_${scala.version}</artifactId>
<version>10.1.6</version>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-http-core_${scala.version}</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_${scala.version}</artifactId>
<version>${akka.version}</version>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-actor_${scala.version}</artifactId>
<version>${pekko.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-remote_${scala.version}</artifactId>
<version>${akka.version}</version>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-remote_${scala.version}</artifactId>
<version>${pekko.version}</version>
</dependency>
<dependency>
<groupId>com.sksamuel.avro4s</groupId>
Expand All @@ -316,8 +272,8 @@
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>chill-akka_${scala.version}</artifactId>
<version>0.9.1</version>
<artifactId>chill_${scala.version}</artifactId>
<version>0.9.3</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
Expand All @@ -337,9 +293,9 @@
<version>0.9.3</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-slf4j_${scala.version}</artifactId>
<version>${akka.version}</version>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-slf4j_${scala.version}</artifactId>
<version>${pekko.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.dwickern/scala-nameof_2.11 -->
<dependency>
Expand Down
10 changes: 10 additions & 0 deletions obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -1683,3 +1683,13 @@ securelogging_mask_credit_card=true

# Email addresses
securelogging_mask_email=true


############################################
# http4s server configuration
############################################

# Host and port for http4s server (used by bootstrap.http4s.Http4sServer)
# Defaults (if not set) are 127.0.0.1 and 8181
http4s.host=127.0.0.1
http4s.port=8086
52 changes: 26 additions & 26 deletions obp-api/src/main/scala/code/actorsystem/ObpActorConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ object ObpActorConfig {

val commonConf =
"""
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
pekko {
loggers = ["org.apache.pekko.event.slf4j.Slf4jLogger"]
loglevel = """ + akka_loglevel + """
actor {
provider = "akka.remote.RemoteActorRefProvider"
allow-java-serialization = off
provider = "org.apache.pekko.remote.RemoteActorRefProvider"
allow-java-serialization = on
kryo {
type = "graph"
idstrategy = "default"
Expand All @@ -40,31 +40,31 @@ object ObpActorConfig {
resolve-subclasses = true
}
serializers {
kryo = "com.twitter.chill.akka.AkkaSerializer"
java = "org.apache.pekko.serialization.JavaSerializer"
}
serialization-bindings {
"net.liftweb.common.Full" = kryo,
"net.liftweb.common.Empty" = kryo,
"net.liftweb.common.Box" = kryo,
"net.liftweb.common.ParamFailure" = kryo,
"code.api.APIFailure" = kryo,
"com.openbankproject.commons.model.BankAccount" = kryo,
"com.openbankproject.commons.model.View" = kryo,
"com.openbankproject.commons.model.User" = kryo,
"com.openbankproject.commons.model.ViewId" = kryo,
"com.openbankproject.commons.model.BankIdAccountIdViewId" = kryo,
"com.openbankproject.commons.model.Permission" = kryo,
"scala.Unit" = kryo,
"scala.Boolean" = kryo,
"java.io.Serializable" = kryo,
"scala.collection.immutable.List" = kryo,
"akka.actor.ActorSelectionMessage" = kryo,
"code.model.Consumer" = kryo,
"code.model.AppType" = kryo
"net.liftweb.common.Full" = java,
"net.liftweb.common.Empty" = java,
"net.liftweb.common.Box" = java,
"net.liftweb.common.ParamFailure" = java,
"code.api.APIFailure" = java,
"com.openbankproject.commons.model.BankAccount" = java,
"com.openbankproject.commons.model.View" = java,
"com.openbankproject.commons.model.User" = java,
"com.openbankproject.commons.model.ViewId" = java,
"com.openbankproject.commons.model.BankIdAccountIdViewId" = java,
"com.openbankproject.commons.model.Permission" = java,
"scala.Unit" = java,
"scala.Boolean" = java,
"java.io.Serializable" = java,
"scala.collection.immutable.List" = java,
"org.apache.pekko.actor.ActorSelectionMessage" = java,
"code.model.Consumer" = java,
"code.model.AppType" = java
}
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
enabled-transports = ["org.apache.pekko.remote.netty.tcp"]
netty {
tcp {
send-buffer-size = 50000000
Expand All @@ -79,7 +79,7 @@ object ObpActorConfig {
val lookupConf =
s"""
${commonConf}
akka {
pekko {
remote.netty.tcp.hostname = ${localHostname}
remote.netty.tcp.port = 0
}
Expand All @@ -88,7 +88,7 @@ object ObpActorConfig {
val localConf =
s"""
${commonConf}
akka {
pekko {
remote.netty.tcp.hostname = ${localHostname}
remote.netty.tcp.port = ${localPort}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package code.actorsystem

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import code.bankconnectors.akka.actor.AkkaConnectorActorConfig
import code.util.Helper
import code.util.Helper.MdcLoggable
Expand Down
12 changes: 6 additions & 6 deletions obp-api/src/main/scala/code/actorsystem/ObpLookupSystem.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package code.actorsystem

import akka.actor.{ActorSystem}
import org.apache.pekko.actor.{ActorSystem}
import code.api.util.APIUtil
import code.bankconnectors.LocalMappedOutInBoundTransfer
import code.bankconnectors.akka.actor.{AkkaConnectorActorConfig, AkkaConnectorHelperActor}
import code.util.Helper
import code.util.Helper.MdcLoggable
import com.openbankproject.adapter.akka.commons.config.AkkaConfig
// import com.openbankproject.adapter.pekko.commons.config.PekkoConfig // TODO: Re-enable when Pekko adapter is available
import com.typesafe.config.ConfigFactory
import net.liftweb.common.Full

Expand Down Expand Up @@ -38,7 +38,7 @@ trait ObpLookupSystem extends MdcLoggable {
if (port == 0) {
logger.error("Failed to connect to local Remotedata actor, the port is 0, can not find a proper port in current machine.")
}
s"akka.tcp://ObpActorSystem_${props_hostname}@${hostname}:${port}/user/${actorName}"
s"pekko.tcp://ObpActorSystem_${props_hostname}@${hostname}:${port}/user/${actorName}"
}

this.obpLookupSystem.actorSelection(actorPath)
Expand All @@ -55,7 +55,7 @@ trait ObpLookupSystem extends MdcLoggable {
val hostname = h
val port = p
val akka_connector_hostname = Helper.getAkkaConnectorHostname
s"akka.tcp://SouthSideAkkaConnector_${akka_connector_hostname}@${hostname}:${port}/user/${actorName}"
s"pekko.tcp://SouthSideAkkaConnector_${akka_connector_hostname}@${hostname}:${port}/user/${actorName}"

case _ =>
val hostname = AkkaConnectorActorConfig.localHostname
Expand All @@ -66,12 +66,12 @@ trait ObpLookupSystem extends MdcLoggable {
}

if(embeddedAdapter) {
AkkaConfig(LocalMappedOutInBoundTransfer, Some(ObpActorSystem.northSideAkkaConnectorActorSystem))
// AkkaConfig(LocalMappedOutInBoundTransfer, Some(ObpActorSystem.northSideAkkaConnectorActorSystem)) // TODO: Re-enable when Pekko adapter is available
} else {
AkkaConnectorHelperActor.startAkkaConnectorHelperActors(ObpActorSystem.northSideAkkaConnectorActorSystem)
}

s"akka.tcp://SouthSideAkkaConnector_${props_hostname}@${hostname}:${port}/user/${actorName}"
s"pekko.tcp://SouthSideAkkaConnector_${props_hostname}@${hostname}:${port}/user/${actorName}"
}
this.obpLookupSystem.actorSelection(actorPath)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package code.api.dynamic.endpoint.helper

import akka.http.scaladsl.model.{HttpMethods, HttpMethod => AkkaHttpMethod}
import org.apache.pekko.http.scaladsl.model.{HttpMethods, HttpMethod => PekkoHttpMethod}
import code.DynamicData.{DynamicDataProvider, DynamicDataT}
import code.DynamicEndpoint.{DynamicEndpointProvider, DynamicEndpointT}
import code.api.util.APIUtil.{BigDecimalBody, BigIntBody, BooleanBody, DoubleBody, EmptyBody, FloatBody, IntBody, JArrayBody, LongBody, PrimaryDataBody, ResourceDoc, StringBody}
Expand Down Expand Up @@ -171,15 +171,15 @@ object DynamicEndpointHelper extends RestHelper {
* @param r HttpRequest
* @return (adapterUrl, requestBodyJson, httpMethod, requestParams, pathParams, role, operationId, mockResponseCode->mockResponseBody)
*/
def unapply(r: Req): Option[(String, JValue, AkkaHttpMethod, Map[String, List[String]], Map[String, String], ApiRole, String, Option[(Int, JValue)], Option[String])] = {
def unapply(r: Req): Option[(String, JValue, PekkoHttpMethod, Map[String, List[String]], Map[String, String], ApiRole, String, Option[(Int, JValue)], Option[String])] = {

val requestUri = r.request.uri //eg: `/obp/dynamic-endpoint/fashion-brand-list/BRAND_ID`
val partPath = r.path.partPath //eg: List("fashion-brand-list","BRAND_ID"), the dynamic is from OBP URL, not in the partPath now.

if (!testResponse_?(r) || !requestUri.startsWith(s"/${ApiStandards.obp.toString}/${ApiShortVersions.`dynamic-endpoint`.toString}"+urlPrefix))//if check the Content-Type contains json or not, and check the if it is the `dynamic_endpoints_url_prefix`
None //if do not match `URL and Content-Type`, then can not find this endpoint. return None.
else {
val akkaHttpMethod = HttpMethods.getForKeyCaseInsensitive(r.requestType.method).get
val pekkoHttpMethod = HttpMethods.getForKeyCaseInsensitive(r.requestType.method).get
val httpMethod = HttpMethod.valueOf(r.requestType.method)
val urlQueryParameters = r.params
// url that match original swagger endpoint.
Expand Down Expand Up @@ -230,7 +230,7 @@ object DynamicEndpointHelper extends RestHelper {

val Some(role::_) = doc.roles
val requestBodyJValue = body(r).getOrElse(JNothing)
Full(s"""$serverUrl$url""", requestBodyJValue, akkaHttpMethod, urlQueryParameters, pathParams, role, doc.operationId, mockResponse, bankId)
Full(s"""$serverUrl$url""", requestBodyJValue, pekkoHttpMethod, urlQueryParameters, pathParams, role, doc.operationId, mockResponse, bankId)
}

}
Expand Down
8 changes: 4 additions & 4 deletions obp-api/src/main/scala/code/api/util/DynamicUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ object DynamicUtil extends MdcLoggable{
|import java.util.Date
|import java.util.UUID.randomUUID
|
|import _root_.akka.stream.StreamTcpException
|import akka.http.scaladsl.model.headers.RawHeader
|import akka.http.scaladsl.model.{HttpProtocol, _}
|import akka.util.ByteString
|import _root_.org.apache.pekko.stream.StreamTcpException
|import org.apache.pekko.http.scaladsl.model.headers.RawHeader
|import org.apache.pekko.http.scaladsl.model.{HttpProtocol, _}
|import org.apache.pekko.util.ByteString
|import code.api.APIFailureNewStyle
|import code.api.ResourceDocs1_4_0.MessageDocsSwaggerDefinitions
|import code.api.cache.Caching
Expand Down
2 changes: 1 addition & 1 deletion obp-api/src/main/scala/code/api/util/NewStyle.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package code.api.util


import akka.http.scaladsl.model.HttpMethod
import org.apache.pekko.http.scaladsl.model.HttpMethod
import code.DynamicEndpoint.{DynamicEndpointProvider, DynamicEndpointT}
import code.api.Constant.{SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID}
import code.api.builder.PaymentInitiationServicePISApi.APIMethods_PaymentInitiationServicePISApi.checkPaymentServerTypeError
Expand Down
2 changes: 1 addition & 1 deletion obp-api/src/main/scala/code/bankconnectors/Connector.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package code.bankconnectors

import _root_.akka.http.scaladsl.model.HttpMethod
import org.apache.pekko.http.scaladsl.model.HttpMethod
import code.api.attributedefinition.AttributeDefinition
import code.api.util.APIUtil.{OBPReturnType, _}
import code.api.util.ErrorMessages._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package code.bankconnectors

import _root_.akka.http.scaladsl.model.HttpMethod
import _root_.org.apache.pekko.http.scaladsl.model.HttpMethod
import code.DynamicData.DynamicDataProvider
import code.accountapplication.AccountApplicationX
import code.accountattribute.AccountAttributeX
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package code.bankconnectors.akka

import java.util.Date
import akka.pattern.ask
import org.apache.pekko.pattern.ask
import code.actorsystem.ObpLookupSystem
import code.api.ResourceDocs1_4_0.MessageDocsSwaggerDefinitions
import code.api.ResourceDocs1_4_0.MessageDocsSwaggerDefinitions.{bankAccountCommons, bankCommons, transaction, _}
Expand Down
Loading
Loading