Comments (3)
I'm interested in mostly the EventSourceClient part of this library. Why does the constructor build its own url from ssl, url, action, and target parameters, instead of a single url parameter? An SSE server can respond at any location, and it isn't clear what that URL should be.
well, I might have implemented the client in a too specialised way. Basically, the URL that's gonna be polled is built based on those parameters:
self._url = "%s://%s/%s/%s" % ("https" if ssl else "http", url, action, target)
so typically, action is poll
per default, and target is the token
, so that would be:
https://host.tld/poll/42:42:42:42:42:42
The callback being what you'd want to do with that URL. Per default, it's just logging the events being pushed by the server.
So a good idea would be to make EventSourceClient
only caring about the idea of an URL, and create a function that would take all the URL parameters I designed and build the URL, so that building the singleton would look like:
EventSourceClient(
url = build_token_action_url(
base_url = url,
action = args.action,
target = args.token
),
retry = args.retry,
keep_alive = args.keep_alive,
ssl = args.ssl,
validate_cert = args.validate_cert,
user = args.user,
password = args.password).poll()
then for your own needs, you'd only have to feed it the URL, and manufacture your callback
function to pass to the constructor.
Would you mind if I forked your EventSourceClient code into a new repository (with credit and link back here), and updated it to be more generic and python 3 compatible?
Thank you for asking, but not only I wouldn't, but this code is GPL, so you're free to do so ☺
But I'd rather have you fork it, and make a PR to improve that code!
Though, I consider that library to have some tech debt due to its age (I mean it's four years old and I haven't been personally using it for over three years).
If I were to rewrite it today, I'd totally drop py2 and tornado support, and and write it towards asyncio and requests.
And I'd also write some pytest unit tests ☺
N.B.: I'm planning on coming to the FOSDEM, so maybe we could take half a day to pair code on this, if you're coming as well.
N.B.2: I'm zmo on freenode, feel free to PRIVMSG me!
from event-source-library.
Thanks for the response!
Actually, along the way I found https://github.com/btubbs/sseclient, which works pretty well for my purposes. Alas, I won't be at FOSDEM. I'm ottomata on freenode. :)
from event-source-library.
oh, cool, did not know.
Though I'd be happy to upgrade that lib and make it cool again ☺
Also it's (was?) the only lib to provide both server and client implementation 😉
from event-source-library.
Related Issues (14)
- 'token' and 'action' parameters HOT 1
- Issue with 'libcurl' while running client side code HOT 1
- traceback is not imported in listener.py HOT 2
- "import json" used instead of "from tornado.escape import json_encode, json_decode" HOT 2
- listener.py:EventSourceHandler:_event_loop() performance issue HOT 6
- removal of buffer_events()
- Support of Tornado >3 HOT 10
- Max number of connections HOT 2
- update documentation HOT 6
- confusing error on port mismatch HOT 3
- wildcard events HOT 2
- integration clarification HOT 7
- doubled events HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from event-source-library.