53: Create Nenjim Process Manager and some dummy services
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
package com.fanitas.evelyn.core;
|
package com.fanitas.evelyn.core;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface Evelyn {
|
public interface Evelyn {
|
||||||
void executeService() throws Exception;
|
void executeService() throws Exception;
|
||||||
|
|
||||||
|
@NotNull String getStatusReport();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.r35157.libs.solana.SolanaConstants;
|
|||||||
import com.r35157.libs.valuetypes.basic.AssetPrice;
|
import com.r35157.libs.valuetypes.basic.AssetPrice;
|
||||||
import com.r35157.libs.valuetypes.basic.MoneyAmount;
|
import com.r35157.libs.valuetypes.basic.MoneyAmount;
|
||||||
import com.r35157.libs.valuetypes.basic.TradingPair;
|
import com.r35157.libs.valuetypes.basic.TradingPair;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -27,7 +28,7 @@ import static com.r35157.libs.solana.valuetypes.economic.SolanaSPLTokenProgram.T
|
|||||||
|
|
||||||
public class EvelynImpl implements Evelyn {
|
public class EvelynImpl implements Evelyn {
|
||||||
|
|
||||||
public EvelynImpl(
|
/*public EvelynImpl(
|
||||||
State state,
|
State state,
|
||||||
DesiredPositionCalculator desiredPositionCalculator,
|
DesiredPositionCalculator desiredPositionCalculator,
|
||||||
Raydium raydium,
|
Raydium raydium,
|
||||||
@@ -37,13 +38,21 @@ public class EvelynImpl implements Evelyn {
|
|||||||
this.desiredPositionCalculator = desiredPositionCalculator;
|
this.desiredPositionCalculator = desiredPositionCalculator;
|
||||||
this.raydium = raydium;
|
this.raydium = raydium;
|
||||||
this.solanaChain = solanaChain;
|
this.solanaChain = solanaChain;
|
||||||
|
}*/
|
||||||
|
public EvelynImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeService() throws Exception {
|
public void executeService() throws Exception {
|
||||||
handleRebalancingProposal();
|
//handleRebalancingProposal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getStatusReport() {
|
||||||
|
return "Hello World!";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private SPLTokenHolding getSPLHolding(ΩSolanaAddressΩ ownerAddress, ΩSPLMintAddressΩ splMintAddress) throws Exception {
|
private SPLTokenHolding getSPLHolding(ΩSolanaAddressΩ ownerAddress, ΩSPLMintAddressΩ splMintAddress) throws Exception {
|
||||||
Map<ΩSPLMintAddressΩ, SPLTokenHolding> holdings = new HashMap<>();
|
Map<ΩSPLMintAddressΩ, SPLTokenHolding> holdings = new HashMap<>();
|
||||||
|
|
||||||
@@ -263,4 +272,5 @@ public class EvelynImpl implements Evelyn {
|
|||||||
private final DesiredPositionCalculator desiredPositionCalculator;
|
private final DesiredPositionCalculator desiredPositionCalculator;
|
||||||
private final Raydium raydium;
|
private final Raydium raydium;
|
||||||
private final SolanaBlockChain solanaChain;
|
private final SolanaBlockChain solanaChain;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
package com.fanitas.evelyn.core.impl.ref;
|
|
||||||
|
|
||||||
import com.fanitas.evelyn.core.Evelyn;
|
|
||||||
import com.fanitas.evelyn.core.DesiredPositionCalculator;
|
|
||||||
import com.fanitas.evelyn.core.State;
|
|
||||||
import com.r35157.libs.raydium.*;
|
|
||||||
import com.r35157.libs.raydium.impl.ref.RaydiumImpl;
|
|
||||||
import com.r35157.libs.solana.SPLTokenHolding;
|
|
||||||
import com.r35157.libs.solana.SPLTokenSupply;
|
|
||||||
import com.r35157.libs.solana.SolanaAccountInfo;
|
|
||||||
import com.r35157.libs.solana.SolanaBlockChain;
|
|
||||||
import com.r35157.libs.solana.impl.ref.SolanaBlockChainImpl;
|
|
||||||
import com.r35157.libs.solana.valuetypes.SolanaProgramDerivedAddress;
|
|
||||||
import com.r35157.libs.solana.valuetypes.economic.SolanaSPLTokenProgram;
|
|
||||||
import com.r35157.libs.valuetypes.basic.Range;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.MathContext;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
static void main() throws Exception {
|
|
||||||
log.info("Initializing Evelyn...");
|
|
||||||
SolanaBlockChain solanaChain = new SolanaBlockChainImpl();
|
|
||||||
Raydium raydium = new RaydiumImpl(solanaChain);
|
|
||||||
System.out.println(" Done.");
|
|
||||||
|
|
||||||
State state = new StateImpl(raydium);
|
|
||||||
DesiredPositionCalculator desiredPositionCalculator = new DesiredPositionCalculatorImpl(
|
|
||||||
state.getCurveWidth(),
|
|
||||||
state.getLiquidityPositions()
|
|
||||||
);
|
|
||||||
|
|
||||||
Evelyn evelyn = new EvelynImpl(
|
|
||||||
state,
|
|
||||||
desiredPositionCalculator,
|
|
||||||
raydium,
|
|
||||||
solanaChain
|
|
||||||
);
|
|
||||||
|
|
||||||
evelyn.executeService();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(Main.class);
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
package com.r35157.evelyn.emc.impl.ref;
|
package com.r35157.evelyn.emc.impl.ref;
|
||||||
|
|
||||||
import com.r35157.evelyn.emc.EvelynMissionControl;
|
import com.r35157.evelyn.emc.EvelynMissionControl;
|
||||||
import javafx.application.Platform;
|
import com.r35157.libs.javafx.JavaFxRuntime;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public final class EvelynMissionControlImpl/*<T>*/ implements EvelynMissionControl {
|
public final class EvelynMissionControlImpl/*<T>*/ implements EvelynMissionControl {
|
||||||
|
|
||||||
public EvelynMissionControlImpl(/*T evelyn*/) {
|
public EvelynMissionControlImpl(/*T evelyn*/) {
|
||||||
@@ -16,20 +14,22 @@ public final class EvelynMissionControlImpl/*<T>*/ implements EvelynMissionContr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
Platform.startup(() -> {
|
JavaFxRuntime.runLater(this::showWindow);
|
||||||
TextArea text = new TextArea("""
|
}
|
||||||
Evelyn Mission Control
|
|
||||||
|
|
||||||
Evelyn is running.
|
private void showWindow() {
|
||||||
Connected to: %s
|
TextArea text = new TextArea("""
|
||||||
""".formatted("Test123"/*evelyn.getClass().getName())*/));
|
Evelyn Mission Control
|
||||||
text.setEditable(false);
|
|
||||||
|
|
||||||
Stage window = new Stage();
|
Evelyn is running.
|
||||||
window.setTitle("Evelyn Mission Control");
|
Connected to: %s
|
||||||
window.setScene(new Scene(text, 600, 400));
|
""".formatted("Test123"/*evelyn.getClass().getName())*/));
|
||||||
window.show();
|
text.setEditable(false);
|
||||||
});
|
|
||||||
|
Stage window = new Stage();
|
||||||
|
window.setTitle("Evelyn Mission Control");
|
||||||
|
window.setScene(new Scene(text, 600, 400));
|
||||||
|
window.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
//private final T evelyn;
|
//private final T evelyn;
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.r35157.libs.javafx;
|
||||||
|
|
||||||
|
import javafx.application.Platform;
|
||||||
|
|
||||||
|
public final class JavaFxRuntime {
|
||||||
|
|
||||||
|
public static void runLater(Runnable runnable) {
|
||||||
|
initialize();
|
||||||
|
Platform.runLater(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static synchronized void initialize() {
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform.startup(() -> Platform.setImplicitExit(false));
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JavaFxRuntime() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean initialized;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.r35157.nenjim.composer;
|
||||||
|
|
||||||
|
public interface NenjimComposer {
|
||||||
|
void start();
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.r35157.nenjim.composer.impl.ref;
|
||||||
|
|
||||||
|
import com.r35157.libs.javafx.JavaFxRuntime;
|
||||||
|
import com.r35157.nenjim.composer.NenjimComposer;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public final class NenjimComposerImpl implements NenjimComposer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
JavaFxRuntime.runLater(this::showWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showWindow() {
|
||||||
|
|
||||||
|
var window = new Stage();
|
||||||
|
window.setTitle("Nenjim Composer");
|
||||||
|
window.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,12 @@ package com.r35157.nenjim.hubd.impl.ref;
|
|||||||
import com.r35157.evelyn.emc.EvelynMissionControl;
|
import com.r35157.evelyn.emc.EvelynMissionControl;
|
||||||
import com.r35157.evelyn.emc.impl.ref.EvelynMissionControlImpl;
|
import com.r35157.evelyn.emc.impl.ref.EvelynMissionControlImpl;
|
||||||
import com.r35157.jupiterperpsalarm.impl.ref.JupiterPerpsAlarmImpl;
|
import com.r35157.jupiterperpsalarm.impl.ref.JupiterPerpsAlarmImpl;
|
||||||
|
import com.r35157.nenjim.composer.NenjimComposer;
|
||||||
|
import com.r35157.nenjim.composer.impl.ref.NenjimComposerImpl;
|
||||||
import com.r35157.nenjim.hubd.NenjimHub;
|
import com.r35157.nenjim.hubd.NenjimHub;
|
||||||
import com.r35157.nenjim.hubd.journal.Journal;
|
import com.r35157.nenjim.hubd.journal.Journal;
|
||||||
|
import com.r35157.nenjim.npm.NenjimProcessManager;
|
||||||
|
import com.r35157.nenjim.npm.impl.ref.NenjimProcessManagerImpl;
|
||||||
import crypto.r35157.nenjim.NenjimProcess;
|
import crypto.r35157.nenjim.NenjimProcess;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -48,6 +52,8 @@ public class NenjimHubImpl implements NenjimHub {
|
|||||||
private void startAutoRunProcesses() throws Exception {
|
private void startAutoRunProcesses() throws Exception {
|
||||||
startJupiterPerpsAlarm(); // TODO: Hardcoded/hacky way to auto-start but good enough for now.
|
startJupiterPerpsAlarm(); // TODO: Hardcoded/hacky way to auto-start but good enough for now.
|
||||||
startEvelynMissionControl();
|
startEvelynMissionControl();
|
||||||
|
startNenjimComposer();
|
||||||
|
startNenjimProcessManager();
|
||||||
|
|
||||||
// TODO: Old but more correct way to auto start plugins - but it is currently broken.
|
// TODO: Old but more correct way to auto start plugins - but it is currently broken.
|
||||||
/*
|
/*
|
||||||
@@ -138,6 +144,36 @@ public class NenjimHubImpl implements NenjimHub {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startNenjimComposer() {
|
||||||
|
Thread thread = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
NenjimComposer nc = new NenjimComposerImpl();
|
||||||
|
nc.start();
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
}, "Nenjim Plugin - Nenjim Composer");
|
||||||
|
|
||||||
|
thread.setDaemon(false);
|
||||||
|
thread.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startNenjimProcessManager() {
|
||||||
|
Thread thread = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
NenjimProcessManager npm = new NenjimProcessManagerImpl();
|
||||||
|
npm.start();
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
}, "Nenjim Plugin - Nenjim Process Manager");
|
||||||
|
|
||||||
|
thread.setDaemon(false);
|
||||||
|
thread.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(NenjimHubImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(NenjimHubImpl.class);
|
||||||
private final CountDownLatch shutdownLatch = new CountDownLatch(1);
|
private final CountDownLatch shutdownLatch = new CountDownLatch(1);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.r35157.nenjim.npm;
|
||||||
|
|
||||||
|
public interface NenjimProcessManager {
|
||||||
|
void start();
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.r35157.nenjim.npm.impl.ref;
|
||||||
|
|
||||||
|
import com.r35157.libs.javafx.JavaFxRuntime;
|
||||||
|
import com.r35157.nenjim.npm.NenjimProcessManager;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.ListView;
|
||||||
|
import javafx.scene.control.SelectionMode;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public final class NenjimProcessManagerImpl implements NenjimProcessManager {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
JavaFxRuntime.runLater(this::showWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showWindow() {
|
||||||
|
var processes = new ListView<String>();
|
||||||
|
processes.getItems().addAll(
|
||||||
|
"Nenjim Composer",
|
||||||
|
"Nenjim Process Manager (this)",
|
||||||
|
"Evelyn Mission Control"
|
||||||
|
);
|
||||||
|
processes.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||||
|
|
||||||
|
var window = new Stage();
|
||||||
|
window.setTitle("Nenjim Process Manager");
|
||||||
|
window.setScene(new Scene(processes, 500, 400));
|
||||||
|
window.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user