-
Notifications
You must be signed in to change notification settings - Fork 19
/
sparrow.go
48 lines (38 loc) · 1.1 KB
/
sparrow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"time"
eb "github.com/soulteary/sparrow/components/event-broker"
lcs "github.com/soulteary/sparrow/components/local-conversation-storage"
claude "github.com/soulteary/sparrow/connectors/claude"
midjourney "github.com/soulteary/sparrow/connectors/mid-journey"
"github.com/soulteary/sparrow/internal/api"
"github.com/soulteary/sparrow/internal/define"
"github.com/soulteary/sparrow/internal/server"
"github.com/soulteary/sparrow/internal/version"
)
var brokerPool = eb.NewBrokerManager(256)
func main() {
fmt.Printf("Sparrow v%s\n", version.Version)
lcs.InitStorage(define.LOCAL_CONVERSATION_STORAGE_PATH)
engine := server.SetupEngine()
engine.Use(server.Recovery())
api.AuthSession(engine)
api.Public(engine)
api.Backend(engine, brokerPool)
if define.ENABLE_MIDJOURNEY {
go func() {
for {
if !midjourney.Ready {
midjourney.KeepConnection(brokerPool, !midjourney.Ready)
}
time.Sleep(1 * time.Second)
fmt.Println("check midjourney")
}
}()
}
if define.ENABLE_CLAUDE {
go claude.KeepConnection(brokerPool)
}
server.Launched(engine)
}