diff --git a/java-agent/src/jvmMain/kotlin/com/epam/drill/agent/transport/BuildPayload.kt b/java-agent/src/jvmMain/kotlin/com/epam/drill/agent/transport/BuildPayload.kt new file mode 100644 index 00000000..98a3cfdb --- /dev/null +++ b/java-agent/src/jvmMain/kotlin/com/epam/drill/agent/transport/BuildPayload.kt @@ -0,0 +1,31 @@ +/** + * Copyright 2020 - 2022 EPAM Systems + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.epam.drill.agent.transport + +import com.epam.drill.agent.common.transport.AgentMessage +import kotlinx.serialization.Serializable + +@Serializable +class BuildPayload( + val groupId: String, + val appId: String, + val commitSha: String? = null, + val buildVersion: String? = null, + val branch: String? = null, + val commitDate: String? = null, + val commitMessage: String? = null, + val commitAuthor: String? = null +) : AgentMessage() \ No newline at end of file diff --git a/java-agent/src/jvmMain/kotlin/com/epam/drill/agent/transport/InstancePayload.kt b/java-agent/src/jvmMain/kotlin/com/epam/drill/agent/transport/InstancePayload.kt new file mode 100644 index 00000000..e00724be --- /dev/null +++ b/java-agent/src/jvmMain/kotlin/com/epam/drill/agent/transport/InstancePayload.kt @@ -0,0 +1,29 @@ +/** + * Copyright 2020 - 2022 EPAM Systems + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.epam.drill.agent.transport + +import com.epam.drill.agent.common.transport.AgentMessage +import kotlinx.serialization.Serializable + +@Serializable +class InstancePayload( + val groupId: String, + val appId: String, + val instanceId: String, + val commitSha: String? = null, + val buildVersion: String? = null, + val envId: String? = null, +): AgentMessage() \ No newline at end of file diff --git a/java-agent/src/jvmMain/kotlin/com/epam/drill/agent/transport/JvmModuleMessageSender.kt b/java-agent/src/jvmMain/kotlin/com/epam/drill/agent/transport/JvmModuleMessageSender.kt index 62b4c39f..8150a767 100644 --- a/java-agent/src/jvmMain/kotlin/com/epam/drill/agent/transport/JvmModuleMessageSender.kt +++ b/java-agent/src/jvmMain/kotlin/com/epam/drill/agent/transport/JvmModuleMessageSender.kt @@ -29,6 +29,7 @@ import com.epam.drill.agent.common.transport.AgentMessageDestination import com.epam.drill.agent.common.transport.AgentMessageSender import kotlinx.serialization.InternalSerializationApi import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable actual object JvmModuleMessageSender : AgentMessageSender { @@ -43,16 +44,28 @@ actual object JvmModuleMessageSender : AgentMessageSender { actual fun sendAgentMetadata() { messageSender.send( AgentMessageDestination("PUT", "instances"), - Configuration.agentMetadata, - AgentMetadata.serializer() + InstancePayload( + groupId = Configuration.agentMetadata.groupId, + appId = Configuration.agentMetadata.appId, + instanceId = Configuration.agentMetadata.instanceId, + commitSha = Configuration.agentMetadata.commitSha, + buildVersion = Configuration.agentMetadata.buildVersion, + envId = Configuration.agentMetadata.envId + ), + InstancePayload.serializer() ) } fun sendBuildMetadata() { messageSender.send( AgentMessageDestination("PUT", "builds"), - Configuration.agentMetadata, - AgentMetadata.serializer() + BuildPayload( + groupId = Configuration.agentMetadata.groupId, + appId = Configuration.agentMetadata.appId, + commitSha = Configuration.agentMetadata.commitSha, + buildVersion = Configuration.agentMetadata.buildVersion + ), + BuildPayload.serializer() ) } @@ -81,6 +94,7 @@ actual object JvmModuleMessageSender : AgentMessageSender { "DIRECT" -> SimpleAgentMessageSender(transport, serializer, mapper).also { logger.info { "Using DIRECT message sending mode." } } + "QUEUED" -> QueuedAgentMessageSender( transport, serializer, mapper, queue, maxRetries = Configuration.parameters[ParameterDefinitions.MESSAGE_MAX_RETRIES]