Skip to content

Add Teeracle configuration to CLI #1300

@coax1d

Description

@coax1d

Problem

At the moment when the WORKER_MODE is set to teeracle the service spins up all teeracle services.
Shown here: Teeracle Service

This causes us to always launch, retrieve and submit oracle data for every oracle that we support.

Solution

I propose we add a new cli flag Teeracles which inputs a Vec<TeeracleTypes> into the RunConfig struct shown here: RunConfig in Service

This new argument can look like the following in practice:

./integritee-service run --teeracles teeracle1 teeracle2 teeracle3

Where each teeracle can simply be parsed as a string which can then be mapped to a TeeracleType

pub enum TeeracleType {
    Market,
    Weather
    ..
}

impl FromStr for TeeracleType {
    type Error = () // Some Error type maybe &'static str
    
    fn from_str(s: &str) -> Result<Self, Self::Error> {
        match s {
            "weather" => TeeracleType::Weather,
            // .. etc
        }
    }
}

// Then can do something with the clap::ArgMatches in
impl From<&ArgMatches<'_>> for RunConfig {
	fn from(m: &ArgMatches<'_>) -> Self {
		...
                 let teeracles = m.values_of("teeracles").map(|i| /* TeeracleType::from_str(i).unwrap_or_else(..) */).collect();
		Self { teeracles ..}
	}
}

This also requires editing the cli.yml and adding the teeracles field similar to how the interval is handled here: teeracle-interval cli.yml

subcommands:
    - run:
        about: Start the integritee-service
        args:
            - teeracles:
              required: false
              long: teeracles
              short: t
              help: List of Teeracles to launch Example --teeracles Weather Market SomeOtherOracle
              multiple: true
              takes_value: true
        # .. Other args here

We can then pass the list of teeracles to initiate to start_interval_update function in order to match on each TeeracleType and start the teeracle services accordingly to what we care for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions