StorageEngine

Struct StorageEngine 

Source
pub struct StorageEngine { /* private fields */ }
Expand description

ストレージエンジンのメインエントリポイント

§Example

use kawa_storage::{StorageEngine, StorageConfig};
 
#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let config = StorageConfig::default();
    let storage = StorageEngine::new(config).await?;
     
    // @todo イベント書き込み・読み取りのサンプル実装
    Ok(())
}

Implementations§

Source§

impl StorageEngine

Source

pub async fn new(config: StorageConfig) -> StorageResult<Self>

新しいストレージエンジンを作成

§Arguments
  • config - ストレージ設定
§Returns
  • Result<Self> - ストレージエンジンインスタンス
§@todo
  • データディレクトリの自動作成
  • 既存データの復旧処理
  • メトリクス収集の初期化
Source

pub async fn append_event( &self, topic: &Topic, partition: Partition, event_data: EventData, ) -> StorageResult<(EventId, Offset)>

イベントを永続化

§Arguments
  • topic - トピック名
  • partition - パーティション番号
  • event_data - イベントデータ
§Returns
  • Result<(EventId, Offset)> - イベントIDとオフセット
§@todo
  • バッチ書き込みのサポート
  • 圧縮機能の実装
  • レプリケーション対応
Source

pub async fn read_events( &self, topic: &Topic, partition: Partition, start_offset: Offset, max_events: usize, ) -> StorageResult<Vec<Event>>

指定したオフセット範囲のイベントを読み取り

§Arguments
  • topic - トピック名
  • partition - パーティション番号
  • start_offset - 開始オフセット
  • max_events - 最大イベント数
§Returns
  • Result<Vec<Event>> - イベントリスト
§@todo
  • ストリーミング読み取り
  • インデックスベース高速検索
  • 非同期イテレータの実装
Source

pub async fn get_latest_offset( &self, topic: &Topic, partition: Partition, ) -> StorageResult<Option<Offset>>

最新のオフセットを取得

§Arguments
  • topic - トピック名
  • partition - パーティション番号
§Returns
  • Result<Option<Offset>> - 最新オフセット(データがない場合はNone)
Source

pub async fn append_events_batch( &self, events: Vec<(Topic, Partition, EventData)>, ) -> StorageResult<Vec<(EventId, Offset)>>

バッチでイベントを永続化(高性能版)

§Arguments
  • events - イベントのバッチ
§Returns
  • Result<Vec<(EventId, Offset)>> - イベントIDとオフセットのリスト
§Performance

1M+ events/secを達成するための最適化バッチ処理

Source

pub fn memory_pool_stats(&self) -> PoolStats

メモリプール統計を取得

Source

pub async fn shutdown(&self) -> StorageResult<()>

ストレージエンジンを優雅にシャットダウン

§@todo
  • 未書き込みデータのフラッシュ
  • メトリクスの最終出力
  • リソースクリーンアップ

Trait Implementations§

Source§

impl Debug for StorageEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more