3 ms·
I discovered recently that one part of the Pusher javascript library does basically this (using arrays of javascript strings, just as in the article). And this
by SEMW 11y ago
I discovered recently that one part of the Pusher javascript library does basically this (using arrays of javascript strings, just as in the article). And this isn't test code, it's the actual code they use for connection fallback logic. Utterly bizarre.
https://github.com/pusher/pusher-js/blob/2.2/src/defaults.js#L87 https://github.com/pusher/pusher-js/blob/2.2/src/defaults.js...
parser in https://github.com/pusher/pusher-js/blob/2.2/src/strategies/strategy_builder.js https://github.com/pusher/pusher-js/blob/2.2/src/strategies/...
- ludvik 11y agoI wrote that code, there were some reasons why we did it that way. First, before the 2.0 release, we ran several experiments with the connection strategy to figure out the fastest way for the clients to connect to Pusher. We haven't had much experience with HTTP fallbacks, so it was important for us to make the learning process easier. This DSL helped a little bit. The main reason was that we were thinking about helping clients with server-supplied connection strategies. We could gather some metrics and tell the client in advance that, for example, WebSockets won't work due to some network issues. We also thought it could be useful for orchestrating migrations and working around potential load balancing issues. Injecting JavaScript was out of question, so I wrote this JSON DSL for connection strategies. We haven't done that and it's probably never going to happen. The Internet has moved on, we dropped support for some ancient browsers, connectivity has improved and we haven't really felt a need for that feature, to be honest. I agree that at the moment it's unnecessary.
- SEMW 11y agoThanks for the explanation. Interesting to hear the reasoning behind it.