Skip to content

How to create IO-based custom executors #84

Open
@HoneyryderChuck

Description

@HoneyryderChuck

Hi, I haven't found any discussion forum about RxRuby, this is more about how to adapt it for my use case, and not an issue with the library itself. Feel free to redirect me to the correct forum if existing, and I'll gladly re-submit this discussion.

I've been looking into #82, and I've seen that it's possible to pass a custom executor through observe_on call (I haven't found documentation about it, however). I have this use case in which I open custom network clients in a batch like scenario, where my current "baby-executor" caps the number of concurrently open connections. This means that further elements of the collection will have to wait for the connection to be open, all callbacks to be run and the connection to be closed, before proceeding with the consumption.

Is there an example of such a Reactive Observable in the wild, or can you provide documentation about it? My concern is that, everytime I call an operation on the collection, my current implementations reopen connections, i.e. I can't seem to keep the connections open until the end of the observable evaluation:

hosts = %w(host1 host2 ...)

collection = MyCustomObservable.new(hosts) # exposes an ssh connection

# I want that both the #select call as the on_next observer callback run 
# within the same network transaction, instead of 
# open/evaluate select/close/open/on_next/close again
collection = collection.select(&:ipindesiredregion)
collection.subscribe(->(conn) { conn.exec!("weird command") } ...

# trigger?
collection.run!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions