Renamed plugins to strategies
This commit is contained in:
@@ -47,7 +47,7 @@ impl Engine {
|
||||
set_cfg!(id, {
|
||||
let id: String = id;
|
||||
|
||||
if !crate::store::pulse_plugin(&id)?
|
||||
if !crate::store::pulse_strategy(&id)?
|
||||
.join("strategy.toml")
|
||||
.exists()
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ use tokio::{
|
||||
|
||||
use crate::{
|
||||
engine::Engine,
|
||||
store::{strategy::StrategyChild, pulse_plugin},
|
||||
store::{pulse_strategy, strategy::StrategyChild},
|
||||
};
|
||||
|
||||
pub struct StrategyEngine {
|
||||
@@ -28,9 +28,9 @@ pub struct StrategyEngine {
|
||||
|
||||
impl StrategyEngine {
|
||||
pub async fn new(strategy_id: &str) -> tokio::io::Result<Self> {
|
||||
let strategy = pulse_plugin(strategy_id)?;
|
||||
let strategy = pulse_strategy(strategy_id)?;
|
||||
|
||||
let (strategy, strategy_manifest) = get_manifest_plugin_pair(
|
||||
let (strategy, strategy_manifest) = get_manifest(
|
||||
&strategy,
|
||||
&strategy.join("strategy.bash"),
|
||||
&fs::read(strategy.join("strategy.toml")).await?,
|
||||
@@ -168,12 +168,12 @@ impl StrategyEngine {
|
||||
}
|
||||
|
||||
pub async fn reload_strategy(self: &Arc<Self>, id: &str) -> tokio::io::Result<()> {
|
||||
let plugin = pulse_plugin(id)?;
|
||||
let strategy = pulse_strategy(id)?;
|
||||
|
||||
let (child, manifest) = get_manifest_plugin_pair(
|
||||
&plugin,
|
||||
&plugin.join("strategy.bash"),
|
||||
&fs::read(plugin.join("strategy.toml")).await?,
|
||||
let (child, manifest) = get_manifest(
|
||||
&strategy,
|
||||
&strategy.join("strategy.bash"),
|
||||
&fs::read(strategy.join("strategy.toml")).await?,
|
||||
)?;
|
||||
|
||||
self.strategy.reload(child, manifest).await?;
|
||||
@@ -185,15 +185,15 @@ impl StrategyEngine {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_manifest_plugin_pair<'de, M: serde::Deserialize<'de>>(
|
||||
plugin_dir: &PathBuf,
|
||||
plugin_path: &PathBuf,
|
||||
fn get_manifest<'de, M: serde::Deserialize<'de>>(
|
||||
strategy_dir: &PathBuf,
|
||||
strategy_path: &PathBuf,
|
||||
manifest: &'de [u8],
|
||||
) -> tokio::io::Result<(Child, M)> {
|
||||
Ok((
|
||||
Command::new("bash")
|
||||
.arg(plugin_path)
|
||||
.current_dir(plugin_dir)
|
||||
.arg(strategy_path)
|
||||
.current_dir(strategy_dir)
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::inherit())
|
||||
|
||||
@@ -14,12 +14,12 @@ pub fn pulse_directory() -> tokio::io::Result<PathBuf> {
|
||||
Ok(home_dir()?.join(".config").join("pulse-trader"))
|
||||
}
|
||||
|
||||
pub fn pulse_plugins_directory() -> tokio::io::Result<PathBuf> {
|
||||
Ok(pulse_directory()?.join("plugins"))
|
||||
pub fn pulse_strategies_directory() -> tokio::io::Result<PathBuf> {
|
||||
Ok(pulse_directory()?.join("strategies"))
|
||||
}
|
||||
|
||||
pub fn pulse_plugin(id: &str) -> tokio::io::Result<PathBuf> {
|
||||
Ok(pulse_directory()?.join("plugins").join(id))
|
||||
pub fn pulse_strategy(id: &str) -> tokio::io::Result<PathBuf> {
|
||||
Ok(pulse_directory()?.join("strategies").join(id))
|
||||
}
|
||||
|
||||
pub fn pulse_config_file() -> tokio::io::Result<PathBuf> {
|
||||
|
||||
Reference in New Issue
Block a user