-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: rename SpuSocket to StreamSocket (#3958)
* feat: create stream connection via fluvio admin * chore: rename SpuSocket to StreamSocket
- Loading branch information
Showing
7 changed files
with
75 additions
and
67 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "fluvio" | ||
version = "0.21.9" | ||
version = "0.22.0" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
authors = ["Fluvio Contributors <[email protected]>"] | ||
|
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,59 @@ | ||
use std::sync::Arc; | ||
|
||
use fluvio_protocol::api::{Request, RequestMessage}; | ||
use fluvio_socket::{ | ||
AsyncResponse, ClientConfig, SharedMultiplexerSocket, VersionedSerialSocket, Versions, | ||
}; | ||
|
||
use crate::FluvioError; | ||
const DEFAULT_STREAM_QUEUE_SIZE: usize = 10; | ||
|
||
/// Stream Socket | ||
#[derive(Debug)] | ||
pub struct StreamSocket { | ||
config: Arc<ClientConfig>, | ||
socket: SharedMultiplexerSocket, | ||
versions: Versions, | ||
} | ||
|
||
impl StreamSocket { | ||
pub fn new( | ||
config: Arc<ClientConfig>, | ||
socket: SharedMultiplexerSocket, | ||
versions: Versions, | ||
) -> Self { | ||
Self { | ||
config, | ||
socket, | ||
versions, | ||
} | ||
} | ||
|
||
pub async fn create_serial_socket(&mut self) -> VersionedSerialSocket { | ||
VersionedSerialSocket::new( | ||
self.socket.clone(), | ||
self.config.clone(), | ||
self.versions.clone(), | ||
) | ||
} | ||
|
||
pub fn is_stale(&self) -> bool { | ||
self.socket.is_stale() | ||
} | ||
|
||
pub async fn create_stream_with_version<R: Request>( | ||
&mut self, | ||
request: R, | ||
version: i16, | ||
) -> Result<AsyncResponse<R>, FluvioError> { | ||
let mut req_msg = RequestMessage::new_request(request); | ||
req_msg.header.set_api_version(version); | ||
req_msg | ||
.header | ||
.set_client_id(self.config.client_id().to_owned()); | ||
self.socket | ||
.create_stream(req_msg, DEFAULT_STREAM_QUEUE_SIZE) | ||
.await | ||
.map_err(|err| err.into()) | ||
} | ||
} |