-
Notifications
You must be signed in to change notification settings - Fork 825
refactor: add retry for flight service #16234
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
Closed
Closed
Changes from 15 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
706c744
refactor: allow to encode data with arc
dqhl76 b05ad85
feat: add retry for do_get and do_action
dqhl76 f2e352f
refactor: change to do_exchange with a request-response flow
dqhl76 08136be
debug
dqhl76 76024d4
fixup
dqhl76 07a150a
fixup
dqhl76 4255129
fixup
dqhl76 3fb21c6
fixup
dqhl76 9630604
fixup
dqhl76 cd8d856
don't need cas, already mutex lock
dqhl76 1afe141
try to improve performance by change ack method
dqhl76 bab36ac
change window size
dqhl76 f116033
remove ack
dqhl76 f6ed9d9
Merge branch 'main' into test_remove_flight
dqhl76 fc6ed14
Merge branch 'main' into test_remove_flight
zhang2014 ab5afc2
apply review suggestion
dqhl76 af9a31a
Merge branch 'main' into test_remove_flight
zhang2014 2d56d33
fixup
dqhl76 e37a126
chore: use settings to support switch the feature on client side
dqhl76 2d50a4d
chore: use settings to support switch the feature on server side
dqhl76 f8aa71e
chore: refine to make clippy happy
dqhl76 984a62e
Merge branch 'main' into test_remove_flight
dqhl76 b064790
Merge branch 'main' into test_remove_flight
zhang2014 612e525
Merge branch 'main' into test_remove_flight
zhang2014 237725d
Merge branch 'main' into test_remove_flight
zhang2014 de9c0e4
Merge branch 'main' into test_remove_flight
dqhl76 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2021 Datafuse Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::marker::PhantomData; | ||
use std::sync::Arc; | ||
|
||
use prost::Message; | ||
use tonic::codec::Codec; | ||
use tonic::codec::DecodeBuf; | ||
use tonic::codec::Decoder; | ||
use tonic::codec::EncodeBuf; | ||
use tonic::codec::Encoder; | ||
use tonic::Status; | ||
|
||
#[derive(Default)] | ||
pub struct MessageCodec<E, D>(PhantomData<(E, D)>); | ||
|
||
impl<E: Message + 'static, D: Message + Default + 'static> Codec for MessageCodec<E, D> { | ||
type Encode = Arc<E>; | ||
type Decode = D; | ||
type Encoder = ArcEncoder<E>; | ||
type Decoder = DefaultDecoder<D>; | ||
|
||
fn encoder(&mut self) -> Self::Encoder { | ||
ArcEncoder(PhantomData) | ||
} | ||
|
||
fn decoder(&mut self) -> Self::Decoder { | ||
DefaultDecoder(PhantomData) | ||
} | ||
} | ||
|
||
pub struct ArcEncoder<E>(PhantomData<E>); | ||
|
||
impl<T: Message> Encoder for ArcEncoder<T> { | ||
type Item = Arc<T>; | ||
|
||
type Error = Status; | ||
|
||
fn encode(&mut self, item: Self::Item, dst: &mut EncodeBuf<'_>) -> Result<(), Self::Error> { | ||
item.as_ref() | ||
.encode(dst) | ||
.map_err(|e| Status::internal(e.to_string())) | ||
} | ||
} | ||
|
||
pub struct DefaultDecoder<D>(PhantomData<D>); | ||
|
||
impl<T: Message + Default> Decoder for DefaultDecoder<T> { | ||
type Item = T; | ||
|
||
type Error = Status; | ||
|
||
fn decode(&mut self, buf: &mut DecodeBuf<'_>) -> Result<Option<Self::Item>, Self::Error> { | ||
let item = Message::decode(buf) | ||
.map(Some) | ||
.map_err(|e| Status::internal(e.to_string()))?; | ||
|
||
Ok(item) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.