Comments (7)
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).
- Start with UnixStream
- Implement your codec (
Encoder + Decoder
) for your redis protocol (https://docs.rs/tokio/0.1.13/tokio/codec/index.html). - Call
MyCodec.framed(my_stream)
(https://docs.rs/tokio/0.1.13/tokio/codec/trait.Decoder.html#method.framed), you now have a transport. - 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.
from tower.
What do you hope to do w/ Tower & unix domain sockets? Maybe with more info I could point you in the right direction.
from tower.
@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
from tower.
I think this might be a good case for tokio-tower (which is in progress). Thoughts @jonhoo
from tower.
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?
from tower.
π for full stack docs! :D
from tower.
Tracking documentation with #33.
from tower.
Related Issues (20)
- Adding Service Wrapper that allows to share services for compatibility with Axum route layers HOT 4
- Support weights for request rate limiting HOT 1
- Can I ask one question? HOT 4
- Publish `0.5` release HOT 5
- `Retry<RetryPolicy, RateLimit<Client>>` does not work HOT 7
- Idea: Preventing Inappropriate Service Invocation HOT 1
- Returning a response from a tower layer HOT 2
- AsyncFilterLayer is missing Clone impl
- Have MakeBalance and MakeBalanceLayer example?
- `Reconnect::new()` Generic parameters are redundant HOT 2
- Adding option_layer causes trait bound unsastisfied HOT 1
- Publish release without pin-project (with pin-project-lite) HOT 5
- `tower::service_fn` docs don't say that you need the `util` flag HOT 3
- MQTT client adapter / framework HOT 1
- βFan outβ services? HOT 3
- Consider using `ControlFlow` for retry `Policy`.
- Extending `Building a middleware from scratch` guide
- breaking change in tower design (0.6 or beyond): first class support for async fn traits HOT 20
- unexpected behaviour of `RateLimit`
- experiment with permit based service framework HOT 5
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 tower.