ЕСОЗ - публічна документація

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Purpose

This procedure is designed for using timeout in resending SMS flow.

Key Point

  • In order to remove expired attempts records are saved in Redis db with expire parameter.

Input Parameters

  • MAX_ATTEMPTS_COUNT - specifies the maximum number of retries before resend is rejected;

  • SEND_TIMEOUT -specifies a number of seconds to wait to retry sending after an error condition ;(attempts.count() >= MAX_ATTEMPTS_COUNT);

  • entity_name - i.e. “medication_request”;

  • entity_id - i.e. medication_request_id.

Logic

  1. Get array with all attempts which start with “{entity_name}:{entity_id}” from Redis db using script:

    [redis] KEYS $"{entity_name}:{entity_id}_*"
  2. Get attempts.count();

  3. If attempts.count() < MAX_ATTEMPTS_COUNT

    • generate attempt_id using structure: {entity_name}:{entity_id}_{datetime.now()},
      (i.e. "medication_request:b075f148-7f93-4fc2-b2ec-2d81b19a9b7_2022-12-22T10:30:45.255687")

    • save attempt to Redis db using attempt_id as key and datetime.now() as value using script:

      [redis] set attempt_id $"{datetime.now()}"
    • set timeout to attempt with SEND_TIMEOUT parameter using script:

      [redis] expire key SEND_TIMEOUT
    • return 200 (ok).20

  4. Else (attempts.count() >= MAX_ATTEMPTS_COUNT)

    • do not save attempt;

    • return error 429 ("Sending SMS timeout. Try later. Next attempt will be available at <attempts.oldest.value + SEND_TIMEOUT>").

  • No labels