Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validateur NeTEx : polling des résultats #4326

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ptitfred
Copy link
Contributor

@ptitfred ptitfred commented Nov 21, 2024

Description

Cela permet de ne plus bloquer la queue de validation (que ce soit les ressources historisées ou on demand).

La première implémentation faisait le polling en Elixir, rendant un job bloquant le temps que la validation termine (ou timeout). Ceci créait de la congestion dans les queues de validation historisées ou on demand (surtout problématique pour l'historisé).

La nouvelle implémentation délégue le polling à 2 jobs

  • 1 pour la validation historisée
  • 1 pour la validation on demand

Checklist

  • code non bloquant via des jobs
  • adaptation de /backoffice/jobs pour afficher les jobs en attente
  • tests unitaires
  • tests manuels de OnDemand
  • tests manuels de validation d'une ressource historisée
  • tests manuels de validation concurrente de beaucoup de ressources historisées

Script de test manuel concurrent :

require Logger

Logger.info("Starting...")

import Ecto.Query

defmodule Script do
  # for each active dataset, grab all resources with a resource history.
  def query() do
    DB.Dataset.base_query()
    |> DB.Resource.join_dataset_with_resource()
    |> DB.ResourceHistory.join_resource_with_latest_resource_history()
    |> where([resource: r], r.format == "NeTEx")
    |> select([resource_history: rh], rh)
  end

  def validate_resource_history(resource_history_id) do
    %{
      "force_validation" => true,
      "validator" => Atom.to_string(Transport.Validators.NeTEx),
      "resource_history_id" => resource_history_id
    }
    |> Transport.Jobs.ResourceHistoryValidationJob.new()
  end
end

Script.query()
|> DB.Repo.all()
|> Enum.take(20)
|> Enum.map(&(&1.id |> Script.validate_resource_history()))
|> Oban.insert_all()
|> Logger.info()

Voir #4153

@ptitfred ptitfred requested a review from a team as a code owner November 21, 2024 17:06
@ptitfred ptitfred marked this pull request as draft November 21, 2024 17:06
@ptitfred ptitfred mentioned this pull request Nov 25, 2024
17 tasks
@thbar thbar added the NeTEx label Nov 26, 2024
@ptitfred ptitfred force-pushed the netex-validation/polling-of-results branch 10 times, most recently from 3f6cf5c to f4e5d51 Compare November 27, 2024 10:23
@ptitfred ptitfred force-pushed the netex-validation/polling-of-results branch 2 times, most recently from 7ca429f to 53bf8f4 Compare November 27, 2024 12:13
@ptitfred ptitfred marked this pull request as ready for review November 27, 2024 12:14
@ptitfred ptitfred force-pushed the netex-validation/polling-of-results branch from 53bf8f4 to 8bb70c9 Compare November 28, 2024 10:26
@AntoineAugusti AntoineAugusti self-assigned this Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants