huejay icon indicating copy to clipboard operation
huejay copied to clipboard

Add optional queue functionality

Open WeeJeWel opened this issue 7 years ago • 5 comments

Because the Bridges are pretty horrible, and sometimes accept a PUT without actually syncing this to a light (even the official app gets out of sync), it might be useful to add an optional 'queue timeout' parameter to client.lights.save. I'd say something like this:

client.lights.save( light, {
    queueTimeout: 1500 // wait 1500ms after each request
})

Any thoughts?

WeeJeWel avatar Oct 27 '16 16:10 WeeJeWel

I think this is a good idea, but your example wouldn't work out so well if there are several calls with different "queueTimeout" values. This also doesn't solve performance issues when numerous apps are hitting the bridge.

If I were to implement this, a setting on the client would be a better option. A queue timeout as well as a setting for number of in-flight requests could work. All reads/writes from the client would respect these values.

sqmk avatar Oct 27 '16 17:10 sqmk

That's a much better solution indeed. Shouldn't be too hard I guess :-)

WeeJeWel avatar Oct 27 '16 17:10 WeeJeWel

@sqmk Do you have any plans on supporting this? If so, when? (I'd love to do it but am not comfortable enough with Promises yet)

WeeJeWel avatar Jan 31 '17 19:01 WeeJeWel

This is still something I'm interested in. I may include this in Huejay 2.0.0, which would be a node 8+ release now that promises are much nicer to deal with via async/await.

sqmk avatar Feb 12 '18 16:02 sqmk

That would be amazing!

WeeJeWel avatar Feb 12 '18 16:02 WeeJeWel