forked from openimsdk/chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat_api.go
More file actions
39 lines (34 loc) · 982 Bytes
/
chat_api.go
File metadata and controls
39 lines (34 loc) · 982 Bytes
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
package cmd
import (
"context"
"github.com/openimsdk/chat/internal/api/chat"
"github.com/openimsdk/chat/pkg/common/config"
"github.com/openimsdk/tools/system/program"
"github.com/spf13/cobra"
)
type ChatApiCmd struct {
*RootCmd
ctx context.Context
configMap map[string]any
apiConfig chat.Config
}
func NewChatApiCmd() *ChatApiCmd {
var ret ChatApiCmd
ret.configMap = map[string]any{
ShareFileName: &ret.apiConfig.Share,
ChatAPIChatCfgFileName: &ret.apiConfig.ApiConfig,
ZookeeperConfigFileName: &ret.apiConfig.ZookeeperConfig,
}
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.runE()
}
return &ret
}
func (a *ChatApiCmd) Exec() error {
return a.Execute()
}
func (a *ChatApiCmd) runE() error {
return chat.Start(a.ctx, a.Index(), &a.apiConfig)
}