Skip to main content

register_gittorrent

Function register_gittorrent 

Source
pub async fn register_gittorrent(
    manager: &GitManager,
    config: GitTorrentConfig,
) -> Result<Arc<GitTorrentService>>
Expand description

Register gittorrent transport with GitManager

Accepts a GitTorrentConfig which can come from:

  • Git2DBConfig::gittorrent (unified configuration)
  • Custom configuration programmatically created
  • Loaded directly via GitTorrentConfig::load()

Returns the service Arc for advanced usage if needed.

§Example

ⓘ
use git2db::{Git2DBConfig, gittorrent_integration};

// Option 1: Use git2db's unified config
let config = Git2DBConfig::builder()
    .load_env()
    .gittorrent_p2p_port(4001)
    .build()?;

let service = gittorrent_integration::register_gittorrent(
    manager,
    config.gittorrent
).await?;

// Option 2: Load gittorrent config independently
let gittorrent_config = hyprstream_p2p::service::GitTorrentConfig::load()?;
let service = gittorrent_integration::register_gittorrent(
    manager,
    gittorrent_config
).await?;