Skip to content
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

Question: Support for Unix Domain Socket and example #126

Closed
rohitjoshi opened this issue Nov 23, 2018 · 7 comments
Closed

Question: Support for Unix Domain Socket and example #126

rohitjoshi opened this issue Nov 23, 2018 · 7 comments

Comments

@rohitjoshi
Copy link

Do we have an example of Unix domain socket support?

@carllerche
Copy link
Member

What do you hope to do w/ Tower & unix domain sockets? Maybe with more info I could point you in the right direction.

@rohitjoshi
Copy link
Author

@callerche planning to implement Redis protocol interface which internally connects to remove DB.

I did implement using ‘mio’ and wanted to leverage many towers modules like rate limit, reconnect, bufffer etc

@carllerche
Copy link
Member

I think this might be a good case for tokio-tower (which is in progress). Thoughts @jonhoo

@jonhoo
Copy link
Collaborator

jonhoo commented Nov 28, 2018

As long as you have an AsyncRead and AsyncWrite (which Unix domain sockets are iirc), you should be able to turn that into Stream + Sink with a tokio::codec (or by writing your own if you're so inclined). Once you have that, you can indeed use tokio-tower to move from Stream + Sink to Service :)

@carllerche maybe we should publish tokio-tower 0.0.1 so that we get docs up on docs.rs?

@carllerche
Copy link
Member

The short answer is, Tower is decoupled from UDS or TCP.

You would implement Service for Redis, which is request / response based. Once you have that, you can take advantage of all the middleware provided here.

The easiest way to do that, as mentioned, would be tokio-tower. With tokio-tower, you provide a "transport" which is a type that implements Stream + Sink.

And the easiest way to get a transport, is to use a codec :)

(we really should have full stack docs for this).

  1. Start with UnixStream
  2. Implement your codec (Encoder + Decoder) for your redis protocol (https://docs.rs/tokio/0.1.13/tokio/codec/index.html).
  3. Call MyCodec.framed(my_stream) (https://docs.rs/tokio/0.1.13/tokio/codec/trait.Decoder.html#method.framed), you now have a transport.
  4. Pass your transport to tokio-tower (not released yet, but we will do that asap).

At that point, you have your Service handle for the redis protocol. Then, you can use all the middleware.

@jonhoo
Copy link
Collaborator

jonhoo commented Nov 28, 2018

👍 for full stack docs! :D

@carllerche carllerche mentioned this issue Apr 4, 2019
8 tasks
@carllerche
Copy link
Member

Tracking documentation with #33.

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

No branches or pull requests

3 participants