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

Question to acthitecture: Where to put potential workers? #33

Open
Berki2021 opened this issue Aug 18, 2021 · 1 comment
Open

Question to acthitecture: Where to put potential workers? #33

Berki2021 opened this issue Aug 18, 2021 · 1 comment

Comments

@Berki2021
Copy link

Berki2021 commented Aug 18, 2021

I really like this repository, and it's architecture and project-structure. Currently, I am trying to implement "clean-achitecture" to one of my projects and stumbled upon one question: Where to put all the worker classes? For example, let's look at the following CoroutineWorker:

@HiltWorker
class DocumentListWorker @AssistedInject constructor(
    @Assisted context: Context,
    @Assisted params: WorkerParameters,
    private val firebaseEntity: DocumentRepository,
    private val documentDao: DocumentDao,
    private val networkMapper: DocumentNetworkMapper,
) : CoroutineWorker(context, params) {
    override suspend fun doWork(): Result {
        Timber.d("Started DocumentWorker")
        // Get Data from Cloud Firestore and map it to a DocumentCacheEntity to insert it to the database
        val documentEntityList = firebaseEntity.getAllDocuments()
        val documentCacheList = networkMapper.mapFromEntityList(documentEntityList)

        documentDao.deleteAll()
        documentDao.insert(documentCacheList)

        return Result.success()
    }
}

My question is: In which package would such a class fit the best? Here are my thoughts:

  1. Not into presentation, because it has nothing to do with ui
  2. Not into domain because it does not represent any sort of domain-data
  3. Not into interactors
  4. Somewhere into datasource, maybe into network as business -> datasource -> network -> worker OR
  5. As another package inside datasource, so business -> datasource -> worker?

I appreciate any answer, thank you very much

@razaghimahdi
Copy link

adding worker package to datasource looks good, maybe adding this class to Utils package? which is could be in presentation package?

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

No branches or pull requests

2 participants