Skip to content

Commit

Permalink
refactor(dup): port queries to xandra
Browse files Browse the repository at this point in the history
Ports all the existing queries to xandra, with a little refactor where deemed necessary (no, no `"simple flow"` rework _yet_).
Removes all references to CQEx.

Signed-off-by: Francesco Noacco <[email protected]>
  • Loading branch information
noaccOS committed Aug 31, 2023
1 parent fbad22c commit 33493ad
Show file tree
Hide file tree
Showing 6 changed files with 1,168 additions and 1,349 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,17 +383,9 @@ defmodule Astarte.DataUpdaterPlant.Config do
defdelegate xandra_nodes, to: DataAccessConfig
defdelegate xandra_nodes!, to: DataAccessConfig

@doc """
Returns Cassandra nodes formatted in the CQEx format.
"""
defdelegate cqex_nodes, to: DataAccessConfig
defdelegate cqex_nodes!, to: DataAccessConfig

def xandra_options! do
DataAccessConfig.xandra_options!()
|> Keyword.put(:name, :xandra)
|> Keyword.drop([:autodiscovery])
end

defdelegate cqex_options!, to: DataAccessConfig
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# This file is part of Astarte.
#
# Copyright 2017 Ispirata Srl
# Copyright 2017-2023 SECO Mind Srl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,6 @@ defmodule Astarte.DataUpdaterPlant.DataUpdater do
alias Astarte.DataUpdaterPlant.AMQPDataConsumer
alias Astarte.DataUpdaterPlant.DataUpdater.Server
alias Astarte.DataUpdaterPlant.DataUpdater.Queries
alias Astarte.DataAccess.Database
alias Astarte.DataUpdaterPlant.MessageTracker
require Logger

Expand Down Expand Up @@ -226,19 +225,14 @@ defmodule Astarte.DataUpdaterPlant.DataUpdater do

defp verify_device_exists(realm_name, encoded_device_id) do
with {:ok, decoded_device_id} <- Device.decode_device_id(encoded_device_id),
{:ok, client} <- Database.connect(realm: realm_name),
{:ok, exists?} <- Queries.check_device_exists(client, decoded_device_id) do
if exists? do
:ok
else
_ =
Logger.warn(
"Device #{encoded_device_id} in realm #{realm_name} does not exist.",
tag: "device_does_not_exist"
)

{:error, :device_does_not_exist}
end
{:error, :device_does_not_exist} <-
Queries.check_device_exists(realm_name, decoded_device_id) do
Logger.warn(
"Device #{encoded_device_id} in realm #{realm_name} does not exist.",
tag: "device_does_not_exist"
)

{:error, :device_does_not_exist}
end
end
end
Loading

0 comments on commit 33493ad

Please sign in to comment.