TableEntriesI'm starting out with RxScala and I'm trying to come up with a polling mechanism that checks the database for every interval (say 20 seconds), to check if there was any change in some of the rows in the table.
object MyDatabaseService {
def getAllEntries: List[MyTableEntries] = ???
}
I would need to start out with an Observable that will emit List[MyTableEntries]. So I started out with the following:
class MyDBObservable(service: MyDatabaseService, observer: Observer[Seq[MyTableEntries]]) extends Observable[Seq[MyTableEntries]] {
val o = Observable.interval(10.seconds).map { _ => service.getAllTableEntries }
o.subscribe(observer)
}
In my Observer that I pass in to the function, I have the onNext, onError and onCompleted implemented! There are a couple of questions however:
- What happens if my database takes more than 30 seconds to respond
- What happens if my database is completely down?
Is this a valid approach what I have done? Suggestions?