Skip to content

Throttling Observables #4115

Closed
Closed
@abersnaze

Description

@abersnaze

We have a problem where multiple code paths are making different calls to a backend service but we want to throttle the number of concurrent requests that each client is making. The problem is that different requests could be different types or without knowledge of the other happening something like this:

Service.getA()
    .subscribe(processResponseA())

I was thinking that it would be cool to have a ThrottlingScheduler and/or a MaxConcurrentScheduler that could limit the number of Observables that are active without having to interfere with the data of any of them and without having to make a new thread pool.

static Scheduler serviceLimiter = Schedulers.maxConcurrent(2, Schedulers.computation());

Service.getA()
    .subscribeOn(serviceLimiter)
    .subscribe(processResponseA())

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions