diff --git a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxEntry.kt b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxEntry.kt index 6d20262..53b0aa3 100644 --- a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxEntry.kt +++ b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxEntry.kt @@ -9,6 +9,7 @@ import java.time.Instant * or [toFailed] — each returning a new immutable copy. */ data class OutboxEntry( + @get:JvmName("getOutboxId") val outboxId: OutboxId, val messageType: String, val payload: String, @@ -47,6 +48,7 @@ data class OutboxEntry( companion object { /** Creates a new PENDING entry from a [message] and [deliveryInfo]. */ + @JvmStatic fun createPending(message: OutboxMessage, deliveryInfo: DeliveryInfo, now: Instant): OutboxEntry = createPending(message, deliveryType = deliveryInfo.type, deliveryMetadata = deliveryInfo.serialize(), now = now) diff --git a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxProcessor.kt b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxProcessor.kt index b29d6cf..6ff0d9a 100644 --- a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxProcessor.kt +++ b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxProcessor.kt @@ -10,6 +10,7 @@ class OutboxProcessor( private val store: OutboxStore, private val entryProcessor: OutboxEntryProcessor, ) { + @JvmOverloads fun processNext(limit: Int = 10) { store.claimPending(limit).forEach { entry -> val updated = entryProcessor.process(entry) diff --git a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxPublisher.kt b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxPublisher.kt index b958a49..6fb1aaf 100644 --- a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxPublisher.kt +++ b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxPublisher.kt @@ -12,10 +12,11 @@ import java.time.Clock * Framework-specific modules (e.g. `okapi-spring`) may provide wrappers that * validate transactional context before delegating here. */ -class OutboxPublisher( +class OutboxPublisher @JvmOverloads constructor( private val outboxStore: OutboxStore, private val clock: Clock = Clock.systemUTC(), ) { + @JvmName("publish") fun publish(outboxMessage: OutboxMessage, deliveryInfo: DeliveryInfo): OutboxId = OutboxEntry .createPending(outboxMessage, deliveryInfo, clock.instant()) .also(outboxStore::persist) diff --git a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxPurger.kt b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxPurger.kt index 3c72376..482f5f6 100644 --- a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxPurger.kt +++ b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxPurger.kt @@ -16,7 +16,7 @@ import java.util.concurrent.atomic.AtomicBoolean * * Delegates to [OutboxStore.removeDeliveredBefore] -- works with any storage adapter. */ -class OutboxPurger( +class OutboxPurger @JvmOverloads constructor( private val outboxStore: OutboxStore, private val config: OutboxPurgerConfig = OutboxPurgerConfig(), private val clock: Clock = Clock.systemUTC(), diff --git a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxScheduler.kt b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxScheduler.kt index 72bd8d8..1de4ebe 100644 --- a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxScheduler.kt +++ b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxScheduler.kt @@ -18,7 +18,7 @@ import java.util.concurrent.atomic.AtomicBoolean * - `okapi-spring-boot`: `SmartLifecycle` * - `okapi-ktor`: `ApplicationStarted` / `ApplicationStopped` */ -class OutboxScheduler( +class OutboxScheduler @JvmOverloads constructor( private val outboxProcessor: OutboxProcessor, private val transactionRunner: TransactionRunner? = null, private val config: OutboxSchedulerConfig = OutboxSchedulerConfig(), diff --git a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxStatus.kt b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxStatus.kt index 3cf01bc..f337b14 100644 --- a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxStatus.kt +++ b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxStatus.kt @@ -9,6 +9,7 @@ enum class OutboxStatus { companion object { /** Resolves a status by matching the given [value] against enum entry names. Throws if unknown. */ + @JvmStatic fun from(value: String): OutboxStatus = requireNotNull(entries.find { it.name == value }) { "Unknown outbox status: $value" } diff --git a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/TransactionalOutboxPublisher.kt b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/TransactionalOutboxPublisher.kt index 2800588..4b96607 100644 --- a/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/TransactionalOutboxPublisher.kt +++ b/okapi-core/src/main/kotlin/com/softwaremill/okapi/core/TransactionalOutboxPublisher.kt @@ -13,6 +13,7 @@ class TransactionalOutboxPublisher( private val delegate: OutboxPublisher, private val validator: TransactionContextValidator, ) { + @JvmName("publish") fun publish(outboxMessage: OutboxMessage, deliveryInfo: DeliveryInfo): OutboxId { check(validator.isInActiveReadWriteTransaction()) { validator.failureMessage } return delegate.publish(outboxMessage, deliveryInfo) diff --git a/okapi-http/src/main/kotlin/com/softwaremill/okapi/http/HttpDeliveryInfo.kt b/okapi-http/src/main/kotlin/com/softwaremill/okapi/http/HttpDeliveryInfo.kt index f5d3a80..6b80b3b 100644 --- a/okapi-http/src/main/kotlin/com/softwaremill/okapi/http/HttpDeliveryInfo.kt +++ b/okapi-http/src/main/kotlin/com/softwaremill/okapi/http/HttpDeliveryInfo.kt @@ -10,7 +10,7 @@ import com.softwaremill.okapi.core.DeliveryInfo * [serviceName] is resolved to a base URL via [ServiceUrlResolver] at delivery time. * [endpointPath] is appended to form the full URL. */ -data class HttpDeliveryInfo( +data class HttpDeliveryInfo @JvmOverloads constructor( override val type: String = TYPE, val serviceName: String, val endpointPath: String, @@ -29,6 +29,7 @@ data class HttpDeliveryInfo( private val mapper = jacksonObjectMapper() /** Deserializes from JSON stored in [OutboxEntry.deliveryMetadata]. */ + @JvmStatic fun deserialize(json: String): HttpDeliveryInfo = mapper.readValue(json) } } diff --git a/okapi-http/src/main/kotlin/com/softwaremill/okapi/http/HttpMessageDeliverer.kt b/okapi-http/src/main/kotlin/com/softwaremill/okapi/http/HttpMessageDeliverer.kt index a67f409..0890ff5 100644 --- a/okapi-http/src/main/kotlin/com/softwaremill/okapi/http/HttpMessageDeliverer.kt +++ b/okapi-http/src/main/kotlin/com/softwaremill/okapi/http/HttpMessageDeliverer.kt @@ -19,7 +19,7 @@ import java.time.Duration * * Connection errors are treated as retriable. */ -class HttpMessageDeliverer( +class HttpMessageDeliverer @JvmOverloads constructor( private val urlResolver: ServiceUrlResolver, private val httpClient: HttpClient = defaultHttpClient(), private val retriableStatusCodes: Set = DEFAULT_RETRIABLE_STATUS_CODES, diff --git a/okapi-kafka/src/main/kotlin/com/softwaremill/okapi/kafka/KafkaDeliveryInfo.kt b/okapi-kafka/src/main/kotlin/com/softwaremill/okapi/kafka/KafkaDeliveryInfo.kt index 38bd713..5ffa545 100644 --- a/okapi-kafka/src/main/kotlin/com/softwaremill/okapi/kafka/KafkaDeliveryInfo.kt +++ b/okapi-kafka/src/main/kotlin/com/softwaremill/okapi/kafka/KafkaDeliveryInfo.kt @@ -10,7 +10,7 @@ import com.softwaremill.okapi.core.DeliveryInfo * [topic] is required. Optional [partitionKey] controls partition routing. * Custom [headers] are sent as UTF-8 encoded Kafka record headers. */ -data class KafkaDeliveryInfo( +data class KafkaDeliveryInfo @JvmOverloads constructor( override val type: String = TYPE, val topic: String, val partitionKey: String? = null, @@ -27,6 +27,7 @@ data class KafkaDeliveryInfo( private val mapper = jacksonObjectMapper() /** Deserializes from JSON stored in [OutboxEntry.deliveryMetadata]. */ + @JvmStatic fun deserialize(json: String): KafkaDeliveryInfo = mapper.readValue(json) } } diff --git a/okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/SpringOutboxPublisher.kt b/okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/SpringOutboxPublisher.kt index 13cbbc7..efde58c 100644 --- a/okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/SpringOutboxPublisher.kt +++ b/okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/SpringOutboxPublisher.kt @@ -30,6 +30,7 @@ class SpringOutboxPublisher(delegate: OutboxPublisher, dataSource: DataSource) { * * @throws IllegalStateException if no active read-write transaction is present. */ + @JvmName("publish") fun publish(outboxMessage: OutboxMessage, deliveryInfo: DeliveryInfo): OutboxId = transactionalPublisher.publish(outboxMessage, deliveryInfo) }