ExpDev07 / coronavirus-tracker-api

🦠 A simple and fast (< 200ms) API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak. It's written in python using the 🔥 FastAPI framework. Supports multiple sources!
https://coronavirus-tracker-api.herokuapp.com
GNU General Public License v3.0
1.59k stars 323 forks source link

creational pattern patch #460

Closed atayyabi closed 3 years ago

atayyabi commented 3 years ago

The location services associated with csbs, jhu and nyt require only one instance of each to perform the necessary operation. Therefore in order to avoid wasting memory we would create only one instance of each and access it using the singleton pattern. For this end I created a class-level variable __instance__ and a method getInstance in the parent class LocationService to implement the singleton pattern. And then updated data.init.py module to use the getInstance to retrieve and return the relevant LocationService instance.