-
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] Replicated loglet provider basic wiring
This PR makes some progress in wiring up a real replicated loglet factory. Note that the `ReplicatedLoglet` is a stub and its inputs are not correct yet.
- Loading branch information
1 parent
06e0e04
commit d37408a
Showing
10 changed files
with
202 additions
and
26 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
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,53 @@ | ||
// Copyright (c) 2024-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. | ||
|
||
use std::sync::Arc; | ||
|
||
use restate_core::ShutdownError; | ||
use restate_types::errors::MaybeRetryableError; | ||
use restate_types::logs::metadata::SegmentIndex; | ||
use restate_types::logs::LogId; | ||
|
||
use crate::loglet::OperationError; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub(crate) enum ReplicatedLogletError { | ||
#[error("cannot parse loglet configuration for log_id={0} at segment_index={1}: {2}")] | ||
LogletParamsParsingError(LogId, SegmentIndex, serde_json::Error), | ||
#[error(transparent)] | ||
Shutdown(#[from] ShutdownError), | ||
} | ||
|
||
impl MaybeRetryableError for ReplicatedLogletError { | ||
fn retryable(&self) -> bool { | ||
match self { | ||
Self::LogletParamsParsingError(..) => false, | ||
Self::Shutdown(_) => false, | ||
} | ||
} | ||
} | ||
|
||
impl From<ReplicatedLogletError> for OperationError { | ||
fn from(value: ReplicatedLogletError) -> Self { | ||
match value { | ||
ReplicatedLogletError::Shutdown(e) => OperationError::Shutdown(e), | ||
e => OperationError::Other(Arc::new(e)), | ||
} | ||
} | ||
} | ||
|
||
impl From<ReplicatedLogletError> for crate::Error { | ||
fn from(value: ReplicatedLogletError) -> Self { | ||
match value { | ||
ReplicatedLogletError::Shutdown(e) => crate::Error::Shutdown(e), | ||
e => crate::Error::LogletError(Arc::new(e)), | ||
} | ||
} | ||
} |
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,71 @@ | ||
// 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. | ||
|
||
use std::sync::Arc; | ||
|
||
use async_trait::async_trait; | ||
use futures::stream::BoxStream; | ||
|
||
use restate_core::ShutdownError; | ||
use restate_types::logs::{KeyFilter, LogletOffset, Record, TailState}; | ||
use restate_types::replicated_loglet::ReplicatedLogletParams; | ||
|
||
use crate::loglet::{Loglet, LogletCommit, OperationError, SendableLogletReadStream}; | ||
|
||
#[derive(derive_more::Debug)] | ||
pub(super) struct ReplicatedLoglet { | ||
_my_params: ReplicatedLogletParams, | ||
} | ||
|
||
impl ReplicatedLoglet { | ||
pub fn new(my_params: ReplicatedLogletParams) -> Self { | ||
Self { | ||
_my_params: my_params, | ||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl Loglet for ReplicatedLoglet { | ||
async fn create_read_stream( | ||
self: Arc<Self>, | ||
_filter: KeyFilter, | ||
_from: LogletOffset, | ||
_to: Option<LogletOffset>, | ||
) -> Result<SendableLogletReadStream, OperationError> { | ||
todo!() | ||
} | ||
|
||
fn watch_tail(&self) -> BoxStream<'static, TailState<LogletOffset>> { | ||
todo!() | ||
} | ||
|
||
async fn enqueue_batch(&self, _payloads: Arc<[Record]>) -> Result<LogletCommit, ShutdownError> { | ||
todo!() | ||
} | ||
|
||
async fn find_tail(&self) -> Result<TailState<LogletOffset>, OperationError> { | ||
todo!() | ||
} | ||
|
||
async fn get_trim_point(&self) -> Result<Option<LogletOffset>, OperationError> { | ||
todo!() | ||
} | ||
|
||
/// Trim the log to the minimum of new_trim_point and last_committed_offset | ||
/// new_trim_point is inclusive (will be trimmed) | ||
async fn trim(&self, _new_trim_point: LogletOffset) -> Result<(), OperationError> { | ||
todo!() | ||
} | ||
|
||
async fn seal(&self) -> Result<(), OperationError> { | ||
todo!() | ||
} | ||
} |
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
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