-
Notifications
You must be signed in to change notification settings - Fork 0
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
Ed/29 may 17 #12
Merged
Merged
Ed/29 may 17 #12
Conversation
This file contains 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
I'm using phoenix 1.3-rc2 for this
`cd assets && npm install elm elm-brunch --save`
Hooks Elm into brunch I've chosen to keep my .elm files in assets/elm/src, and compile to assets/vendor. Often people keep their .elm files in web/elm, but I feel that dir is for Elixir really. Toyed with compiling Elm to priv/static as we do with other js, but couldn't get that working.
This hooks up a basic model, update and view for a search field. Currently this just render the input text into a p tag, as a proof of concept.
This adds some basic plumbing for the websocket connection.
This joins the websocket on `init`, sends to it when typing, and renders recieved body to the screen. Currently we're basicall just echoing. Likely could clean this some with some more advanced types.
This adds a rough skeleton for GenStage to be used with our typeahead search function. This is currently split into 3 stages: \### `QueryProducer` `QueryProducer` is unusual for a producer, as the state it holds is just 1 word, not many. This is because I only care about the most recent version of whatever has been input by the user, and so only store this. Unsure how this will behave with latency atm. \### `QueryProducerConsumer` `QueryProducerConsumer` takes care of grabbing the state from the producer, at a configurable rate. I've taken this implementation from an example in the Elixir docs, and think it might be more complex than I need. \### `QueryConsumer` This simply prints the latest event to the screen.
This updates the GenStage implementation to be aware of sockets, meaning we can update the producer for a given channel, and push from the consumer to the channel it knows about. This is good in that it means we could have more than one user on this at once, and they'd only see their own messages. However, the rate limit will now be exceeded if the limit is per-application, rather than per-socket, which seems likely.
Rough working implementation rendering users found based on query 🤠
This slipped through my net. Token revoked
This is quite a large refactor, but should make things work better going forwards. Should be functional at this commit, but RateLimiter needs updating to send demand every second.
This switches to using the internal buffers in `Query`. This handles buffering somewhat better than my manual implementation, as for instance: * if we receive events but have not enough demand, we enqueue them. We set this buffer size to 1, so that we never enqueue more than 1 event, which makes sense for our purposes (no point rendering stale search results). * if receive demand but no events, the next events to come through are dispatched immediately, and so the search can happen straight away instead of at the next demand. This is much better than what we had before. The main issue I see with it is that as far as I can see there is no way to set the max pending demand buffer, so this would seem to be unbounded. I'd rather limit this to say 100 (could likely handle this somehow in the producer_consumer.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://www.dropbox.com/s/rvyc1vmurfnykn1/githubprofiler480.mov?dl=0
My solution here is kind of involved, so hear me out:
The TLDR is:
The flow of data through the app looks roughly like so:
max_demand
andinterval
. We use this to make sure we only ask for the query once per second.Perhaps I cheated with the rendering of the user, but all the info you wanted is displayed in the typeahead anyway ;)
Good luck finding a cooler stack than this in the near future: