mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 21:18:58 +00:00
(docs) Update documentation
This commit is contained in:
parent
4415f52e18
commit
88f49834fd
@ -26,57 +26,40 @@ The inbox implementations as well as the outbox can be constructed via the `Mess
|
||||
|
||||
The MQSM is a finite state machine that is backed by the message queue used to implement an Actor style paradigm.
|
||||
|
||||
The machine itself is defined through a class that extends the 'AbstractActorPrototype'; with state transitions and
|
||||
The machine itself is defined through a class that extends the 'RecordActorPrototype'; with state transitions and
|
||||
names defined as implementations.
|
||||
|
||||
Example:
|
||||
|
||||
```java
|
||||
class ExampleStateMachine extends AbstractActorPrototype {
|
||||
class ExampleStateMachine extends RecordActorPrototype {
|
||||
|
||||
@ActorState(name = "INITIAL", next="GREET")
|
||||
public void initial() {
|
||||
return "World"; // passed to the next state
|
||||
}
|
||||
public record Initial() implements ActorStep {}
|
||||
public record Greet(String message) implements ActorStep {}
|
||||
public record CountDown(int from) implements ActorStep {}
|
||||
|
||||
@ActorState(name = "GREET", next="COUNT-TO-FIVE")
|
||||
public void greet(String name) {
|
||||
System.out.println("Hello " + name);
|
||||
}
|
||||
|
||||
@ActorState(name = "COUNT-TO-FIVE", next="END")
|
||||
public void countToFive(Integer value) {
|
||||
// value is passed from the previous state, since greet didn't pass a value,
|
||||
// null will be the default.
|
||||
|
||||
if (null == value) {
|
||||
// jumps to the current state with a value of 0
|
||||
transition("COUNT-TO-FIVE", 0);
|
||||
}
|
||||
|
||||
|
||||
System.out.println(++value);
|
||||
if (value < 5) {
|
||||
// Loops the current state until value = 5
|
||||
transition("COUNT-TO-FIVE", value);
|
||||
}
|
||||
|
||||
if (value > 5) {
|
||||
// demonstrates an error condition
|
||||
error("Illegal value");
|
||||
}
|
||||
|
||||
// Default transition is to END
|
||||
}
|
||||
|
||||
@ActorState(name="END")
|
||||
public void end() {
|
||||
System.out.println("Done");
|
||||
@Override
|
||||
public ActorStep transition(ActorStep self) {
|
||||
return switch (self) {
|
||||
case Initial i -> new Greet("World");
|
||||
case Greet(String name) -> {
|
||||
System.out.println("Hello " + name + "!");
|
||||
yield new CountDown(5);
|
||||
}
|
||||
case CountDown (int from) -> {
|
||||
if (from > 0) {
|
||||
System.out.println(from);
|
||||
yield new CountDown(from - 1);
|
||||
}
|
||||
yield new End();
|
||||
}
|
||||
default -> new Error();
|
||||
};
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Each method should ideally be idempotent, or at least be able to handle being called multiple times.
|
||||
Each step should ideally be idempotent, or at least be able to handle being called multiple times.
|
||||
It can not be assumed that the states are invoked within the same process, or even on the same machine,
|
||||
on the same day, etc.
|
||||
|
||||
@ -90,6 +73,7 @@ To create an ActorStateMachine from the above class, the following code can be u
|
||||
ActorStateMachine actorStateMachine = new ActorStateMachine(
|
||||
messageQueueFactory,
|
||||
actorInboxName,
|
||||
node,
|
||||
actorInstanceUUID,
|
||||
new ExampleStateMachine());
|
||||
|
||||
|
@ -17,6 +17,7 @@ A map of the most important components and how they relate can be found below.
|
||||
* * [control](services-core/control-service)
|
||||
* * [query](services-core/query-service)
|
||||
* * [index](services-core/index-service)
|
||||
* * [executor](services-core/executor-service)
|
||||
* * [assistant](services-core/assistant-service)
|
||||
* [application services](services-application/) "microservices", stateless providing additional functionality and making an application out of the search engine.
|
||||
* * [api](services-application/api-service) - public API
|
||||
|
12
code/services-core/executor-service/readme.md
Normal file
12
code/services-core/executor-service/readme.md
Normal file
@ -0,0 +1,12 @@
|
||||
The executor service is a partitioned service responsible for executing and keeping
|
||||
track of long running maintenance and operational tasks, such as crawling or data
|
||||
processing.
|
||||
|
||||
It accomplishes this using the [message queue and actor library](../../libraries/message-queue/),
|
||||
which permits program state to survive crashes and reboots. The executor service is closely
|
||||
linked to the [control-service](../control-service), which provides a user interface for
|
||||
much of the executor's functionality.
|
||||
|
||||
## Central Classes
|
||||
|
||||
* [ExecutorActorControlService](src/main/java/nu/marginalia/actor/ExecutorActorControlService.java)
|
@ -1,6 +1,6 @@
|
||||
# Index Service
|
||||
|
||||
The index service knows which document contains which keywords.
|
||||
The index service is a partitioned service that knows which document contains which keywords.
|
||||
|
||||

|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user