-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bifrost] More Replicated Loglet Scaffolding (#1986)
This introduces a few more bits that happen during loglet instantiation.
- Loading branch information
1 parent
d9407b9
commit cc40ed9
Showing
7 changed files
with
242 additions
and
17 deletions.
There are no files selected for viewing
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,65 @@ | ||
// Copyright (c) 2024 - Restate Software, Inc., Restate GmbH. | ||
// All rights reserved. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the LICENSE file. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0. | ||
|
||
// todo(asoli): remove when fleshed out | ||
#![allow(dead_code)] | ||
|
||
use std::pin::Pin; | ||
use std::sync::Arc; | ||
|
||
use futures::Stream; | ||
|
||
use restate_core::network::{Incoming, MessageRouterBuilder, TransportConnect}; | ||
use restate_core::{cancellation_watcher, Metadata}; | ||
use restate_types::config::ReplicatedLogletOptions; | ||
use restate_types::net::replicated_loglet::Append; | ||
use tracing::trace; | ||
|
||
use super::provider::ReplicatedLogletProvider; | ||
|
||
type MessageStream<T> = Pin<Box<dyn Stream<Item = Incoming<T>> + Send + Sync + 'static>>; | ||
|
||
pub struct RequestPump { | ||
metadata: Metadata, | ||
append_stream: MessageStream<Append>, | ||
} | ||
|
||
impl RequestPump { | ||
pub fn new( | ||
_opts: &ReplicatedLogletOptions, | ||
metadata: Metadata, | ||
router_builder: &mut MessageRouterBuilder, | ||
) -> Self { | ||
// todo(asoli) read from opts | ||
let queue_length = 10; | ||
let append_stream = router_builder.subscribe_to_stream(queue_length); | ||
Self { | ||
metadata, | ||
append_stream, | ||
} | ||
} | ||
|
||
/// Must run in task-center context | ||
pub async fn run<T: TransportConnect>( | ||
self, | ||
_provider: Arc<ReplicatedLogletProvider<T>>, | ||
) -> anyhow::Result<()> { | ||
trace!("Starting replicated loglet request pump"); | ||
let mut cancel = std::pin::pin!(cancellation_watcher()); | ||
loop { | ||
tokio::select! { | ||
_ = &mut cancel => { | ||
break; | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
crates/bifrost/src/providers/replicated_loglet/record_cache.rs
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,25 @@ | ||
// Copyright (c) 2024 - Restate Software, Inc., Restate GmbH. | ||
// All rights reserved. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the LICENSE file. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0. | ||
|
||
/// A placeholder for a global record cache. | ||
/// | ||
/// This can be safely shared between all ReplicatedLoglet(s) and the LocalSequencers or the | ||
/// RemoteSequencers | ||
/// | ||
/// | ||
/// This is a streaming LRU-cache with total memory budget tracking and enforcement. | ||
#[derive(Clone, Debug)] | ||
pub struct RecordCache {} | ||
|
||
impl RecordCache { | ||
pub fn new(_memory_budget_bytes: usize) -> Self { | ||
Self {} | ||
} | ||
} |
Oops, something went wrong.