-
-
Notifications
You must be signed in to change notification settings - Fork 60
Add quote streaming #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bguban
wants to merge
3
commits into
dblock:master
Choose a base branch
from
bguban:add_quote_streaming
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add quote streaming #108
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t love that we’re adding another parameter here. We’re modifying the endpoint, not adding another one. Maybe because there’s just one API that goes to a different endpoint, hardcore that in the request and allow me to overwrite it if I want to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to use
endpoint.gsub('://cloud.', '://cloud-sse.')to generate the new endpoint. It allows users to specify the API version in theendpointconfig.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like the least future proof option of all :)
I was thinking that
stream_quotewould do this:This way if that endpoint does change, one can override it in the request without releasing a new version of the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I missed your comment. IEX supports a lot of other streaming endpoints. For example, https://iexcloud.io/docs/api/#cryptocurrency is for streaming crypto. I don't think that it's a good idea to hard code it in every method that will use streaming.
Again, as I understand we have this
endpointconfiguration to give the ability to use a sandbox or specify a specific API version, but if we hard code that then it will require people to set sandbox API in the code instead of the configuration.I checked the sandbox documentation https://iexcloud.io/docs/api/#testing-sandbox and it looks like my current solution will not work with the sandbox env at all. So I think that the first implementation (where we had an extra config option) is the best. It allows us to specify different URLs for different environments, it's straight and simple. And if IEX decides to change the URL (which I doubt very much) then developers will be required just to update their config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dblock so do you want me to hard code the URL or is it still an open discussion? if we are going to hard code then what do you suggest to do with a sandbox URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think you're right. SSE is a thing on its own.
I think we should build SSE support next to the current endpoint implementation rather than attempting to bolt it on top. This means namespacing SSE support under
IEX::Api::StreamingorIEX::Streaming::APIorIEX:SSE::API- no strong preference on which one.SSE would have its own implementation, its own connection/request/etc. Much of it can be shared from the existing implementation, meaning you'll want to extract some base classes and potentially move IEX::Api into
IEX::Web::ApiorIEX::Rest::Api.This is what I think we want to write:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that it's worth the effort:
supercalls with small updates.And honestly say I don't see any benefits from separating the functionality to different namespaces. The only difference in the code is
request.rbfile that requires thisevent parser. So maybe it makes sense to create ansse_request.rbfile that will be responsible for streaming (or just continue using therequest.rb). Or we can try to implement a Faraday middleware that will takeevent parserresponsibility.Probably it makes sense to ask other contributors their opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just think it would make things a lot cleaner and I expect IEX to keep adding endpoints. If you don't feel like doing it, I might pick it up.