Comments (8)
I'm not sure we need any specific integration in tarpc
itself, since as @tikue said, we can already plug in our own transport layer. For instance one can create a client that tries to reconnect every second using stubborn-io
:
use std::{iter, time::Duration};
use stubborn_io::{ReconnectOptions, StubbornTcpStream};
use tarpc::{client::Config, serde_transport::Transport};
use tokio::net::ToSocketAddrs;
pub async fn client_connect<A: ToSocketAddrs + Unpin + Clone + Send + Sync + 'static>(
addr: A,
) -> io::Result<Client> {
let reconnect_opts = ReconnectOptions::new()
.with_exit_if_first_connect_fails(false)
.with_retries_generator(|| iter::repeat(Duration::from_secs(1)));
let tcp_stream = StubbornTcpStream::connect_with_options(addr, reconnect_opts).await?;
let transport = Transport::from((tcp_stream, Json::default()));
Client::new(Config::default(), transport).spawn()
}
from tarpc.
The field client::Config.pending_request_buffer
controls how large the Sink
can grow. When it reaches capacity, the response Future will remain in a pending state until there's room to add the request to the outbound request buffer. So it applies backpressure without erroring out the call.
Currently, the client-side timeout that enforces the request deadline is only applied to the response future after the request is successfully buffered. This arguably should change, though, so that a large request backlog will time out further pending requests that haven't yet been buffered.
from tarpc.
Any progress on this? :)
from tarpc.
Nope, I've been pretty busy with work/life the last few months and haven't been actively developing new features. I'd be happy to mentor on this or any other feature request.
from tarpc.
With #199, this can be implemented in the transport layer. However, I think this could also be done at a higher level of abstraction. I'm imagining some kind of load balancer that is represented by a Stream<Item = Transport>
, and the client can automatically manage multiple transports, maybe round-robin style.
from tarpc.
With something like stubborn-io this could mostly be a drop-in replacement for TCP.
from tarpc.
Yes, seems stubborn-io is a good reconnect implementation; are we considering to integrate the two?
from tarpc.
I'm just not sure how this example works in practice. I assume the Sink
gets full at some point and requests will start failing. Will the client be able to recover from that? Also will requests time out?
from tarpc.
Related Issues (20)
- Removing the dependency on tokio HOT 3
- No error details when exceeding of LengthDelimitedCodec's max frame length HOT 6
- use qualified paths for all macro generated signatures HOT 1
- Why is it called tarpc? HOT 2
- How to save transport context? HOT 24
- Multi-client requests HOT 2
- Bidirectional RPC HOT 3
- Cross Platform Procedure Call HOT 2
- [FEATURE REQUEST] Stream responses HOT 4
- QUESTION: how to get tcp server features for custom transport? HOT 1
- Consider making tracing optional HOT 8
- Bubble up server side transport errors to the client HOT 5
- Design problem, how to call other structs method ?
- Server-side span with client’s span as parent HOT 3
- Recommended way for connection pooling? HOT 4
- Support for Async Fn in Trait? HOT 3
- Generic type parameters HOT 4
- On client's read errors quick subsequent requests may wait for response indefinitely HOT 9
- Adding client ID to identify clients (and retrieve specific context)? HOT 2
- Associated data with client
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 tarpc.