Skip to content

Commit 68d2fe9

Browse files
committed
feat: add keepalive option
add a wrapper around the keepalive transport option, which is enabled by default as it resolves a connection issue with scylla cloud mimics astarte-platform/astarte_data_access#126 Signed-off-by: Francesco Noacco <francesco.noacco@secomind.com>
1 parent 04c5732 commit 68d2fe9

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [1.3.0] - Unreleased
8+
### Added
9+
- Add the option to enable keepalive for scylladb connections, using the environment variable
10+
`DOCKER_VERNEMQ_ASTARTE_VMQ_PLUGIN__CASSANDRA__ENABLE_KEEPALIVE`. Defaults to `true`
11+
712
## [1.2.1-rc.0] 2025-08-22
813
### Changed
914
- RPC now uses erlang clustering instead of `astarte_rpc`

lib/astarte_vmq_plugin/config.ex

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,31 @@ defmodule Astarte.VMQ.Plugin.Config do
182182

183183
def xandra_options! do
184184
# TODO handle SNI
185+
keepalive =
186+
case Application.get_env(:astarte_vmq_plugin, :cassandra_enable_keepalive, "true") do
187+
"true" -> true
188+
_ -> false
189+
end
190+
191+
transport_options =
192+
xandra_ssl_options()
193+
|> Keyword.put(:keepalive, keepalive)
194+
185195
[
186196
nodes: Application.get_env(:astarte_vmq_plugin, :cassandra_nodes),
187197
authentication: xandra_authentication_options(),
188198
pool_size: Application.get_env(:astarte_vmq_plugin, :cassandra_pool_size, 10),
189199
encryption: Application.get_env(:astarte_vmq_plugin, :cassandra_ssl_enabled, false),
200+
transport_options: transport_options,
190201
name: :xandra
191202
]
192-
|> populate_xandra_ssl_options!()
193203
end
194204

195-
defp populate_xandra_ssl_options!(options) do
205+
defp xandra_ssl_options do
196206
if Application.get_env(:astarte_vmq_plugin, :cassandra_ssl_enabled, false) do
197-
ssl_options = build_xandra_ssl_options!()
198-
Keyword.put(options, :transport_options, ssl_options)
207+
build_xandra_ssl_options!()
199208
else
200-
options
209+
[]
201210
end
202211
end
203212

priv/astarte_vmq_plugin.schema

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@
145145
{datatype, string}
146146
]}.
147147

148+
{mapping, "astarte_vmq_plugin.cassandra.enable_keepalive", "astarte_vmq_plugin.cassandra_enable_keepalive", [
149+
{datatype, {enum, [true, false]}},
150+
{default, true}
151+
]}.
152+
148153
{translation, "astarte_vmq_plugin.registry_mfa",
149154
fun(Conf) ->
150155
S = cuttlefish:conf_get("astarte_vmq_plugin.registry_mfa", Conf),

0 commit comments

Comments
 (0)