-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (42 loc) · 1.55 KB
/
main.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
49
50
51
52
// File: main.go
// Created by: Hoven
// Created on: 2025-02-16
//
// This file is part of the Example Project.
//
// (c) 2024 Example Corp. All rights reserved.
package main
import (
"github.com/go-puzzles/puzzles/cores"
"github.com/go-puzzles/puzzles/pflags"
"github.com/go-puzzles/puzzles/plog"
"github.com/yazl-tech/ai-bot/internal/domain/bot"
"github.com/yazl-tech/ai-bot/internal/domain/bot/doubao"
"github.com/yazl-tech/ai-bot/internal/service"
botpb "github.com/yazl-tech/ai-bot/pkg/proto/bot"
consulpuzzle "github.com/go-puzzles/puzzles/cores/puzzles/consul-puzzle"
grpcpuzzle "github.com/go-puzzles/puzzles/cores/puzzles/grpc-puzzle"
grpcuipuzzle "github.com/go-puzzles/puzzles/cores/puzzles/grpcui-puzzle"
grpcInterface "github.com/yazl-tech/ai-bot/internal/api/grpc"
)
var (
port = pflags.Int("port", 28089, "ai bot port to listen on")
doubaoConfFlag = pflags.Struct("doubao", (*doubao.DoubaoConfig)(nil), "doubao config")
)
func main() {
pflags.Parse()
doubaoConf := new(doubao.DoubaoConfig)
plog.PanicError(doubaoConfFlag(doubaoConf))
botFactory := bot.NewBotFactory()
doubaoProvider := doubao.NewDoubaoProvider(doubaoConf)
botFactory.RegisterProvider(botpb.ProviderType_Doubao, doubaoProvider)
botService := service.NewAiBotService(botFactory)
grpcSrv := grpcInterface.SetupGrpcServer(botService)
srv := cores.NewPuzzleCore(
cores.WithService(pflags.GetServiceName()),
consulpuzzle.WithConsulRegister(),
grpcpuzzle.WithCoreGrpcPuzzle(grpcSrv),
grpcuipuzzle.WithCoreGrpcUI(),
)
plog.PanicError(cores.Start(srv, port()))
}