-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change pubsub/ls to return base64url encoded topics
Prior to this change the pubsub/ls endpoint would return the raw topic names when the should be base64url encoded names. Additionally the subscription would remain even after the subscription connection had closed. This is now fixed.
- Loading branch information
1 parent
16a50d8
commit 10b6efc
Showing
6 changed files
with
165 additions
and
13 deletions.
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 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 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 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,57 @@ | ||
use std::{ | ||
pin::Pin, | ||
task::{Context, Poll}, | ||
}; | ||
|
||
use futures_util::{Future, Stream}; | ||
use pin_project::{pin_project, pinned_drop}; | ||
|
||
/// Wraps a stream and on drop spawns a future as its own task. | ||
/// The future is not gauranteed to complete. | ||
#[pin_project(PinnedDrop)] | ||
pub struct StreamDrop<S, D> | ||
where | ||
D: Future<Output = ()> + Send + 'static, | ||
{ | ||
#[pin] | ||
stream: S, | ||
drop_fut: Option<D>, | ||
} | ||
|
||
impl<S, D> StreamDrop<S, D> | ||
where | ||
D: Future<Output = ()> + Send + 'static, | ||
{ | ||
pub fn new(stream: S, drop_fn: D) -> Self { | ||
Self { | ||
stream, | ||
drop_fut: Some(drop_fn), | ||
} | ||
} | ||
} | ||
|
||
impl<S, D> Stream for StreamDrop<S, D> | ||
where | ||
S: Stream, | ||
D: Future<Output = ()> + Send + 'static, | ||
{ | ||
type Item = S::Item; | ||
|
||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | ||
let this = self.project(); | ||
Stream::poll_next(this.stream, cx) | ||
} | ||
} | ||
|
||
#[pinned_drop] | ||
impl<S, D> PinnedDrop for StreamDrop<S, D> | ||
where | ||
D: Future<Output = ()> + Send + 'static, | ||
{ | ||
fn drop(self: Pin<&mut Self>) { | ||
let this = self.project(); | ||
if let Some(drop_fn) = this.drop_fut.take() { | ||
tokio::spawn(drop_fn); | ||
} | ||
} | ||
} |
Oops, something went wrong.