Skip to content

Commit

Permalink
Update jars
Browse files Browse the repository at this point in the history
  • Loading branch information
pambrose committed Nov 27, 2024
1 parent b5ef872 commit 47f6559
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 40 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ stop:
clean:
./gradlew clean

compile:
build: clean
./gradlew build -xtest

publish:
./gradlew publishToMavenLocal

scan:
./gradlew build --scan -xtest

build: compile

uberjar:
./gradlew uberjar

Expand Down Expand Up @@ -57,4 +58,4 @@ depends:
./gradlew dependencies

upgrade-wrapper:
./gradlew wrapper --gradle-version=8.10.2 --distribution-type=bin
./gradlew wrapper --gradle-version=8.11.1 --distribution-type=bin
40 changes: 20 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ plugins {
id 'application'
id 'org.jetbrains.kotlin.jvm' version '2.0.21' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '2.0.21' apply false
id 'org.jmailen.kotlinter' version "4.4.1" apply false
id 'com.github.gmazzo.buildconfig' version '5.5.0' apply false
id 'org.jmailen.kotlinter' version "4.5.0" apply false
id 'com.github.gmazzo.buildconfig' version '5.5.1' apply false
id "com.github.ben-manes.versions" version '0.51.0' apply false
id "org.flywaydb.flyway" version "10.21.0"
id "org.flywaydb.flyway" version "11.0.0"
}

ext {
Expand Down Expand Up @@ -87,11 +87,11 @@ ext {
allprojects {
description = 'ReadingBat Core'
group 'com.github.readingbat'
version '1.40.4'
version '1.40.5'

apply plugin: 'application'
apply plugin: 'java-library'
apply plugin: 'maven-publish' // required for jitpack.io install
apply plugin: 'maven-publish'
apply plugin: 'org.jmailen.kotlinter'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.plugin.serialization'
Expand All @@ -107,21 +107,21 @@ allprojects {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
}
}
// publishing {
// publications {
// mavenJava(MavenPublication) {
// from components.java
// versionMapping {
// usage('java-api') {
// fromResolutionOf('runtimeClasspath')
// }
// usage('java-runtime') {
// fromResolutionResult()
// }
// }
// }
// }
// }
}

subprojects {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ org.gradle.jvmargs=-Xmx8g -Dkotlin.daemon.jvm.options=-Xmx6g -XX:+HeapDumpOnOutO
# Jars
cloud_version=1.21.0
commons_version=1.12.0
css_version=1.0.0-pre.819
css_version=1.0.0-pre.838
exposed_version=0.56.0
flexmark_version=0.64.8
github_api_version=1.324
gson_version=2.11.0
hikari_version=6.1.0
hikari_version=6.2.1
java_script_version=2.0.0
khealth_version=2.1.1
kotest_ktor_version=4.4.3
Expand All @@ -29,4 +29,4 @@ proxy_version=1.22.0
redis_version=5.1.5
sendgrid_version=4.10.2
serialization_version=1.7.3
utils_version=2.1.1
utils_version=2.1.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
28 changes: 28 additions & 0 deletions readingbat-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,34 @@ dependencies {
testImplementation project(':readingbat-kotest')
}

publishing {
publications {
maven(MavenPublication) {
groupId = 'com.github.readingbat'
artifactId = project.name
version = project.version

from components.java
}
}
}

//publishing {
// publications {
// mavenJava(MavenPublication) {
// from components.java
// versionMapping {
// usage('java-api') {
// fromResolutionOf('runtimeClasspath')
// }
// usage('java-runtime') {
// fromResolutionResult()
// }
// }
// }
// }
//}

buildConfig {
packageName("com.github.readingbat")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ sealed class Property(
initFunc = { setPropertyFromConfig(it, "3") },
)

object REDIS_MAX_WAIT_SECS :
Property(
propertyValue = RedisUtils.REDIS_MAX_WAIT_SECS,
initFunc = { setPropertyFromConfig(it, "1") },
)

companion object {
private val logger = KotlinLogging.logger {}

Expand Down Expand Up @@ -412,6 +418,7 @@ sealed class Property(
REDIS_MAX_POOL_SIZE,
REDIS_MAX_IDLE_SIZE,
REDIS_MIN_IDLE_SIZE,
REDIS_MAX_WAIT_SECS,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,7 @@ class User {
classCode.isEnabled -> {
// Check to see if the teacher that owns class has it set as their active class in one of the sessions
val teacherId = classCode.fetchClassTeacherId()
teacherId.isNotEmpty() &&
teacherId.toUser().interestedInActiveClassCode(classCode)
teacherId.isNotEmpty() && teacherId.toUser().interestedInActiveClassCode(classCode)
.also { logger.debug { "Publishing teacherId: $teacherId for $classCode" } }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal object AdminPost {
redis: Jedis,
): String =
when {
isProduction() && user.isNotValidUser() -> adminDataPage(content, user, redis = redis, msg = mustBeLoggedIn)
isProduction() && user.isNotValidUser() -> adminDataPage(content, user, redis, mustBeLoggedIn)
isProduction() && user.isNotAdminUser() -> adminDataPage(content, user, redis, mustBeSysAdmin)
else -> {
when (call.receiveParameters()[ADMIN_ACTION_PARAM] ?: "") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,11 @@ fun Application.module() {
ReadingBatServer.redisPool =
if (isRedisEnabled())
try {
RedisUtils.newJedisPool().also { logger.info { "Created Redis pool" } }
RedisUtils.newJedisPool()
.apply { logger.info { "Created Redis pool: maxIdle=$maxIdle, minIdle=$minIdle maxWait=$maxWaitDuration" } }
} catch (e: JedisConnectionException) {
logger.error { "Failed to create Redis pool: $REDIS_IS_DOWN" }
null // Return null
null
}
else
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ internal object ServerUtils {
redirectTo { e.redirectUrl }
}

suspend fun PipelineCall.respondWithRedisCheck(block: (redis: Jedis) -> String) =
suspend fun PipelineCall.respondWithRedisCheck(block: (Jedis) -> String) =
try {
val html =
redisPool?.withRedisPool { redis ->
Expand All @@ -114,7 +114,7 @@ internal object ServerUtils {
redirectTo { e.redirectUrl }
}

suspend fun PipelineCall.respondWithSuspendingRedisCheck(block: suspend (redis: Jedis) -> String) =
suspend fun PipelineCall.respondWithSuspendingRedisCheck(block: suspend (Jedis) -> String) =
try {
val html =
redisPool?.withSuspendingRedisPool { redis ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@ fun Routing.userRoutes(metrics: Metrics, contentSrc: () -> ReadingBatContent) {
}

get(ADMIN_ENDPOINT, metrics) {
respondWithRedisCheck { redis -> adminDataPage(contentSrc(), fetchUser(), redis = redis) }
respondWithRedisCheck { adminDataPage(contentSrc(), fetchUser(), redis = it) }
}

post(ADMIN_ENDPOINT) {
metrics.measureEndpointRequest(ADMIN_ENDPOINT) {
respondWithSuspendingRedisCheck { redis -> adminActions(contentSrc(), fetchUser(), redis) }
respondWithSuspendingRedisCheck { adminActions(contentSrc(), fetchUser(), redis = it) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ internal object PubSubCommandsWs {
}

fun initThreads() {
logger.info { "Initializing PubSubCommandsWs" }
val pubSub =
object : JedisPubSub() {
override fun onMessage(channel: String?, message: String?) {
Expand Down Expand Up @@ -135,13 +136,16 @@ internal object PubSubCommandsWs {
}

newSingleThreadContext("pubsubcommands-ws-redis").executor.execute {
logger.info { "Starting pubsubcommands-ws-redis thread" }
while (true) {
runCatching {
redisPool?.withNonNullRedisPool { redis ->
redis.subscribe(pubSub, *PubSubTopic.entries.map { it.name }.toTypedArray())
redisPool?.withNonNullRedisPool(true) { redis ->
val topics = PubSubTopic.entries.map { it.name }
logger.info { "Subscribing to $topics" }
redis.subscribe(pubSub, *topics.toTypedArray())
} ?: throw RedisUnavailableException("pubsubWs subscriber")
}.onFailure { e ->
logger.error(e) { "Exception in pubsubWs subscriber ${e.simpleClassName} ${e.message}" }
logger.error(e) { "Exception in pubsubWs subscriber: ${e.simpleClassName} ${e.message}" }
Thread.sleep(5.seconds.inWholeMilliseconds)
}
}
Expand Down

0 comments on commit 47f6559

Please sign in to comment.