MCPcopy Create free account
hub / github.com/Pluralith/pluralith-cli / ProcessEvents

Function ProcessEvents

app/pkg/comdb/WatchComDB.go:13–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11)
12
13func ProcessEvents() (string, error) {
14 functionName := "ProcessEvents"
15
16 var comDB ComDB
17 // Read comDB from file
18 if readErr := ReadComFile(auxiliary.StateInstance.ComDBPath, &comDB); readErr != nil {
19 return "", fmt.Errorf("reading ComDB failed -> %v: %w", functionName, readErr)
20 }
21
22 // Iteratve over comDB events
23 for _, event := range comDB.Events {
24 // Filter for confirm events (the only events targeted at CLI)
25 if event.Path == auxiliary.StateInstance.WorkingPath && event.Receiver == "CLI" && !event.Received {
26 // Mark event as received in comDB
27 if markErr := MarkComDBReceived(event); markErr != nil {
28 return "", fmt.Errorf("could not mark event as received -> %v --- %v: %w", event.Type, functionName, markErr)
29 }
30
31 if event.Type == "confirmed" {
32 return "confirmed", nil
33 }
34
35 if event.Type == "canceled" {
36 return "canceled", nil
37 }
38 }
39 }
40
41 return "", nil
42}
43
44func WatchComDBFallback() (bool, error) {
45 functionName := "WatchComDBFallback"

Callers 2

WatchComDBFallbackFunction · 0.85
WatchComDBFunction · 0.85

Calls 2

ReadComFileFunction · 0.85
MarkComDBReceivedFunction · 0.85

Tested by

no test coverage detected