Skip to content

Commit

Permalink
Merge pull request #658 from hexagonkt/develop
Browse files Browse the repository at this point in the history
Minor changes and documentation update
  • Loading branch information
jaguililla authored Aug 31, 2023
2 parents 589efef + 8d856c7 commit c5d4360
Show file tree
Hide file tree
Showing 57 changed files with 888 additions and 345 deletions.
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plugins {
id("org.jetbrains.dokka") version("1.8.20")
id("com.github.jk1.dependency-license-report") version("2.5")
id("org.jetbrains.kotlinx.binary-compatibility-validator") version("0.13.2")
id("org.graalvm.buildtools.native") version("0.9.24") apply(false)
id("org.graalvm.buildtools.native") version("0.9.25") apply(false)
id("io.gitlab.arturbosch.detekt") version("1.23.1") apply(false)
id("me.champeau.jmh") version("0.7.1") apply(false)
}
Expand Down Expand Up @@ -153,6 +153,7 @@ apiValidation {
// Experimental modules
"rest",
"rest_tools",
// "serverless",
"web",
)
)
Expand Down
8 changes: 4 additions & 4 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ public abstract interface class com/hexagonkt/core/logging/LoggingPort {
public abstract fun setLoggerLevel (Ljava/lang/String;Lcom/hexagonkt/core/logging/LoggingLevel;)V
}

public final class com/hexagonkt/core/logging/PrintLogger : com/hexagonkt/core/logging/LoggerPort {
public final class com/hexagonkt/core/logging/SystemLogger : com/hexagonkt/core/logging/LoggerPort {
public fun <init> (Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/String;
public final fun copy (Ljava/lang/String;)Lcom/hexagonkt/core/logging/PrintLogger;
public static synthetic fun copy$default (Lcom/hexagonkt/core/logging/PrintLogger;Ljava/lang/String;ILjava/lang/Object;)Lcom/hexagonkt/core/logging/PrintLogger;
public final fun copy (Ljava/lang/String;)Lcom/hexagonkt/core/logging/SystemLogger;
public static synthetic fun copy$default (Lcom/hexagonkt/core/logging/SystemLogger;Ljava/lang/String;ILjava/lang/Object;)Lcom/hexagonkt/core/logging/SystemLogger;
public fun equals (Ljava/lang/Object;)Z
public final fun getName ()Ljava/lang/String;
public fun hashCode ()I
Expand All @@ -276,7 +276,7 @@ public final class com/hexagonkt/core/logging/PrintLogger : com/hexagonkt/core/l
public fun toString ()Ljava/lang/String;
}

public final class com/hexagonkt/core/logging/PrintLoggingAdapter : com/hexagonkt/core/logging/LoggingPort {
public final class com/hexagonkt/core/logging/SystemLoggingAdapter : com/hexagonkt/core/logging/LoggingPort {
public fun <init> ()V
public fun <init> (Lcom/hexagonkt/core/logging/LoggingLevel;)V
public synthetic fun <init> (Lcom/hexagonkt/core/logging/LoggingLevel;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package com.hexagonkt.core.logging
import kotlin.reflect.KClass

/**
* Manages Logs using [PrintLoggingAdapter]
* Manages Logs using [SystemLoggingAdapter]
*/
object LoggingManager {
var useColor: Boolean = true
var adapter: LoggingPort = PrintLoggingAdapter()
var adapter: LoggingPort = SystemLoggingAdapter()
var defaultLoggerName: String = "com.hexagonkt.core.logging"
set(value) {
require(value.isNotEmpty()) { "Default logger name cannot be empty string" }
Expand Down
16 changes: 0 additions & 16 deletions core/src/main/kotlin/com/hexagonkt/core/logging/PrintLogger.kt

This file was deleted.

28 changes: 28 additions & 0 deletions core/src/main/kotlin/com/hexagonkt/core/logging/SystemLogger.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.hexagonkt.core.logging

import com.hexagonkt.core.logging.LoggingLevel.*

data class SystemLogger(val name: String) : LoggerPort {

private val logger: System.Logger = System.getLogger(name)

override fun <E : Throwable> log(level: LoggingLevel, exception: E, message: (E) -> Any?) {
if (LoggingManager.isLoggerLevelEnabled(name, level))
logger.log(level(level), message(exception).toString(), exception)
}

override fun log(level: LoggingLevel, message: () -> Any?) {
if (LoggingManager.isLoggerLevelEnabled(name, level))
logger.log(level(level), message())
}

private fun level(level: LoggingLevel): System.Logger.Level =
when (level) {
TRACE -> System.Logger.Level.TRACE
DEBUG -> System.Logger.Level.DEBUG
INFO -> System.Logger.Level.INFO
WARN -> System.Logger.Level.WARNING
ERROR -> System.Logger.Level.ERROR
OFF -> System.Logger.Level.OFF
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package com.hexagonkt.core.logging
import com.hexagonkt.core.logging.LoggingLevel.INFO
import com.hexagonkt.core.require

// TODO Wrap these loggers using System.Logger:
// https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/System.Logger.html
class PrintLoggingAdapter(defaultLevel: LoggingLevel = INFO) : LoggingPort {
class SystemLoggingAdapter(defaultLevel: LoggingLevel = INFO) : LoggingPort {

private val loggerLevels: MutableMap<String, LoggingLevel> = mutableMapOf("" to defaultLevel)

override fun createLogger(name: String): LoggerPort =
PrintLogger(name)
SystemLogger(name)

override fun setLoggerLevel(name: String, level: LoggingLevel) {
loggerLevels[name] = level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class LoggingManagerTest {
// TODO Repeat this test on other logging adapters
@Test fun `Loggers are enabled and disabled at runtime`() {

LoggingManager.adapter = PrintLoggingAdapter()
LoggingManager.adapter = SystemLoggingAdapter()
val allLevels = LoggingLevel.values()

val ch = Logger("com.hx")
Expand Down
13 changes: 7 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.warning.mode=all
org.gradle.console=plain

# Gradle
version=3.0.3
version=3.0.4
group=com.hexagonkt
description=The atoms of your platform

Expand Down Expand Up @@ -37,23 +37,24 @@ mockkVersion=1.13.7
junitVersion=5.10.0
gatlingVersion=3.9.5
jmhVersion=1.37
mkdocsMaterialVersion=9.2.4
mkdocsMaterialVersion=9.2.6
mermaidDokkaVersion=0.4.4
nativeToolsVersion=0.9.24
nativeToolsVersion=0.9.25

# http_server_netty
nettyVersion=4.1.96.Final
nettyVersion=4.1.97.Final
nettyTcNativeVersion=2.0.61.Final

# http_server_nima
nimaVersion=4.0.0-M1

# http_server_servlet
servletVersion=6.0.0
#jettyVersion=12.0.1 Failing with HTTP client gzip encoding
jettyVersion=12.0.0

# rest_tools
vertxVersion=4.4.4
vertxVersion=4.4.5
swaggerParserVersion=2.1.16

# logging
Expand All @@ -62,7 +63,7 @@ logbackVersion=1.4.11

# serialization
jacksonVersion=2.15.2
dslJsonVersion=2.0.1
dslJsonVersion=2.0.2

# templates_freemarker
freemarkerVersion=2.3.32
Expand Down
6 changes: 4 additions & 2 deletions gradle/application.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ tasks.register("jpackage") {

final String options = findProperty("options")
final String icon = findProperty("icon")
final String modules = findProperty("modules") ?: "java.logging"
final String modules = findProperty("modules")
final String jarAllName = "$name-all-${version}.jar"
final java.nio.file.Path jarAll = buildDir.resolve("libs/$jarAllName")
final java.nio.file.Path jpackageJar = buildDir.resolve("jpackage/$jarAllName")
Expand All @@ -78,10 +78,12 @@ tasks.register("jpackage") {
"--description", project.description ?: name,
"--name", name,
"--input", tmp.absolutePath,
"--add-modules", modules,
"--main-jar", jarAllName
]

if (modules != null)
command += [ "--add-modules", modules ]

if (options != null)
command += [ "--java-options", options ]

Expand Down
2 changes: 1 addition & 1 deletion gradle/kotlin.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply(plugin: "maven-publish")
defaultTasks("build")

java {
sourceCompatibility = JavaVersion.toVersion(findProperty("jvmTarget") ?: "11")
sourceCompatibility = JavaVersion.toVersion(findProperty("jvmTarget") ?: "17")
targetCompatibility = sourceCompatibility
}

Expand Down
6 changes: 5 additions & 1 deletion handlers/src/main/kotlin/com/hexagonkt/handlers/OnHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ data class OnHandler<T : Any>(

override fun process(context: Context<T>): Context<T> =
try {
callback(context).with(handled = true).next()
val callbackContext = callback(context)
if (callbackContext.handled)
callbackContext.next()
else
callbackContext.with(handled = true).next()
}
catch (e: Exception) {
context.with(exception = e).next()
Expand Down
50 changes: 26 additions & 24 deletions http/http_client/api/http_client.api
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ public final class com/hexagonkt/http/client/HttpClient : java/io/Closeable {
public synthetic fun <init> (Lcom/hexagonkt/http/client/HttpClientPort;Lcom/hexagonkt/http/client/HttpClientSettings;Lcom/hexagonkt/http/handlers/HttpHandler;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun close ()V
public final fun cookiesMap ()Ljava/util/Map;
public final fun delete (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun delete$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun get (Ljava/lang/String;Lcom/hexagonkt/http/model/Headers;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun get$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Lcom/hexagonkt/http/model/Headers;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun delete (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun delete$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun get (Ljava/lang/String;Lcom/hexagonkt/http/model/Headers;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun get$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Lcom/hexagonkt/http/model/Headers;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun getCookies ()Ljava/util/List;
public final fun getHandler ()Lcom/hexagonkt/http/handlers/HttpHandler;
public final fun getSettings ()Lcom/hexagonkt/http/client/HttpClientSettings;
public final fun head (Ljava/lang/String;Lcom/hexagonkt/http/model/Headers;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun head$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Lcom/hexagonkt/http/model/Headers;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun options (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/Headers;Lcom/hexagonkt/http/model/ContentType;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun options$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/Headers;Lcom/hexagonkt/http/model/ContentType;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun patch (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun patch$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun post (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun post$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun put (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun put$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun options (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/Headers;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun options$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/Headers;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun patch (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun patch$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun post (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun post$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun put (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun put$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun request (Lkotlin/jvm/functions/Function1;)V
public final fun send (Lcom/hexagonkt/http/model/HttpRequest;Ljava/util/Map;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun send$default (Lcom/hexagonkt/http/client/HttpClient;Lcom/hexagonkt/http/model/HttpRequest;Ljava/util/Map;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
Expand All @@ -29,8 +29,8 @@ public final class com/hexagonkt/http/client/HttpClient : java/io/Closeable {
public final fun start ()V
public final fun started ()Z
public final fun stop ()V
public final fun trace (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun trace$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun trace (Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;)Lcom/hexagonkt/http/model/HttpResponsePort;
public static synthetic fun trace$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Ljava/lang/Object;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ILjava/lang/Object;)Lcom/hexagonkt/http/model/HttpResponsePort;
public final fun ws (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;)Lcom/hexagonkt/http/model/ws/WsSession;
public static synthetic fun ws$default (Lcom/hexagonkt/http/client/HttpClient;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/hexagonkt/http/model/ws/WsSession;
}
Expand All @@ -50,19 +50,21 @@ public final class com/hexagonkt/http/client/HttpClientPort$DefaultImpls {

public final class com/hexagonkt/http/client/HttpClientSettings {
public fun <init> ()V
public fun <init> (Ljava/net/URL;Lcom/hexagonkt/http/model/ContentType;ZLcom/hexagonkt/http/model/Headers;ZLcom/hexagonkt/http/SslSettings;Lcom/hexagonkt/http/model/Authorization;Z)V
public synthetic fun <init> (Ljava/net/URL;Lcom/hexagonkt/http/model/ContentType;ZLcom/hexagonkt/http/model/Headers;ZLcom/hexagonkt/http/SslSettings;Lcom/hexagonkt/http/model/Authorization;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/net/URL;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ZLcom/hexagonkt/http/model/Headers;ZLcom/hexagonkt/http/SslSettings;Lcom/hexagonkt/http/model/Authorization;Z)V
public synthetic fun <init> (Ljava/net/URL;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ZLcom/hexagonkt/http/model/Headers;ZLcom/hexagonkt/http/SslSettings;Lcom/hexagonkt/http/model/Authorization;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/net/URL;
public final fun component2 ()Lcom/hexagonkt/http/model/ContentType;
public final fun component3 ()Z
public final fun component4 ()Lcom/hexagonkt/http/model/Headers;
public final fun component5 ()Z
public final fun component6 ()Lcom/hexagonkt/http/SslSettings;
public final fun component7 ()Lcom/hexagonkt/http/model/Authorization;
public final fun component8 ()Z
public final fun copy (Ljava/net/URL;Lcom/hexagonkt/http/model/ContentType;ZLcom/hexagonkt/http/model/Headers;ZLcom/hexagonkt/http/SslSettings;Lcom/hexagonkt/http/model/Authorization;Z)Lcom/hexagonkt/http/client/HttpClientSettings;
public static synthetic fun copy$default (Lcom/hexagonkt/http/client/HttpClientSettings;Ljava/net/URL;Lcom/hexagonkt/http/model/ContentType;ZLcom/hexagonkt/http/model/Headers;ZLcom/hexagonkt/http/SslSettings;Lcom/hexagonkt/http/model/Authorization;ZILjava/lang/Object;)Lcom/hexagonkt/http/client/HttpClientSettings;
public final fun component3 ()Ljava/util/List;
public final fun component4 ()Z
public final fun component5 ()Lcom/hexagonkt/http/model/Headers;
public final fun component6 ()Z
public final fun component7 ()Lcom/hexagonkt/http/SslSettings;
public final fun component8 ()Lcom/hexagonkt/http/model/Authorization;
public final fun component9 ()Z
public final fun copy (Ljava/net/URL;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ZLcom/hexagonkt/http/model/Headers;ZLcom/hexagonkt/http/SslSettings;Lcom/hexagonkt/http/model/Authorization;Z)Lcom/hexagonkt/http/client/HttpClientSettings;
public static synthetic fun copy$default (Lcom/hexagonkt/http/client/HttpClientSettings;Ljava/net/URL;Lcom/hexagonkt/http/model/ContentType;Ljava/util/List;ZLcom/hexagonkt/http/model/Headers;ZLcom/hexagonkt/http/SslSettings;Lcom/hexagonkt/http/model/Authorization;ZILjava/lang/Object;)Lcom/hexagonkt/http/client/HttpClientSettings;
public fun equals (Ljava/lang/Object;)Z
public final fun getAccept ()Ljava/util/List;
public final fun getAuthorization ()Lcom/hexagonkt/http/model/Authorization;
public final fun getBaseUrl ()Ljava/net/URL;
public final fun getContentType ()Lcom/hexagonkt/http/model/ContentType;
Expand Down
Loading

0 comments on commit c5d4360

Please sign in to comment.