chore: adds basic instructions for making an agent

buddies-main-deployment
James Prestwich 4 years ago committed by James Prestwich
parent 76d1b3f8d1
commit 3382a591cc
No known key found for this signature in database
GPG Key ID: 7CC174C250AD83AD
  1. 20
      rust/README.md
  2. 16
      rust/optics-base/src/main.rs

@ -66,3 +66,23 @@ We use the tokio async runtime environment. Please see the docs
- shared configuration file formats
- basic setup for an off-chain agent
- TODO: other agents :)
### High-level guide to building an agent
- `mkdir $AGENT_NAME && cd $AGENT_NAME`
- `cargo init`
- add dependencies to the new `Cargo.toml`
- create a new module in `src/$AGENT_NAME.rs`
- add a new struct
- implement `optics_base::agent::OpticsAgent` for your struct
- your `run` function is the business logic of your agent
- create a new settings module
- reuse the `Settings` objects from `optics_base::settings`
- make sure the read the docs :)
- add your own new settings
- in `$AGENT_NAME/src/main.rs`
- add `mod _____` declarations for your agent and settings modules
- create `main` and `setup` functions
- follow the pattern in `optics-base/src/main.rs`
- make a `config` folder and a toml file
- Make sure to include your own settings from above

@ -34,17 +34,25 @@ where
oa.run_from_settings(&settings).await
}
fn main() -> Result<()> {
/// Read settings from the
fn setup() -> Result<Settings> {
color_eyre::install()?;
let settings = settings::Settings::new().expect("!config");
dbg!(settings);
let settings = Settings::new()?;
// TODO: setup logging based on settings
Ok(settings)
}
fn main() -> Result<()> {
let _settings = setup();
// tokio::runtime::Builder::new_current_thread()
// .enable_all()
// .build()
// .unwrap()
// .block_on(_main(settings))?;
// .block_on(_example_main(settings))?;
Ok(())
}

Loading…
Cancel
Save