pub async fn create_runtime(
    config: RuntimeConfiguration,
    predefined_envs: Environments,
    deployments: Arc<FaaSDataStore>,
) -> Result<RuntimeConnection> {
    let setup_map = ToolchainMap::new(
        vec![
            (
                ProgrammingLanguage::JavaScript,
                BuildToolchain::Deno(DenoSetup::default()),
            ),
            (
                ProgrammingLanguage::Bash,
                BuildToolchain::Bash(BashSetup::default()),
            ),
            (
                ProgrammingLanguage::Unknown,
                BuildToolchain::Deno(DenoSetup::default()),
            ),
        ],
        vec![
            (
                ProgrammingLanguage::JavaScript,
                Arc::new(ActiveToolchain::Deno(Deno::default())),
            ),
            (
                ProgrammingLanguage::Bash,
                Arc::new(ActiveToolchain::Bash(Bash::default())),
            ),
            (
                ProgrammingLanguage::Unknown,
                Arc::new(ActiveToolchain::Deno(Deno::default())),
            ),
        ],
    );

    let timer_resolution = Duration::milliseconds(config.timer_resolution_ms).to_std()?;

    info!(
        "Found {} executors & {} setups",
        setup_map.len_toolchain_executors(),
        setup_map.len_toolchain_setups()
    );

    let _http = Supervisor::start(HttpTriggered::new).await?;
    let _http2 = _http.clone();
    let _timer = Supervisor::start(move || TimerTriggered::new(timer_resolution)).await?;
    let _timer2 = _timer.clone();
    let log_collector = Arc::new(FileLogCollector::new("logs"));

    let _env_setup = Supervisor::start(move || {
        RuntimeController::new(
            predefined_envs.clone(),
            setup_map.clone(),
            _http2.clone(),
            _timer2.clone(),
            log_collector.clone(),
        )
    })
    .await?;

    info!("Runtime controller successfully started");
    let setup: Vec<Result<_>> = join_all(deployments.values().await.iter().map(|v| {
        _env_setup.call(SetupMsg {
            env_id: v.environment_id,
            toolchain: *v.language(),
        })
    }))
    .await;
    let setup_ok: Vec<_> = setup.iter().filter(|f| f.is_ok()).collect();

    info!(
        "Success setting up {}/{} environments",
        setup_ok.len(),
        setup.len()
    );

    let started: Vec<Result<_>> = join_all(
        deployments
            .values()
            .await
            .iter()
            .map(|v| _env_setup.call(StartExecutorMsg { code: v.clone() })),
    )
    .await;

    let started_ok: Vec<_> = started.iter().filter(|f| f.is_ok()).collect();
    info!(
        "Success starting {}/{} executors",
        started_ok.len(),
        started.len()
    );

    Ok(RuntimeConnection {
        controller_addr: _env_setup,
        http_addr: _http.clone(),
        timer_addr: _timer.clone(),
    })
}
///
/// Creates a runtime based on the configuration and returns a command channel to invoke things with.
///
Creates a runtime based on the configuration and returns a command channel to invoke things with.
Creates a runtime based on the configuration and returns a command channel to invoke things with .
pub async fn create_runtime(
    config: RuntimeConfiguration,
    predefined_envs: Environments,
    deployments: Arc<FaaSDataStore>,
) -> Result<RuntimeConnection> {
    let setup_map = ToolchainMap::new(
        vec![
            (
                ProgrammingLanguage::JavaScript,
                BuildToolchain::Deno(DenoSetup::default()),
            ),
            (
                ProgrammingLanguage::Bash,
                BuildToolchain::Bash(BashSetup::default()),
            ),
            (
                ProgrammingLanguage::Unknown,
                BuildToolchain::Deno(DenoSetup::default()),
            ),
        ],
        vec![
            (
                ProgrammingLanguage::JavaScript,
                Arc::new(ActiveToolchain::Deno(Deno::default())),
            ),
            (
                ProgrammingLanguage::Bash,
                Arc::new(ActiveToolchain::Bash(Bash::default())),
            ),
            (
                ProgrammingLanguage::Unknown,
                Arc::new(ActiveToolchain::Deno(Deno::default())),
            ),
        ],
    );
    let timer_resolution = Duration::milliseconds(config.timer_resolution_ms).to_std()?;
    info!(
        "Found {} executors & {} setups",
        setup_map.len_toolchain_executors(),
        setup_map.len_toolchain_setups()
    );
    let _http = Supervisor::start(HttpTriggered::new).await?;
    let _http2 = _http.clone();
    let _timer = Supervisor::start(move || TimerTriggered::new(timer_resolution)).await?;
    let _timer2 = _timer.clone();
    let log_collector = Arc::new(FileLogCollector::new("logs"));
    let _env_setup = Supervisor::start(move || {
        RuntimeController::new(
            predefined_envs.clone(),
            setup_map.clone(),
            _http2.clone(),
            _timer2.clone(),
            log_collector.clone(),
        )
    })
    .await?;
    info!("Runtime controller successfully started");
    let setup: Vec<Result<_>> = join_all(deployments.values().await.iter().map(|v| {
        _env_setup.call(SetupMsg {
            env_id: v.environment_id,
            toolchain: *v.language(),
        })
    }))
    .await;
    let setup_ok: Vec<_> = setup.iter().filter(|f| f.is_ok()).collect();
    info!(
        "Success setting up {}/{} environments",
        setup_ok.len(),
        setup.len()
    );
    let started: Vec<Result<_>> = join_all(
        deployments
            .values()
            .await
            .iter()
            .map(|v| _env_setup.call(StartExecutorMsg { code: v.clone() })),
    )
    .await;
    let started_ok: Vec<_> = started.iter().filter(|f| f.is_ok()).collect();
    info!(
        "Success starting {}/{} executors",
        started_ok.len(),
        started.len()
    );
    Ok(RuntimeConnection {
        controller_addr: _env_setup,
        http_addr: _http.clone(),
        timer_addr: _timer.clone(),
    })
}
pub async fn create_runtime ( config : RuntimeConfiguration , predefined_envs : Environments , deployments : Arc < FaaSDataStore > , ) -> Result < RuntimeConnection > { let setup_map = ToolchainMap :: new ( vec ! [ ( ProgrammingLanguage JavaScript BuildToolchain Deno ( DenoSetup default ( ) ) ) ( ProgrammingLanguage Bash BuildToolchain Bash ( BashSetup default ( ) ) ) ( ProgrammingLanguage Unknown BuildToolchain Deno ( DenoSetup default ( ) ) ) ] , vec ! [ ( ProgrammingLanguage JavaScript Arc new ( ActiveToolchain Deno ( Deno default ( ) ) ) ) ( ProgrammingLanguage Bash Arc new ( ActiveToolchain Bash ( Bash default ( ) ) ) ) ( ProgrammingLanguage Unknown Arc new ( ActiveToolchain Deno ( Deno default ( ) ) ) ) ] , ) ; let timer_resolution = Duration :: milliseconds ( config . timer_resolution_ms ) . to_std ( ) ? ; info ! ( " " setup_map len_toolchain_executors ( ) setup_map len_toolchain_setups ( ) ) ; let _http = Supervisor :: start ( HttpTriggered :: new ) . await ? ; let _http2 = _http . clone ( ) ; let _timer = Supervisor :: start ( move | | TimerTriggered :: new ( timer_resolution ) ) . await ? ; let _timer2 = _timer . clone ( ) ; let log_collector = Arc :: new ( FileLogCollector :: new ( " " ) ) ; let _env_setup = Supervisor :: start ( move | | { RuntimeController :: new ( predefined_envs . clone ( ) , setup_map . clone ( ) , _http2 . clone ( ) , _timer2 . clone ( ) , log_collector . clone ( ) , ) } ) . await ? ; info ! ( " " ) ; let setup : Vec < Result < _ > > = join_all ( deployments . values ( ) . await . iter ( ) . map ( | v | { _env_setup . call ( SetupMsg { env_id : v . environment_id , toolchain : * v . language ( ) , } ) } ) ) . await ; let setup_ok : Vec < _ > = setup . iter ( ) . filter ( | f | f . is_ok ( ) ) . collect ( ) ; info ! ( " " setup_ok len ( ) setup len ( ) ) ; let started : Vec < Result < _ > > = join_all ( deployments . values ( ) . await . iter ( ) . map ( | v | _env_setup . call ( StartExecutorMsg { code : v . clone ( ) } ) ) , ) . await ; let started_ok : Vec < _ > = started . iter ( ) . filter ( | f | f . is_ok ( ) ) . collect ( ) ; info ! ( " " started_ok len ( ) started len ( ) ) ; Ok ( RuntimeConnection { controller_addr : _env_setup , http_addr : _http . clone ( ) , timer_addr : _timer . clone ( ) , } ) }
Creates a runtime based on the configuration and returns a command channel to invoke things with.
Creates a runtime based on the configuration and returns a command channel to invoke things with .
config
RuntimeConfiguration
predefined_envs
Environments
deployments
Arc<FaaSDataStore>
config
RuntimeConfiguration
predefined_envs
Environments
deployments
Arc<FaaSDataStore>