Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Feature: Persist jobs as JSON #4

Merged
merged 30 commits into from
Jan 13, 2023
Merged

Feature: Persist jobs as JSON #4

merged 30 commits into from
Jan 13, 2023

Conversation

gaebel
Copy link
Contributor

@gaebel gaebel commented Dec 16, 2022

Serialization

Seems this can't be achieved elegantly (because of polymorphism and generics). The consumer of the library has to provide the proper serializer for the task via a serializer module. This way custom serializers can also get registered. So basically there's no way to hide kotlinx.serialization from the outside (the outside depends on it).

val scheduler = JobScheduler(customModule = SerializersModule {
    polymorphic(DataTask::class) {
        subclass(TestTask::class, TestTask.serializer())
    }
})

See https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md

Persistence

Persists and restores jobs via SharedPreferences/UserDefaults.


Merge after #3

@gaebel gaebel requested a review from benjohnde December 16, 2022 10:49
@gaebel gaebel changed the base branch from main to feat/remove-factory December 16, 2022 10:49
@gaebel
Copy link
Contributor Author

gaebel commented Dec 19, 2022

To-Do (possibly in separate branch)

  • Expose JobPersister Interface instead of third party Settings class
  • Proper Coroutine job handling
  • Allow automatically starting queue
  • Improve and add more tests
  • Look into concurrency
  • Try serialization with a generic/base task serializer

@gaebel gaebel changed the title Feature: Serialization Feature: Persist jobs as JSON Dec 19, 2022
@gaebel gaebel changed the title Feature: Persist jobs as JSON WIP: Feature: Persist jobs as JSON Dec 19, 2022
@gaebel gaebel changed the title WIP: Feature: Persist jobs as JSON Feature: Persist jobs as JSON Dec 20, 2022
@gaebel gaebel changed the base branch from feat/remove-factory to main December 20, 2022 10:00
@benjohnde
Copy link
Member

LGTM, the 1 second delay is a bit string though, but I am cool with that :) you could investigate different values as well!

@benjohnde
Copy link
Member

I guess we should just finalise a first version, use it in our apps and go public. It will naturally evolve over time. We can add the potential improvements as issues to leave them on our radar somehow!

Copy link
Member

@benjohnde benjohnde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gaebel gaebel merged commit f2ad415 into main Jan 13, 2023
@gaebel gaebel deleted the feat/serializer branch January 13, 2023 12:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants