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

DB Optimization - Cache Service Callback #2247

Open
8 tasks
k-macmillan opened this issue Jan 15, 2025 · 0 comments
Open
8 tasks

DB Optimization - Cache Service Callback #2247

k-macmillan opened this issue Jan 15, 2025 · 0 comments

Comments

@k-macmillan
Copy link
Member

k-macmillan commented Jan 15, 2025

User Story - Business Need

Reducing the number of queries against our data is necessary to maintain a stable product. Collection of bearer tokens is done on every callback update status.

  • Ticket is understood, and QA has been contacted (if the ticket has a QA label).

User Story(ies)

As a VA Notify reliability dev
I want to reduce unnecessary DB calls
So that our db is only used when necessary

Additional Info and Resources

It all starts inside check_and_queue_service_callback_task and you likely want a dataclass with the following fields:

  • id
  • url
  • bearer_token (set with Encryption.encrypt)
  • include_provider_payload
  • callback_type

⚠️ json.dumps does not like bytes

Image

Acceptance Criteria

  • Uses a dataclass for the necessary fields of ServiceCallback (see Additional Info)
  • Uses Encryption.encrypt method and Encryption.decrypt
  • Uses @cached(cache=TTLCache(maxsize=1024, ttl=600))
  • 10 notifications sent should query the database at most once per worker
  • Tested with a callback that requires bearer tokens
  • SQS callback not forgotten
  • This work is added to the sprint review slide deck (key win bullet point and demo slide)

QA Considerations

Should be no difference for end-users.

Potential Dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants