Skip to content

Commit

Permalink
Oh, yeah. It's all coming together.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasdennnoch committed Dec 3, 2023
1 parent 67a7ef2 commit 720bcb0
Show file tree
Hide file tree
Showing 12 changed files with 442 additions and 369 deletions.
9 changes: 7 additions & 2 deletions latte/src/main/java/gg/beemo/latte/CommonConfig.kt
Expand Up @@ -2,7 +2,12 @@ package gg.beemo.latte

object CommonConfig {

const val INVALID_CLUSTER_ID = Integer.MIN_VALUE.toString()
const val VANILLA_CLUSTER_ID = "-1"
object BrokerServices {
const val TEA = "tea" // Bot
const val VANILLA = "vanilla" // Bot cluster coordinator
const val MILK = "milk" // Raid logs
const val SUGAR = "sugar" // Premium management
const val COFFEE = "coffee" // Raid bans
}

}
7 changes: 1 addition & 6 deletions latte/src/main/java/gg/beemo/latte/TestBrokerClient.kt
Expand Up @@ -7,11 +7,6 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.toList
import kotlin.time.Duration.Companion.seconds

// TODO This would be in the CommonConfig or similar.
object BrokerServices {
const val TEA = "tea"
}

class Tea {
companion object {
val cluster: Cluster = Cluster()
Expand Down Expand Up @@ -67,7 +62,7 @@ class TestBrokerClient(connection: BrokerConnection) : BrokerClient(connection)
// This is something that needs to be adapted at the connection level as well.
val response = greetingRpc.call(
GreetingRequest(name),
services = setOf(BrokerServices.TEA),
services = setOf(CommonConfig.BrokerServices.TEA),
instances = setOf("0"),
timeout = 5.seconds,
)
Expand Down
Expand Up @@ -3,22 +3,34 @@ package gg.beemo.latte.broker
import java.util.*

open class BaseBrokerMessageHeaders(
val clientId: String?,
val sourceService: String,
val sourceInstance: String?,
val sourceInstance: String,
val targetServices: Set<String>,
val targetInstances: Set<String>,
val inReplyTo: String? = null,
val inReplyTo: String?,
messageId: String?,
) {

val messageId: MessageId = UUID.randomUUID().toString()
val messageId: String = messageId ?: UUID.randomUUID().toString()

companion object {

const val HEADER_CLIENT_ID = "client-id"
const val HEADER_REQUEST_ID = "request-id"
const val HEADER_SOURCE_CLUSTER = "source-cluster"
const val HEADER_TARGET_CLUSTERS = "target-clusters"
const val HEADER_SOURCE_SERVICE = "source-service"
const val HEADER_SOURCE_INSTANCE = "source-instance"
const val HEADER_TARGET_SERVICES = "target-services"
const val HEADER_TARGET_INSTANCES = "target-instances"
const val HEADER_MESSAGE_ID = "message-id"
const val HEADER_IN_REPLY_TO = "in-reply-to"

@JvmStatic
protected fun splitToSet(value: String): Set<String> {
return value.split(",").filter { it.isNotEmpty() }.toSet()
}

@JvmStatic
protected fun joinToString(value: Set<String>): String {
return value.joinToString(",")
}

}

Expand Down

0 comments on commit 720bcb0

Please sign in to comment.