Skip to content
This repository has been archived by the owner on Feb 1, 2018. It is now read-only.

Add hooks #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add hooks #11

wants to merge 1 commit into from

Conversation

nicoolas25
Copy link

Hey @etiennebarrie,

I have this hook feature, I'm not sure about the name, but I would like some advices about how to test it properly. A lot of things are going on in the test suite and I don't know where to start ;-)

The feature allows us to track the connected users using their cookies.

Bye

@etiennebarrie
Copy link
Contributor

The issue I see with the implementation is that it adds Ruby code on the server. Ideally we could have the redisse server re-written in any language, as long as you use the nginx redirect feature.

Now the on_connect hook looks superfluous as you already have the channels hook where in addition to returning the channels the client should connect, you should be able to run any code you need.

If you don't use the provided binary and define your own server, you can also use a Goliath middleware to hook into the request. That ties you even more to Goliath though, the redirect endpoint is IMO the way forward (if I had thought of it before, there wouldn't be a way to run Ruby code inside the server anymore)

While keeping the redirect endpoint, I think we could also manage to have requests coming from the redisse server to one of the application servers on disconnect, also protected by nginx internal routing.

As for testing, the server implementation is tested in spec/example_spec.rb by testing the example in example/config.ru. If you wanted to test your hooks you would add them to the example config.ru and add tests for expected behaviour in the example spec.

@nicoolas25
Copy link
Author

I see what you mean by having another implementation. I did something very close to Redisse in Go last year (as a toy project) I see you tried that too in another branch.

With the redirect endpoint, do we have a way to customize the behavior of the server? I'm thinking about authentication here and tracking connected users is another of the use cases.

I though of the Goliath middleware too but I wouldn't want to have dependency that deep in the Redisse implementation. Since I need an on_disconnect method, an on_connect method seems more coherent than using channels.

I agree that it is a dangerous thing to run custom Ruby code inside the SSE server. It leads to extra dependencies, unexpected crashes, performances issues, and so on. Anyway, I'm not sure it can have the features I need without having a way to hook into the Redisse code. I'll be happy to have your opinion on this.

Maybe using something like Kong will do the trick...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants