Skip to content

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

Open
@Berki2021

Description

@Berki2021

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions