mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-07 19:50:07 +08:00
fix: monolithic
This commit is contained in:
parent
f60272a1d2
commit
c2b035839d
209
cmd/main.go
Normal file
209
cmd/main.go
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/mitchellh/mapstructure"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/api"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/msggateway"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/msgtransfer"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/push"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/auth"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/conversation"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/group"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/msg"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/relation"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/third"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/user"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
|
"github.com/openimsdk/tools/discovery"
|
||||||
|
"github.com/openimsdk/tools/discovery/standalone"
|
||||||
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var configPath string
|
||||||
|
flag.StringVar(&configPath, "c", "/Users/chao/Desktop/code/open-im-server/config", "config path")
|
||||||
|
flag.Parse()
|
||||||
|
cmd := newCmds(configPath)
|
||||||
|
putCmd1(cmd, auth.Start)
|
||||||
|
putCmd1(cmd, conversation.Start)
|
||||||
|
putCmd1(cmd, relation.Start)
|
||||||
|
putCmd1(cmd, group.Start)
|
||||||
|
putCmd1(cmd, msg.Start)
|
||||||
|
putCmd1(cmd, third.Start)
|
||||||
|
putCmd1(cmd, user.Start)
|
||||||
|
putCmd1(cmd, push.Start)
|
||||||
|
putCmd2(cmd, msggateway.Start)
|
||||||
|
putCmd2(cmd, msgtransfer.Start)
|
||||||
|
putCmd2(cmd, api.Start)
|
||||||
|
ctx := context.Background()
|
||||||
|
if err := cmd.run(ctx); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println("success")
|
||||||
|
}
|
||||||
|
|
||||||
|
func getTypePath(typ reflect.Type) string {
|
||||||
|
return path.Join(typ.PkgPath(), typ.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCmds(confPath string) *cmds {
|
||||||
|
return &cmds{confPath: confPath}
|
||||||
|
}
|
||||||
|
|
||||||
|
type cmds struct {
|
||||||
|
confPath string
|
||||||
|
cmds []cmdName
|
||||||
|
conf map[string][]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *cmds) readConfig() error {
|
||||||
|
skip := []string{
|
||||||
|
config.DiscoveryConfigFilename,
|
||||||
|
}
|
||||||
|
if x.conf == nil {
|
||||||
|
x.conf = make(map[string][]byte)
|
||||||
|
}
|
||||||
|
vof := reflect.ValueOf(&config.AllConfig{}).Elem()
|
||||||
|
num := vof.NumField()
|
||||||
|
for i := 0; i < num; i++ {
|
||||||
|
field := vof.Field(i)
|
||||||
|
for ptr := true; ptr; {
|
||||||
|
if field.Kind() == reflect.Ptr {
|
||||||
|
field = field.Elem()
|
||||||
|
} else {
|
||||||
|
ptr = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itemConf := field.Addr().Interface()
|
||||||
|
name := itemConf.(interface{ GetConfigFileName() string }).GetConfigFileName()
|
||||||
|
if datautil.Contain(name, skip...) {
|
||||||
|
x.conf[getTypePath(field.Type())] = nil
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
data, err := os.ReadFile(filepath.Join(x.confPath, name))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
x.conf[getTypePath(field.Type())] = data
|
||||||
|
}
|
||||||
|
val := config.Discovery{Enable: discovery.Standalone}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
if err := yaml.NewEncoder(&buf).Encode(&val); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
x.conf[getTypePath(reflect.TypeOf(val))] = buf.Bytes()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *cmds) parseConf(conf any) error {
|
||||||
|
vof := reflect.ValueOf(conf)
|
||||||
|
for {
|
||||||
|
if vof.Kind() == reflect.Ptr {
|
||||||
|
vof = vof.Elem()
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tof := vof.Type()
|
||||||
|
numField := vof.NumField()
|
||||||
|
for i := 0; i < numField; i++ {
|
||||||
|
typeField := tof.Field(i)
|
||||||
|
if !typeField.IsExported() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
field := vof.Field(i)
|
||||||
|
pkt := getTypePath(field.Type())
|
||||||
|
confData, ok := x.conf[pkt]
|
||||||
|
if !ok {
|
||||||
|
if typeField.Name == "FcmConfigPath" && field.Kind() == reflect.String {
|
||||||
|
field.SetString(x.confPath)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return fmt.Errorf("config field %s %s not found", vof.Type().Name(), typeField.Name)
|
||||||
|
}
|
||||||
|
if confData == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val := field.Addr().Interface()
|
||||||
|
v := viper.New()
|
||||||
|
v.SetConfigType("yaml")
|
||||||
|
if err := v.ReadConfig(bytes.NewReader(confData)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fn := func(conf *mapstructure.DecoderConfig) {
|
||||||
|
conf.TagName = config.StructTagName
|
||||||
|
}
|
||||||
|
if err := v.Unmarshal(val, fn); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *cmds) add(name string, fn func(ctx context.Context) error) {
|
||||||
|
x.cmds = append(x.cmds, cmdName{Name: name, Func: fn})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *cmds) run(ctx context.Context) error {
|
||||||
|
if x.conf == nil {
|
||||||
|
if err := x.readConfig(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, cmd := range x.cmds {
|
||||||
|
fmt.Println("start", cmd.Name)
|
||||||
|
if err := cmd.Func(ctx); err != nil {
|
||||||
|
fmt.Println("start failed", cmd.Name, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println("start ok", cmd.Name)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type cmdName struct {
|
||||||
|
Name string
|
||||||
|
Func func(ctx context.Context) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func getFuncPacketName(fn any) string {
|
||||||
|
name := path.Base(runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name())
|
||||||
|
if index := strings.Index(name, "."); index >= 0 {
|
||||||
|
name = name[:index]
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
|
func putCmd1[C any](cmd *cmds, fn func(ctx context.Context, config *C, client discovery.Conn, server grpc.ServiceRegistrar) error) {
|
||||||
|
cmd.add(getFuncPacketName(fn), func(ctx context.Context) error {
|
||||||
|
var conf C
|
||||||
|
if err := cmd.parseConf(&conf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return fn(ctx, &conf, standalone.GetDiscoveryConn(), standalone.GetServiceRegistrar())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func putCmd2[C any](cmd *cmds, fn func(ctx context.Context, index int, config *C) error) {
|
||||||
|
cmd.add(getFuncPacketName(fn), func(ctx context.Context) error {
|
||||||
|
var conf C
|
||||||
|
if err := cmd.parseConf(&conf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return fn(ctx, 0, &conf)
|
||||||
|
})
|
||||||
|
}
|
@ -35,7 +35,7 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) InitServer(ctx context.Context, config *Config, disCov discovery.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func (s *Server) InitServer(ctx context.Context, config *Config, disCov discovery.Conn, server grpc.ServiceRegistrar) error {
|
||||||
userConn, err := disCov.GetConn(ctx, config.Discovery.RpcService.User)
|
userConn, err := disCov.GetConn(ctx, config.Discovery.RpcService.User)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -34,14 +34,14 @@ type Config struct {
|
|||||||
WebhooksConfig config.Webhooks
|
WebhooksConfig config.Webhooks
|
||||||
Discovery config.Discovery
|
Discovery config.Discovery
|
||||||
|
|
||||||
RuntimeEnv string
|
runtimeEnv string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start run ws server.
|
// Start run ws server.
|
||||||
func Start(ctx context.Context, index int, conf *Config) error {
|
func Start(ctx context.Context, index int, conf *Config) error {
|
||||||
conf.RuntimeEnv = runtimeenv.PrintRuntimeEnvironment()
|
conf.runtimeEnv = runtimeenv.PrintRuntimeEnvironment()
|
||||||
|
|
||||||
log.CInfo(ctx, "MSG-GATEWAY server is initializing", "runtimeEnv", conf.RuntimeEnv,
|
log.CInfo(ctx, "MSG-GATEWAY server is initializing", "runtimeEnv", conf.runtimeEnv,
|
||||||
"rpcPorts", conf.MsgGateway.RPC.Ports,
|
"rpcPorts", conf.MsgGateway.RPC.Ports,
|
||||||
"wsPort", conf.MsgGateway.LongConnSvr.Ports, "prometheusPorts", conf.MsgGateway.Prometheus.Ports)
|
"wsPort", conf.MsgGateway.LongConnSvr.Ports, "prometheusPorts", conf.MsgGateway.Prometheus.Ports)
|
||||||
wsPort, err := datautil.GetElemByIndex(conf.MsgGateway.LongConnSvr.Ports, index)
|
wsPort, err := datautil.GetElemByIndex(conf.MsgGateway.LongConnSvr.Ports, index)
|
||||||
|
@ -35,7 +35,7 @@ type LongConnServer interface {
|
|||||||
GetUserAllCons(userID string) ([]*Client, bool)
|
GetUserAllCons(userID string) ([]*Client, bool)
|
||||||
GetUserPlatformCons(userID string, platform int) ([]*Client, bool, bool)
|
GetUserPlatformCons(userID string, platform int) ([]*Client, bool, bool)
|
||||||
Validate(s any) error
|
Validate(s any) error
|
||||||
SetDiscoveryRegistry(ctx context.Context, client discovery.SvcDiscoveryRegistry, config *Config) error
|
SetDiscoveryRegistry(ctx context.Context, client discovery.Conn, config *Config) error
|
||||||
KickUserConn(client *Client) error
|
KickUserConn(client *Client) error
|
||||||
UnRegister(c *Client)
|
UnRegister(c *Client)
|
||||||
SetKickHandlerInfo(i *kickHandler)
|
SetKickHandlerInfo(i *kickHandler)
|
||||||
@ -60,7 +60,7 @@ type WsServer struct {
|
|||||||
handshakeTimeout time.Duration
|
handshakeTimeout time.Duration
|
||||||
writeBufferSize int
|
writeBufferSize int
|
||||||
validate *validator.Validate
|
validate *validator.Validate
|
||||||
disCov discovery.SvcDiscoveryRegistry
|
disCov discovery.Conn
|
||||||
Compressor
|
Compressor
|
||||||
//Encoder
|
//Encoder
|
||||||
MessageHandler
|
MessageHandler
|
||||||
@ -75,7 +75,7 @@ type kickHandler struct {
|
|||||||
newClient *Client
|
newClient *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WsServer) SetDiscoveryRegistry(ctx context.Context, disCov discovery.SvcDiscoveryRegistry, config *Config) error {
|
func (ws *WsServer) SetDiscoveryRegistry(ctx context.Context, disCov discovery.Conn, config *Config) error {
|
||||||
userConn, err := disCov.GetConn(ctx, config.Discovery.RpcService.User)
|
userConn, err := disCov.GetConn(ctx, config.Discovery.RpcService.User)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -41,8 +41,7 @@ func (u emptyOnlinePusher) GetOnlinePushFailedUserIDs(ctx context.Context, msg *
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOnlinePusher(disCov discovery.SvcDiscoveryRegistry, config *Config) OnlinePusher {
|
func NewOnlinePusher(disCov discovery.Conn, config *Config) OnlinePusher {
|
||||||
|
|
||||||
if config.runTimeEnv == conf.KUBERNETES {
|
if config.runTimeEnv == conf.KUBERNETES {
|
||||||
return NewDefaultAllNode(disCov, config)
|
return NewDefaultAllNode(disCov, config)
|
||||||
}
|
}
|
||||||
@ -56,11 +55,11 @@ func NewOnlinePusher(disCov discovery.SvcDiscoveryRegistry, config *Config) Onli
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DefaultAllNode struct {
|
type DefaultAllNode struct {
|
||||||
disCov discovery.SvcDiscoveryRegistry
|
disCov discovery.Conn
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefaultAllNode(disCov discovery.SvcDiscoveryRegistry, config *Config) *DefaultAllNode {
|
func NewDefaultAllNode(disCov discovery.Conn, config *Config) *DefaultAllNode {
|
||||||
return &DefaultAllNode{disCov: disCov, config: config}
|
return &DefaultAllNode{disCov: disCov, config: config}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
type pushServer struct {
|
type pushServer struct {
|
||||||
pbpush.UnimplementedPushMsgServiceServer
|
pbpush.UnimplementedPushMsgServiceServer
|
||||||
database controller.PushDatabase
|
database controller.PushDatabase
|
||||||
disCov discovery.SvcDiscoveryRegistry
|
disCov discovery.Conn
|
||||||
offlinePusher offlinepush.OfflinePusher
|
offlinePusher offlinepush.OfflinePusher
|
||||||
pushCh *ConsumerHandler
|
pushCh *ConsumerHandler
|
||||||
offlinePushCh *OfflinePushConsumerHandler
|
offlinePushCh *OfflinePushConsumerHandler
|
||||||
@ -45,7 +45,7 @@ func (p pushServer) DelUserPushToken(ctx context.Context,
|
|||||||
return &pbpush.DelUserPushTokenResp{}, nil
|
return &pbpush.DelUserPushTokenResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func Start(ctx context.Context, config *Config, client discovery.Conn, server grpc.ServiceRegistrar) error {
|
||||||
config.runTimeEnv = runtimeenv.PrintRuntimeEnvironment()
|
config.runTimeEnv = runtimeenv.PrintRuntimeEnvironment()
|
||||||
|
|
||||||
rdb, err := redisutil.NewRedisClient(ctx, config.RedisConfig.Build())
|
rdb, err := redisutil.NewRedisClient(ctx, config.RedisConfig.Build())
|
||||||
|
@ -50,7 +50,7 @@ type ConsumerHandler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewConsumerHandler(ctx context.Context, config *Config, database controller.PushDatabase, offlinePusher offlinepush.OfflinePusher, rdb redis.UniversalClient,
|
func NewConsumerHandler(ctx context.Context, config *Config, database controller.PushDatabase, offlinePusher offlinepush.OfflinePusher, rdb redis.UniversalClient,
|
||||||
client discovery.SvcDiscoveryRegistry) (*ConsumerHandler, error) {
|
client discovery.Conn) (*ConsumerHandler, error) {
|
||||||
var consumerHandler ConsumerHandler
|
var consumerHandler ConsumerHandler
|
||||||
var err error
|
var err error
|
||||||
consumerHandler.pushConsumerGroup, err = kafka.NewMConsumerGroup(config.KafkaConfig.Build(), config.KafkaConfig.ToPushGroupID,
|
consumerHandler.pushConsumerGroup, err = kafka.NewMConsumerGroup(config.KafkaConfig.Build(), config.KafkaConfig.ToPushGroupID,
|
||||||
|
@ -43,7 +43,7 @@ import (
|
|||||||
type authServer struct {
|
type authServer struct {
|
||||||
pbauth.UnimplementedAuthServer
|
pbauth.UnimplementedAuthServer
|
||||||
authDatabase controller.AuthDatabase
|
authDatabase controller.AuthDatabase
|
||||||
RegisterCenter discovery.SvcDiscoveryRegistry
|
RegisterCenter discovery.Conn
|
||||||
config *Config
|
config *Config
|
||||||
userClient *rpcli.UserClient
|
userClient *rpcli.UserClient
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ type Config struct {
|
|||||||
Discovery config.Discovery
|
Discovery config.Discovery
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func Start(ctx context.Context, config *Config, client discovery.Conn, server grpc.ServiceRegistrar) error {
|
||||||
rdb, err := redisutil.NewRedisClient(ctx, config.RedisConfig.Build())
|
rdb, err := redisutil.NewRedisClient(ctx, config.RedisConfig.Build())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -16,10 +16,11 @@ package conversation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
|
||||||
@ -65,7 +66,7 @@ type Config struct {
|
|||||||
Discovery config.Discovery
|
Discovery config.Discovery
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func Start(ctx context.Context, config *Config, client discovery.Conn, server grpc.ServiceRegistrar) error {
|
||||||
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -17,13 +17,14 @@ package group
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
|
"github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@ -76,7 +77,7 @@ type Config struct {
|
|||||||
Discovery config.Discovery
|
Discovery config.Discovery
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func Start(ctx context.Context, config *Config, client discovery.Conn, server grpc.ServiceRegistrar) error {
|
||||||
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -16,6 +16,7 @@ package msg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@ -56,8 +57,8 @@ type Config struct {
|
|||||||
// MsgServer encapsulates dependencies required for message handling.
|
// MsgServer encapsulates dependencies required for message handling.
|
||||||
type msgServer struct {
|
type msgServer struct {
|
||||||
msg.UnimplementedMsgServer
|
msg.UnimplementedMsgServer
|
||||||
RegisterCenter discovery.SvcDiscoveryRegistry // Service discovery registry for service registration.
|
RegisterCenter discovery.Conn // Service discovery registry for service registration.
|
||||||
MsgDatabase controller.CommonMsgDatabase // Interface for message database operations.
|
MsgDatabase controller.CommonMsgDatabase // Interface for message database operations.
|
||||||
StreamMsgDatabase controller.StreamMsgDatabase
|
StreamMsgDatabase controller.StreamMsgDatabase
|
||||||
UserLocalCache *rpccache.UserLocalCache // Local cache for user data.
|
UserLocalCache *rpccache.UserLocalCache // Local cache for user data.
|
||||||
FriendLocalCache *rpccache.FriendLocalCache // Local cache for friend data.
|
FriendLocalCache *rpccache.FriendLocalCache // Local cache for friend data.
|
||||||
@ -76,7 +77,7 @@ func (m *msgServer) addInterceptorHandler(interceptorFunc ...MessageInterceptorF
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func Start(ctx context.Context, config *Config, client discovery.Conn, server grpc.ServiceRegistrar) error {
|
||||||
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -16,6 +16,7 @@ package relation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
|
||||||
"github.com/openimsdk/tools/mq/memamq"
|
"github.com/openimsdk/tools/mq/memamq"
|
||||||
@ -47,7 +48,7 @@ type friendServer struct {
|
|||||||
db controller.FriendDatabase
|
db controller.FriendDatabase
|
||||||
blackDatabase controller.BlackDatabase
|
blackDatabase controller.BlackDatabase
|
||||||
notificationSender *FriendNotificationSender
|
notificationSender *FriendNotificationSender
|
||||||
RegisterCenter discovery.SvcDiscoveryRegistry
|
RegisterCenter discovery.Conn
|
||||||
config *Config
|
config *Config
|
||||||
webhookClient *webhook.Client
|
webhookClient *webhook.Client
|
||||||
queue *memamq.MemoryQueue
|
queue *memamq.MemoryQueue
|
||||||
@ -66,7 +67,7 @@ type Config struct {
|
|||||||
Discovery config.Discovery
|
Discovery config.Discovery
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func Start(ctx context.Context, config *Config, client discovery.Conn, server grpc.ServiceRegistrar) error {
|
||||||
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -17,9 +17,10 @@ package third
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
|
||||||
@ -60,7 +61,7 @@ type Config struct {
|
|||||||
Discovery config.Discovery
|
Discovery config.Discovery
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func Start(ctx context.Context, config *Config, client discovery.Conn, server grpc.ServiceRegistrar) error {
|
||||||
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -45,7 +45,7 @@ import (
|
|||||||
pbuser "github.com/openimsdk/protocol/user"
|
pbuser "github.com/openimsdk/protocol/user"
|
||||||
"github.com/openimsdk/tools/db/mongoutil"
|
"github.com/openimsdk/tools/db/mongoutil"
|
||||||
"github.com/openimsdk/tools/db/pagination"
|
"github.com/openimsdk/tools/db/pagination"
|
||||||
registry "github.com/openimsdk/tools/discovery"
|
"github.com/openimsdk/tools/discovery"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -57,7 +57,7 @@ type userServer struct {
|
|||||||
db controller.UserDatabase
|
db controller.UserDatabase
|
||||||
friendNotificationSender *relation.FriendNotificationSender
|
friendNotificationSender *relation.FriendNotificationSender
|
||||||
userNotificationSender *UserNotificationSender
|
userNotificationSender *UserNotificationSender
|
||||||
RegisterCenter registry.SvcDiscoveryRegistry
|
RegisterCenter discovery.Conn
|
||||||
config *Config
|
config *Config
|
||||||
webhookClient *webhook.Client
|
webhookClient *webhook.Client
|
||||||
groupClient *rpcli.GroupClient
|
groupClient *rpcli.GroupClient
|
||||||
@ -76,7 +76,7 @@ type Config struct {
|
|||||||
Discovery config.Discovery
|
Discovery config.Discovery
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, config *Config, client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func Start(ctx context.Context, config *Config, client discovery.Conn, server grpc.ServiceRegistrar) error {
|
||||||
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
mgocli, err := mongoutil.NewMongoDB(ctx, config.MongodbConfig.Build())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -28,378 +28,380 @@ import (
|
|||||||
"github.com/openimsdk/tools/s3/oss"
|
"github.com/openimsdk/tools/s3/oss"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const StructTagName = "yaml"
|
||||||
|
|
||||||
type CacheConfig struct {
|
type CacheConfig struct {
|
||||||
Topic string `mapstructure:"topic"`
|
Topic string `yaml:"topic"`
|
||||||
SlotNum int `mapstructure:"slotNum"`
|
SlotNum int `yaml:"slotNum"`
|
||||||
SlotSize int `mapstructure:"slotSize"`
|
SlotSize int `yaml:"slotSize"`
|
||||||
SuccessExpire int `mapstructure:"successExpire"`
|
SuccessExpire int `yaml:"successExpire"`
|
||||||
FailedExpire int `mapstructure:"failedExpire"`
|
FailedExpire int `yaml:"failedExpire"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LocalCache struct {
|
type LocalCache struct {
|
||||||
User CacheConfig `mapstructure:"user"`
|
User CacheConfig `yaml:"user"`
|
||||||
Group CacheConfig `mapstructure:"group"`
|
Group CacheConfig `yaml:"group"`
|
||||||
Friend CacheConfig `mapstructure:"friend"`
|
Friend CacheConfig `yaml:"friend"`
|
||||||
Conversation CacheConfig `mapstructure:"conversation"`
|
Conversation CacheConfig `yaml:"conversation"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Log struct {
|
type Log struct {
|
||||||
StorageLocation string `mapstructure:"storageLocation"`
|
StorageLocation string `yaml:"storageLocation"`
|
||||||
RotationTime uint `mapstructure:"rotationTime"`
|
RotationTime uint `yaml:"rotationTime"`
|
||||||
RemainRotationCount uint `mapstructure:"remainRotationCount"`
|
RemainRotationCount uint `yaml:"remainRotationCount"`
|
||||||
RemainLogLevel int `mapstructure:"remainLogLevel"`
|
RemainLogLevel int `yaml:"remainLogLevel"`
|
||||||
IsStdout bool `mapstructure:"isStdout"`
|
IsStdout bool `yaml:"isStdout"`
|
||||||
IsJson bool `mapstructure:"isJson"`
|
IsJson bool `yaml:"isJson"`
|
||||||
IsSimplify bool `mapstructure:"isSimplify"`
|
IsSimplify bool `yaml:"isSimplify"`
|
||||||
WithStack bool `mapstructure:"withStack"`
|
WithStack bool `yaml:"withStack"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Minio struct {
|
type Minio struct {
|
||||||
Bucket string `mapstructure:"bucket"`
|
Bucket string `yaml:"bucket"`
|
||||||
AccessKeyID string `mapstructure:"accessKeyID"`
|
AccessKeyID string `yaml:"accessKeyID"`
|
||||||
SecretAccessKey string `mapstructure:"secretAccessKey"`
|
SecretAccessKey string `yaml:"secretAccessKey"`
|
||||||
SessionToken string `mapstructure:"sessionToken"`
|
SessionToken string `yaml:"sessionToken"`
|
||||||
InternalAddress string `mapstructure:"internalAddress"`
|
InternalAddress string `yaml:"internalAddress"`
|
||||||
ExternalAddress string `mapstructure:"externalAddress"`
|
ExternalAddress string `yaml:"externalAddress"`
|
||||||
PublicRead bool `mapstructure:"publicRead"`
|
PublicRead bool `yaml:"publicRead"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mongo struct {
|
type Mongo struct {
|
||||||
URI string `mapstructure:"uri"`
|
URI string `yaml:"uri"`
|
||||||
Address []string `mapstructure:"address"`
|
Address []string `yaml:"address"`
|
||||||
Database string `mapstructure:"database"`
|
Database string `yaml:"database"`
|
||||||
Username string `mapstructure:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `yaml:"password"`
|
||||||
AuthSource string `mapstructure:"authSource"`
|
AuthSource string `yaml:"authSource"`
|
||||||
MaxPoolSize int `mapstructure:"maxPoolSize"`
|
MaxPoolSize int `yaml:"maxPoolSize"`
|
||||||
MaxRetry int `mapstructure:"maxRetry"`
|
MaxRetry int `yaml:"maxRetry"`
|
||||||
}
|
}
|
||||||
type Kafka struct {
|
type Kafka struct {
|
||||||
Username string `mapstructure:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `yaml:"password"`
|
||||||
ProducerAck string `mapstructure:"producerAck"`
|
ProducerAck string `yaml:"producerAck"`
|
||||||
CompressType string `mapstructure:"compressType"`
|
CompressType string `yaml:"compressType"`
|
||||||
Address []string `mapstructure:"address"`
|
Address []string `yaml:"address"`
|
||||||
ToRedisTopic string `mapstructure:"toRedisTopic"`
|
ToRedisTopic string `yaml:"toRedisTopic"`
|
||||||
ToMongoTopic string `mapstructure:"toMongoTopic"`
|
ToMongoTopic string `yaml:"toMongoTopic"`
|
||||||
ToPushTopic string `mapstructure:"toPushTopic"`
|
ToPushTopic string `yaml:"toPushTopic"`
|
||||||
ToOfflinePushTopic string `mapstructure:"toOfflinePushTopic"`
|
ToOfflinePushTopic string `yaml:"toOfflinePushTopic"`
|
||||||
ToRedisGroupID string `mapstructure:"toRedisGroupID"`
|
ToRedisGroupID string `yaml:"toRedisGroupID"`
|
||||||
ToMongoGroupID string `mapstructure:"toMongoGroupID"`
|
ToMongoGroupID string `yaml:"toMongoGroupID"`
|
||||||
ToPushGroupID string `mapstructure:"toPushGroupID"`
|
ToPushGroupID string `yaml:"toPushGroupID"`
|
||||||
ToOfflineGroupID string `mapstructure:"toOfflinePushGroupID"`
|
ToOfflineGroupID string `yaml:"toOfflinePushGroupID"`
|
||||||
|
|
||||||
Tls TLSConfig `mapstructure:"tls"`
|
Tls TLSConfig `yaml:"tls"`
|
||||||
}
|
}
|
||||||
type TLSConfig struct {
|
type TLSConfig struct {
|
||||||
EnableTLS bool `mapstructure:"enableTLS"`
|
EnableTLS bool `yaml:"enableTLS"`
|
||||||
CACrt string `mapstructure:"caCrt"`
|
CACrt string `yaml:"caCrt"`
|
||||||
ClientCrt string `mapstructure:"clientCrt"`
|
ClientCrt string `yaml:"clientCrt"`
|
||||||
ClientKey string `mapstructure:"clientKey"`
|
ClientKey string `yaml:"clientKey"`
|
||||||
ClientKeyPwd string `mapstructure:"clientKeyPwd"`
|
ClientKeyPwd string `yaml:"clientKeyPwd"`
|
||||||
InsecureSkipVerify bool `mapstructure:"insecureSkipVerify"`
|
InsecureSkipVerify bool `yaml:"insecureSkipVerify"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
Api struct {
|
Api struct {
|
||||||
ListenIP string `mapstructure:"listenIP"`
|
ListenIP string `yaml:"listenIP"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
CompressionLevel int `mapstructure:"compressionLevel"`
|
CompressionLevel int `yaml:"compressionLevel"`
|
||||||
} `mapstructure:"api"`
|
} `yaml:"api"`
|
||||||
Prometheus struct {
|
Prometheus struct {
|
||||||
Enable bool `mapstructure:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
GrafanaURL string `mapstructure:"grafanaURL"`
|
GrafanaURL string `yaml:"grafanaURL"`
|
||||||
} `mapstructure:"prometheus"`
|
} `yaml:"prometheus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CronTask struct {
|
type CronTask struct {
|
||||||
CronExecuteTime string `mapstructure:"cronExecuteTime"`
|
CronExecuteTime string `yaml:"cronExecuteTime"`
|
||||||
RetainChatRecords int `mapstructure:"retainChatRecords"`
|
RetainChatRecords int `yaml:"retainChatRecords"`
|
||||||
FileExpireTime int `mapstructure:"fileExpireTime"`
|
FileExpireTime int `yaml:"fileExpireTime"`
|
||||||
DeleteObjectType []string `mapstructure:"deleteObjectType"`
|
DeleteObjectType []string `yaml:"deleteObjectType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OfflinePushConfig struct {
|
type OfflinePushConfig struct {
|
||||||
Enable bool `mapstructure:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
Title string `mapstructure:"title"`
|
Title string `yaml:"title"`
|
||||||
Desc string `mapstructure:"desc"`
|
Desc string `yaml:"desc"`
|
||||||
Ext string `mapstructure:"ext"`
|
Ext string `yaml:"ext"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type NotificationConfig struct {
|
type NotificationConfig struct {
|
||||||
IsSendMsg bool `mapstructure:"isSendMsg"`
|
IsSendMsg bool `yaml:"isSendMsg"`
|
||||||
ReliabilityLevel int `mapstructure:"reliabilityLevel"`
|
ReliabilityLevel int `yaml:"reliabilityLevel"`
|
||||||
UnreadCount bool `mapstructure:"unreadCount"`
|
UnreadCount bool `yaml:"unreadCount"`
|
||||||
OfflinePush OfflinePushConfig `mapstructure:"offlinePush"`
|
OfflinePush OfflinePushConfig `yaml:"offlinePush"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Notification struct {
|
type Notification struct {
|
||||||
GroupCreated NotificationConfig `mapstructure:"groupCreated"`
|
GroupCreated NotificationConfig `yaml:"groupCreated"`
|
||||||
GroupInfoSet NotificationConfig `mapstructure:"groupInfoSet"`
|
GroupInfoSet NotificationConfig `yaml:"groupInfoSet"`
|
||||||
JoinGroupApplication NotificationConfig `mapstructure:"joinGroupApplication"`
|
JoinGroupApplication NotificationConfig `yaml:"joinGroupApplication"`
|
||||||
MemberQuit NotificationConfig `mapstructure:"memberQuit"`
|
MemberQuit NotificationConfig `yaml:"memberQuit"`
|
||||||
GroupApplicationAccepted NotificationConfig `mapstructure:"groupApplicationAccepted"`
|
GroupApplicationAccepted NotificationConfig `yaml:"groupApplicationAccepted"`
|
||||||
GroupApplicationRejected NotificationConfig `mapstructure:"groupApplicationRejected"`
|
GroupApplicationRejected NotificationConfig `yaml:"groupApplicationRejected"`
|
||||||
GroupOwnerTransferred NotificationConfig `mapstructure:"groupOwnerTransferred"`
|
GroupOwnerTransferred NotificationConfig `yaml:"groupOwnerTransferred"`
|
||||||
MemberKicked NotificationConfig `mapstructure:"memberKicked"`
|
MemberKicked NotificationConfig `yaml:"memberKicked"`
|
||||||
MemberInvited NotificationConfig `mapstructure:"memberInvited"`
|
MemberInvited NotificationConfig `yaml:"memberInvited"`
|
||||||
MemberEnter NotificationConfig `mapstructure:"memberEnter"`
|
MemberEnter NotificationConfig `yaml:"memberEnter"`
|
||||||
GroupDismissed NotificationConfig `mapstructure:"groupDismissed"`
|
GroupDismissed NotificationConfig `yaml:"groupDismissed"`
|
||||||
GroupMuted NotificationConfig `mapstructure:"groupMuted"`
|
GroupMuted NotificationConfig `yaml:"groupMuted"`
|
||||||
GroupCancelMuted NotificationConfig `mapstructure:"groupCancelMuted"`
|
GroupCancelMuted NotificationConfig `yaml:"groupCancelMuted"`
|
||||||
GroupMemberMuted NotificationConfig `mapstructure:"groupMemberMuted"`
|
GroupMemberMuted NotificationConfig `yaml:"groupMemberMuted"`
|
||||||
GroupMemberCancelMuted NotificationConfig `mapstructure:"groupMemberCancelMuted"`
|
GroupMemberCancelMuted NotificationConfig `yaml:"groupMemberCancelMuted"`
|
||||||
GroupMemberInfoSet NotificationConfig `mapstructure:"groupMemberInfoSet"`
|
GroupMemberInfoSet NotificationConfig `yaml:"groupMemberInfoSet"`
|
||||||
GroupMemberSetToAdmin NotificationConfig `yaml:"groupMemberSetToAdmin"`
|
GroupMemberSetToAdmin NotificationConfig `yaml:"groupMemberSetToAdmin"`
|
||||||
GroupMemberSetToOrdinary NotificationConfig `yaml:"groupMemberSetToOrdinaryUser"`
|
GroupMemberSetToOrdinary NotificationConfig `yaml:"groupMemberSetToOrdinaryUser"`
|
||||||
GroupInfoSetAnnouncement NotificationConfig `mapstructure:"groupInfoSetAnnouncement"`
|
GroupInfoSetAnnouncement NotificationConfig `yaml:"groupInfoSetAnnouncement"`
|
||||||
GroupInfoSetName NotificationConfig `mapstructure:"groupInfoSetName"`
|
GroupInfoSetName NotificationConfig `yaml:"groupInfoSetName"`
|
||||||
FriendApplicationAdded NotificationConfig `mapstructure:"friendApplicationAdded"`
|
FriendApplicationAdded NotificationConfig `yaml:"friendApplicationAdded"`
|
||||||
FriendApplicationApproved NotificationConfig `mapstructure:"friendApplicationApproved"`
|
FriendApplicationApproved NotificationConfig `yaml:"friendApplicationApproved"`
|
||||||
FriendApplicationRejected NotificationConfig `mapstructure:"friendApplicationRejected"`
|
FriendApplicationRejected NotificationConfig `yaml:"friendApplicationRejected"`
|
||||||
FriendAdded NotificationConfig `mapstructure:"friendAdded"`
|
FriendAdded NotificationConfig `yaml:"friendAdded"`
|
||||||
FriendDeleted NotificationConfig `mapstructure:"friendDeleted"`
|
FriendDeleted NotificationConfig `yaml:"friendDeleted"`
|
||||||
FriendRemarkSet NotificationConfig `mapstructure:"friendRemarkSet"`
|
FriendRemarkSet NotificationConfig `yaml:"friendRemarkSet"`
|
||||||
BlackAdded NotificationConfig `mapstructure:"blackAdded"`
|
BlackAdded NotificationConfig `yaml:"blackAdded"`
|
||||||
BlackDeleted NotificationConfig `mapstructure:"blackDeleted"`
|
BlackDeleted NotificationConfig `yaml:"blackDeleted"`
|
||||||
FriendInfoUpdated NotificationConfig `mapstructure:"friendInfoUpdated"`
|
FriendInfoUpdated NotificationConfig `yaml:"friendInfoUpdated"`
|
||||||
UserInfoUpdated NotificationConfig `mapstructure:"userInfoUpdated"`
|
UserInfoUpdated NotificationConfig `yaml:"userInfoUpdated"`
|
||||||
UserStatusChanged NotificationConfig `mapstructure:"userStatusChanged"`
|
UserStatusChanged NotificationConfig `yaml:"userStatusChanged"`
|
||||||
ConversationChanged NotificationConfig `mapstructure:"conversationChanged"`
|
ConversationChanged NotificationConfig `yaml:"conversationChanged"`
|
||||||
ConversationSetPrivate NotificationConfig `mapstructure:"conversationSetPrivate"`
|
ConversationSetPrivate NotificationConfig `yaml:"conversationSetPrivate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Prometheus struct {
|
type Prometheus struct {
|
||||||
Enable bool `mapstructure:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MsgGateway struct {
|
type MsgGateway struct {
|
||||||
RPC struct {
|
RPC struct {
|
||||||
RegisterIP string `mapstructure:"registerIP"`
|
RegisterIP string `yaml:"registerIP"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
} `mapstructure:"rpc"`
|
} `yaml:"rpc"`
|
||||||
Prometheus Prometheus `mapstructure:"prometheus"`
|
Prometheus Prometheus `yaml:"prometheus"`
|
||||||
ListenIP string `mapstructure:"listenIP"`
|
ListenIP string `yaml:"listenIP"`
|
||||||
LongConnSvr struct {
|
LongConnSvr struct {
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
WebsocketMaxConnNum int `mapstructure:"websocketMaxConnNum"`
|
WebsocketMaxConnNum int `yaml:"websocketMaxConnNum"`
|
||||||
WebsocketMaxMsgLen int `mapstructure:"websocketMaxMsgLen"`
|
WebsocketMaxMsgLen int `yaml:"websocketMaxMsgLen"`
|
||||||
WebsocketTimeout int `mapstructure:"websocketTimeout"`
|
WebsocketTimeout int `yaml:"websocketTimeout"`
|
||||||
} `mapstructure:"longConnSvr"`
|
} `yaml:"longConnSvr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MsgTransfer struct {
|
type MsgTransfer struct {
|
||||||
Prometheus struct {
|
Prometheus struct {
|
||||||
Enable bool `mapstructure:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
} `mapstructure:"prometheus"`
|
} `yaml:"prometheus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Push struct {
|
type Push struct {
|
||||||
RPC struct {
|
RPC struct {
|
||||||
RegisterIP string `mapstructure:"registerIP"`
|
RegisterIP string `yaml:"registerIP"`
|
||||||
ListenIP string `mapstructure:"listenIP"`
|
ListenIP string `yaml:"listenIP"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
} `mapstructure:"rpc"`
|
} `yaml:"rpc"`
|
||||||
Prometheus Prometheus `mapstructure:"prometheus"`
|
Prometheus Prometheus `yaml:"prometheus"`
|
||||||
MaxConcurrentWorkers int `mapstructure:"maxConcurrentWorkers"`
|
MaxConcurrentWorkers int `yaml:"maxConcurrentWorkers"`
|
||||||
Enable string `mapstructure:"enable"`
|
Enable string `yaml:"enable"`
|
||||||
GeTui struct {
|
GeTui struct {
|
||||||
PushUrl string `mapstructure:"pushUrl"`
|
PushUrl string `yaml:"pushUrl"`
|
||||||
MasterSecret string `mapstructure:"masterSecret"`
|
MasterSecret string `yaml:"masterSecret"`
|
||||||
AppKey string `mapstructure:"appKey"`
|
AppKey string `yaml:"appKey"`
|
||||||
Intent string `mapstructure:"intent"`
|
Intent string `yaml:"intent"`
|
||||||
ChannelID string `mapstructure:"channelID"`
|
ChannelID string `yaml:"channelID"`
|
||||||
ChannelName string `mapstructure:"channelName"`
|
ChannelName string `yaml:"channelName"`
|
||||||
} `mapstructure:"geTui"`
|
} `yaml:"geTui"`
|
||||||
FCM struct {
|
FCM struct {
|
||||||
FilePath string `mapstructure:"filePath"`
|
FilePath string `yaml:"filePath"`
|
||||||
AuthURL string `mapstructure:"authURL"`
|
AuthURL string `yaml:"authURL"`
|
||||||
} `mapstructure:"fcm"`
|
} `yaml:"fcm"`
|
||||||
JPush struct {
|
JPush struct {
|
||||||
AppKey string `mapstructure:"appKey"`
|
AppKey string `yaml:"appKey"`
|
||||||
MasterSecret string `mapstructure:"masterSecret"`
|
MasterSecret string `yaml:"masterSecret"`
|
||||||
PushURL string `mapstructure:"pushURL"`
|
PushURL string `yaml:"pushURL"`
|
||||||
PushIntent string `mapstructure:"pushIntent"`
|
PushIntent string `yaml:"pushIntent"`
|
||||||
} `mapstructure:"jpush"`
|
} `yaml:"jpush"`
|
||||||
IOSPush struct {
|
IOSPush struct {
|
||||||
PushSound string `mapstructure:"pushSound"`
|
PushSound string `yaml:"pushSound"`
|
||||||
BadgeCount bool `mapstructure:"badgeCount"`
|
BadgeCount bool `yaml:"badgeCount"`
|
||||||
Production bool `mapstructure:"production"`
|
Production bool `yaml:"production"`
|
||||||
} `mapstructure:"iosPush"`
|
} `yaml:"iosPush"`
|
||||||
FullUserCache bool `mapstructure:"fullUserCache"`
|
FullUserCache bool `yaml:"fullUserCache"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Auth struct {
|
type Auth struct {
|
||||||
RPC struct {
|
RPC struct {
|
||||||
RegisterIP string `mapstructure:"registerIP"`
|
RegisterIP string `yaml:"registerIP"`
|
||||||
ListenIP string `mapstructure:"listenIP"`
|
ListenIP string `yaml:"listenIP"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
} `mapstructure:"rpc"`
|
} `yaml:"rpc"`
|
||||||
Prometheus Prometheus `mapstructure:"prometheus"`
|
Prometheus Prometheus `yaml:"prometheus"`
|
||||||
TokenPolicy struct {
|
TokenPolicy struct {
|
||||||
Expire int64 `mapstructure:"expire"`
|
Expire int64 `yaml:"expire"`
|
||||||
} `mapstructure:"tokenPolicy"`
|
} `yaml:"tokenPolicy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Conversation struct {
|
type Conversation struct {
|
||||||
RPC struct {
|
RPC struct {
|
||||||
RegisterIP string `mapstructure:"registerIP"`
|
RegisterIP string `yaml:"registerIP"`
|
||||||
ListenIP string `mapstructure:"listenIP"`
|
ListenIP string `yaml:"listenIP"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
} `mapstructure:"rpc"`
|
} `yaml:"rpc"`
|
||||||
Prometheus Prometheus `mapstructure:"prometheus"`
|
Prometheus Prometheus `yaml:"prometheus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Friend struct {
|
type Friend struct {
|
||||||
RPC struct {
|
RPC struct {
|
||||||
RegisterIP string `mapstructure:"registerIP"`
|
RegisterIP string `yaml:"registerIP"`
|
||||||
ListenIP string `mapstructure:"listenIP"`
|
ListenIP string `yaml:"listenIP"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
} `mapstructure:"rpc"`
|
} `yaml:"rpc"`
|
||||||
Prometheus Prometheus `mapstructure:"prometheus"`
|
Prometheus Prometheus `yaml:"prometheus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Group struct {
|
type Group struct {
|
||||||
RPC struct {
|
RPC struct {
|
||||||
RegisterIP string `mapstructure:"registerIP"`
|
RegisterIP string `yaml:"registerIP"`
|
||||||
ListenIP string `mapstructure:"listenIP"`
|
ListenIP string `yaml:"listenIP"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
} `mapstructure:"rpc"`
|
} `yaml:"rpc"`
|
||||||
Prometheus Prometheus `mapstructure:"prometheus"`
|
Prometheus Prometheus `yaml:"prometheus"`
|
||||||
EnableHistoryForNewMembers bool `mapstructure:"enableHistoryForNewMembers"`
|
EnableHistoryForNewMembers bool `yaml:"enableHistoryForNewMembers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Msg struct {
|
type Msg struct {
|
||||||
RPC struct {
|
RPC struct {
|
||||||
RegisterIP string `mapstructure:"registerIP"`
|
RegisterIP string `yaml:"registerIP"`
|
||||||
ListenIP string `mapstructure:"listenIP"`
|
ListenIP string `yaml:"listenIP"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
} `mapstructure:"rpc"`
|
} `yaml:"rpc"`
|
||||||
Prometheus Prometheus `mapstructure:"prometheus"`
|
Prometheus Prometheus `yaml:"prometheus"`
|
||||||
FriendVerify bool `mapstructure:"friendVerify"`
|
FriendVerify bool `yaml:"friendVerify"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Third struct {
|
type Third struct {
|
||||||
RPC struct {
|
RPC struct {
|
||||||
RegisterIP string `mapstructure:"registerIP"`
|
RegisterIP string `yaml:"registerIP"`
|
||||||
ListenIP string `mapstructure:"listenIP"`
|
ListenIP string `yaml:"listenIP"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
} `mapstructure:"rpc"`
|
} `yaml:"rpc"`
|
||||||
Prometheus Prometheus `mapstructure:"prometheus"`
|
Prometheus Prometheus `yaml:"prometheus"`
|
||||||
Object struct {
|
Object struct {
|
||||||
Enable string `mapstructure:"enable"`
|
Enable string `yaml:"enable"`
|
||||||
Cos Cos `mapstructure:"cos"`
|
Cos Cos `yaml:"cos"`
|
||||||
Oss Oss `mapstructure:"oss"`
|
Oss Oss `yaml:"oss"`
|
||||||
Kodo Kodo `mapstructure:"kodo"`
|
Kodo Kodo `yaml:"kodo"`
|
||||||
Aws Aws `mapstructure:"aws"`
|
Aws Aws `yaml:"aws"`
|
||||||
} `mapstructure:"object"`
|
} `yaml:"object"`
|
||||||
}
|
}
|
||||||
type Cos struct {
|
type Cos struct {
|
||||||
BucketURL string `mapstructure:"bucketURL"`
|
BucketURL string `yaml:"bucketURL"`
|
||||||
SecretID string `mapstructure:"secretID"`
|
SecretID string `yaml:"secretID"`
|
||||||
SecretKey string `mapstructure:"secretKey"`
|
SecretKey string `yaml:"secretKey"`
|
||||||
SessionToken string `mapstructure:"sessionToken"`
|
SessionToken string `yaml:"sessionToken"`
|
||||||
PublicRead bool `mapstructure:"publicRead"`
|
PublicRead bool `yaml:"publicRead"`
|
||||||
}
|
}
|
||||||
type Oss struct {
|
type Oss struct {
|
||||||
Endpoint string `mapstructure:"endpoint"`
|
Endpoint string `yaml:"endpoint"`
|
||||||
Bucket string `mapstructure:"bucket"`
|
Bucket string `yaml:"bucket"`
|
||||||
BucketURL string `mapstructure:"bucketURL"`
|
BucketURL string `yaml:"bucketURL"`
|
||||||
AccessKeyID string `mapstructure:"accessKeyID"`
|
AccessKeyID string `yaml:"accessKeyID"`
|
||||||
AccessKeySecret string `mapstructure:"accessKeySecret"`
|
AccessKeySecret string `yaml:"accessKeySecret"`
|
||||||
SessionToken string `mapstructure:"sessionToken"`
|
SessionToken string `yaml:"sessionToken"`
|
||||||
PublicRead bool `mapstructure:"publicRead"`
|
PublicRead bool `yaml:"publicRead"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Kodo struct {
|
type Kodo struct {
|
||||||
Endpoint string `mapstructure:"endpoint"`
|
Endpoint string `yaml:"endpoint"`
|
||||||
Bucket string `mapstructure:"bucket"`
|
Bucket string `yaml:"bucket"`
|
||||||
BucketURL string `mapstructure:"bucketURL"`
|
BucketURL string `yaml:"bucketURL"`
|
||||||
AccessKeyID string `mapstructure:"accessKeyID"`
|
AccessKeyID string `yaml:"accessKeyID"`
|
||||||
AccessKeySecret string `mapstructure:"accessKeySecret"`
|
AccessKeySecret string `yaml:"accessKeySecret"`
|
||||||
SessionToken string `mapstructure:"sessionToken"`
|
SessionToken string `yaml:"sessionToken"`
|
||||||
PublicRead bool `mapstructure:"publicRead"`
|
PublicRead bool `yaml:"publicRead"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Aws struct {
|
type Aws struct {
|
||||||
Region string `mapstructure:"region"`
|
Region string `yaml:"region"`
|
||||||
Bucket string `mapstructure:"bucket"`
|
Bucket string `yaml:"bucket"`
|
||||||
AccessKeyID string `mapstructure:"accessKeyID"`
|
AccessKeyID string `yaml:"accessKeyID"`
|
||||||
SecretAccessKey string `mapstructure:"secretAccessKey"`
|
SecretAccessKey string `yaml:"secretAccessKey"`
|
||||||
SessionToken string `mapstructure:"sessionToken"`
|
SessionToken string `yaml:"sessionToken"`
|
||||||
PublicRead bool `mapstructure:"publicRead"`
|
PublicRead bool `yaml:"publicRead"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
RPC struct {
|
RPC struct {
|
||||||
RegisterIP string `mapstructure:"registerIP"`
|
RegisterIP string `yaml:"registerIP"`
|
||||||
ListenIP string `mapstructure:"listenIP"`
|
ListenIP string `yaml:"listenIP"`
|
||||||
AutoSetPorts bool `mapstructure:"autoSetPorts"`
|
AutoSetPorts bool `yaml:"autoSetPorts"`
|
||||||
Ports []int `mapstructure:"ports"`
|
Ports []int `yaml:"ports"`
|
||||||
} `mapstructure:"rpc"`
|
} `yaml:"rpc"`
|
||||||
Prometheus Prometheus `mapstructure:"prometheus"`
|
Prometheus Prometheus `yaml:"prometheus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Redis struct {
|
type Redis struct {
|
||||||
Address []string `mapstructure:"address"`
|
Address []string `yaml:"address"`
|
||||||
Username string `mapstructure:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `yaml:"password"`
|
||||||
ClusterMode bool `mapstructure:"clusterMode"`
|
ClusterMode bool `yaml:"clusterMode"`
|
||||||
DB int `mapstructure:"storage"`
|
DB int `yaml:"storage"`
|
||||||
MaxRetry int `mapstructure:"maxRetry"`
|
MaxRetry int `yaml:"maxRetry"`
|
||||||
PoolSize int `mapstructure:"poolSize"`
|
PoolSize int `yaml:"poolSize"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BeforeConfig struct {
|
type BeforeConfig struct {
|
||||||
Enable bool `mapstructure:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
Timeout int `mapstructure:"timeout"`
|
Timeout int `yaml:"timeout"`
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
FailedContinue bool `yaml:"failedContinue"`
|
||||||
AllowedTypes []string `mapstructure:"allowedTypes"`
|
AllowedTypes []string `yaml:"allowedTypes"`
|
||||||
DeniedTypes []string `mapstructure:"deniedTypes"`
|
DeniedTypes []string `yaml:"deniedTypes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AfterConfig struct {
|
type AfterConfig struct {
|
||||||
Enable bool `mapstructure:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
Timeout int `mapstructure:"timeout"`
|
Timeout int `yaml:"timeout"`
|
||||||
AttentionIds []string `mapstructure:"attentionIds"`
|
AttentionIds []string `yaml:"attentionIds"`
|
||||||
AllowedTypes []string `mapstructure:"allowedTypes"`
|
AllowedTypes []string `yaml:"allowedTypes"`
|
||||||
DeniedTypes []string `mapstructure:"deniedTypes"`
|
DeniedTypes []string `yaml:"deniedTypes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Share struct {
|
type Share struct {
|
||||||
Secret string `mapstructure:"secret"`
|
Secret string `yaml:"secret"`
|
||||||
IMAdminUserID []string `mapstructure:"imAdminUserID"`
|
IMAdminUserID []string `yaml:"imAdminUserID"`
|
||||||
MultiLogin MultiLogin `mapstructure:"multiLogin"`
|
MultiLogin MultiLogin `yaml:"multiLogin"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MultiLogin struct {
|
type MultiLogin struct {
|
||||||
Policy int `mapstructure:"policy"`
|
Policy int `yaml:"policy"`
|
||||||
MaxNumOneEnd int `mapstructure:"maxNumOneEnd"`
|
MaxNumOneEnd int `yaml:"maxNumOneEnd"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RpcService struct {
|
type RpcService struct {
|
||||||
User string `mapstructure:"user"`
|
User string `yaml:"user"`
|
||||||
Friend string `mapstructure:"friend"`
|
Friend string `yaml:"friend"`
|
||||||
Msg string `mapstructure:"msg"`
|
Msg string `yaml:"msg"`
|
||||||
Push string `mapstructure:"push"`
|
Push string `yaml:"push"`
|
||||||
MessageGateway string `mapstructure:"messageGateway"`
|
MessageGateway string `yaml:"messageGateway"`
|
||||||
Group string `mapstructure:"group"`
|
Group string `yaml:"group"`
|
||||||
Auth string `mapstructure:"auth"`
|
Auth string `yaml:"auth"`
|
||||||
Conversation string `mapstructure:"conversation"`
|
Conversation string `yaml:"conversation"`
|
||||||
Third string `mapstructure:"third"`
|
Third string `yaml:"third"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RpcService) GetServiceNames() []string {
|
func (r *RpcService) GetServiceNames() []string {
|
||||||
@ -418,80 +420,80 @@ func (r *RpcService) GetServiceNames() []string {
|
|||||||
|
|
||||||
// FullConfig stores all configurations for before and after events
|
// FullConfig stores all configurations for before and after events
|
||||||
type Webhooks struct {
|
type Webhooks struct {
|
||||||
URL string `mapstructure:"url"`
|
URL string `yaml:"url"`
|
||||||
BeforeSendSingleMsg BeforeConfig `mapstructure:"beforeSendSingleMsg"`
|
BeforeSendSingleMsg BeforeConfig `yaml:"beforeSendSingleMsg"`
|
||||||
BeforeUpdateUserInfoEx BeforeConfig `mapstructure:"beforeUpdateUserInfoEx"`
|
BeforeUpdateUserInfoEx BeforeConfig `yaml:"beforeUpdateUserInfoEx"`
|
||||||
AfterUpdateUserInfoEx AfterConfig `mapstructure:"afterUpdateUserInfoEx"`
|
AfterUpdateUserInfoEx AfterConfig `yaml:"afterUpdateUserInfoEx"`
|
||||||
AfterSendSingleMsg AfterConfig `mapstructure:"afterSendSingleMsg"`
|
AfterSendSingleMsg AfterConfig `yaml:"afterSendSingleMsg"`
|
||||||
BeforeSendGroupMsg BeforeConfig `mapstructure:"beforeSendGroupMsg"`
|
BeforeSendGroupMsg BeforeConfig `yaml:"beforeSendGroupMsg"`
|
||||||
BeforeMsgModify BeforeConfig `mapstructure:"beforeMsgModify"`
|
BeforeMsgModify BeforeConfig `yaml:"beforeMsgModify"`
|
||||||
AfterSendGroupMsg AfterConfig `mapstructure:"afterSendGroupMsg"`
|
AfterSendGroupMsg AfterConfig `yaml:"afterSendGroupMsg"`
|
||||||
AfterUserOnline AfterConfig `mapstructure:"afterUserOnline"`
|
AfterUserOnline AfterConfig `yaml:"afterUserOnline"`
|
||||||
AfterUserOffline AfterConfig `mapstructure:"afterUserOffline"`
|
AfterUserOffline AfterConfig `yaml:"afterUserOffline"`
|
||||||
AfterUserKickOff AfterConfig `mapstructure:"afterUserKickOff"`
|
AfterUserKickOff AfterConfig `yaml:"afterUserKickOff"`
|
||||||
BeforeOfflinePush BeforeConfig `mapstructure:"beforeOfflinePush"`
|
BeforeOfflinePush BeforeConfig `yaml:"beforeOfflinePush"`
|
||||||
BeforeOnlinePush BeforeConfig `mapstructure:"beforeOnlinePush"`
|
BeforeOnlinePush BeforeConfig `yaml:"beforeOnlinePush"`
|
||||||
BeforeGroupOnlinePush BeforeConfig `mapstructure:"beforeGroupOnlinePush"`
|
BeforeGroupOnlinePush BeforeConfig `yaml:"beforeGroupOnlinePush"`
|
||||||
BeforeAddFriend BeforeConfig `mapstructure:"beforeAddFriend"`
|
BeforeAddFriend BeforeConfig `yaml:"beforeAddFriend"`
|
||||||
BeforeUpdateUserInfo BeforeConfig `mapstructure:"beforeUpdateUserInfo"`
|
BeforeUpdateUserInfo BeforeConfig `yaml:"beforeUpdateUserInfo"`
|
||||||
AfterUpdateUserInfo AfterConfig `mapstructure:"afterUpdateUserInfo"`
|
AfterUpdateUserInfo AfterConfig `yaml:"afterUpdateUserInfo"`
|
||||||
BeforeCreateGroup BeforeConfig `mapstructure:"beforeCreateGroup"`
|
BeforeCreateGroup BeforeConfig `yaml:"beforeCreateGroup"`
|
||||||
AfterCreateGroup AfterConfig `mapstructure:"afterCreateGroup"`
|
AfterCreateGroup AfterConfig `yaml:"afterCreateGroup"`
|
||||||
BeforeMemberJoinGroup BeforeConfig `mapstructure:"beforeMemberJoinGroup"`
|
BeforeMemberJoinGroup BeforeConfig `yaml:"beforeMemberJoinGroup"`
|
||||||
BeforeSetGroupMemberInfo BeforeConfig `mapstructure:"beforeSetGroupMemberInfo"`
|
BeforeSetGroupMemberInfo BeforeConfig `yaml:"beforeSetGroupMemberInfo"`
|
||||||
AfterSetGroupMemberInfo AfterConfig `mapstructure:"afterSetGroupMemberInfo"`
|
AfterSetGroupMemberInfo AfterConfig `yaml:"afterSetGroupMemberInfo"`
|
||||||
AfterQuitGroup AfterConfig `mapstructure:"afterQuitGroup"`
|
AfterQuitGroup AfterConfig `yaml:"afterQuitGroup"`
|
||||||
AfterKickGroupMember AfterConfig `mapstructure:"afterKickGroupMember"`
|
AfterKickGroupMember AfterConfig `yaml:"afterKickGroupMember"`
|
||||||
AfterDismissGroup AfterConfig `mapstructure:"afterDismissGroup"`
|
AfterDismissGroup AfterConfig `yaml:"afterDismissGroup"`
|
||||||
BeforeApplyJoinGroup BeforeConfig `mapstructure:"beforeApplyJoinGroup"`
|
BeforeApplyJoinGroup BeforeConfig `yaml:"beforeApplyJoinGroup"`
|
||||||
AfterGroupMsgRead AfterConfig `mapstructure:"afterGroupMsgRead"`
|
AfterGroupMsgRead AfterConfig `yaml:"afterGroupMsgRead"`
|
||||||
AfterSingleMsgRead AfterConfig `mapstructure:"afterSingleMsgRead"`
|
AfterSingleMsgRead AfterConfig `yaml:"afterSingleMsgRead"`
|
||||||
BeforeUserRegister BeforeConfig `mapstructure:"beforeUserRegister"`
|
BeforeUserRegister BeforeConfig `yaml:"beforeUserRegister"`
|
||||||
AfterUserRegister AfterConfig `mapstructure:"afterUserRegister"`
|
AfterUserRegister AfterConfig `yaml:"afterUserRegister"`
|
||||||
AfterTransferGroupOwner AfterConfig `mapstructure:"afterTransferGroupOwner"`
|
AfterTransferGroupOwner AfterConfig `yaml:"afterTransferGroupOwner"`
|
||||||
BeforeSetFriendRemark BeforeConfig `mapstructure:"beforeSetFriendRemark"`
|
BeforeSetFriendRemark BeforeConfig `yaml:"beforeSetFriendRemark"`
|
||||||
AfterSetFriendRemark AfterConfig `mapstructure:"afterSetFriendRemark"`
|
AfterSetFriendRemark AfterConfig `yaml:"afterSetFriendRemark"`
|
||||||
AfterGroupMsgRevoke AfterConfig `mapstructure:"afterGroupMsgRevoke"`
|
AfterGroupMsgRevoke AfterConfig `yaml:"afterGroupMsgRevoke"`
|
||||||
AfterJoinGroup AfterConfig `mapstructure:"afterJoinGroup"`
|
AfterJoinGroup AfterConfig `yaml:"afterJoinGroup"`
|
||||||
BeforeInviteUserToGroup BeforeConfig `mapstructure:"beforeInviteUserToGroup"`
|
BeforeInviteUserToGroup BeforeConfig `yaml:"beforeInviteUserToGroup"`
|
||||||
AfterSetGroupInfo AfterConfig `mapstructure:"afterSetGroupInfo"`
|
AfterSetGroupInfo AfterConfig `yaml:"afterSetGroupInfo"`
|
||||||
BeforeSetGroupInfo BeforeConfig `mapstructure:"beforeSetGroupInfo"`
|
BeforeSetGroupInfo BeforeConfig `yaml:"beforeSetGroupInfo"`
|
||||||
AfterSetGroupInfoEx AfterConfig `mapstructure:"afterSetGroupInfoEx"`
|
AfterSetGroupInfoEx AfterConfig `yaml:"afterSetGroupInfoEx"`
|
||||||
BeforeSetGroupInfoEx BeforeConfig `mapstructure:"beforeSetGroupInfoEx"`
|
BeforeSetGroupInfoEx BeforeConfig `yaml:"beforeSetGroupInfoEx"`
|
||||||
AfterRevokeMsg AfterConfig `mapstructure:"afterRevokeMsg"`
|
AfterRevokeMsg AfterConfig `yaml:"afterRevokeMsg"`
|
||||||
BeforeAddBlack BeforeConfig `mapstructure:"beforeAddBlack"`
|
BeforeAddBlack BeforeConfig `yaml:"beforeAddBlack"`
|
||||||
AfterAddFriend AfterConfig `mapstructure:"afterAddFriend"`
|
AfterAddFriend AfterConfig `yaml:"afterAddFriend"`
|
||||||
BeforeAddFriendAgree BeforeConfig `mapstructure:"beforeAddFriendAgree"`
|
BeforeAddFriendAgree BeforeConfig `yaml:"beforeAddFriendAgree"`
|
||||||
AfterAddFriendAgree AfterConfig `mapstructure:"afterAddFriendAgree"`
|
AfterAddFriendAgree AfterConfig `yaml:"afterAddFriendAgree"`
|
||||||
AfterDeleteFriend AfterConfig `mapstructure:"afterDeleteFriend"`
|
AfterDeleteFriend AfterConfig `yaml:"afterDeleteFriend"`
|
||||||
BeforeImportFriends BeforeConfig `mapstructure:"beforeImportFriends"`
|
BeforeImportFriends BeforeConfig `yaml:"beforeImportFriends"`
|
||||||
AfterImportFriends AfterConfig `mapstructure:"afterImportFriends"`
|
AfterImportFriends AfterConfig `yaml:"afterImportFriends"`
|
||||||
AfterRemoveBlack AfterConfig `mapstructure:"afterRemoveBlack"`
|
AfterRemoveBlack AfterConfig `yaml:"afterRemoveBlack"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ZooKeeper struct {
|
type ZooKeeper struct {
|
||||||
Schema string `mapstructure:"schema"`
|
Schema string `yaml:"schema"`
|
||||||
Address []string `mapstructure:"address"`
|
Address []string `yaml:"address"`
|
||||||
Username string `mapstructure:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `yaml:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Discovery struct {
|
type Discovery struct {
|
||||||
Enable string `mapstructure:"enable"`
|
Enable string `yaml:"enable"`
|
||||||
Etcd Etcd `mapstructure:"etcd"`
|
Etcd Etcd `yaml:"etcd"`
|
||||||
Kubernetes Kubernetes `mapstructure:"kubernetes"`
|
Kubernetes Kubernetes `yaml:"kubernetes"`
|
||||||
RpcService RpcService `mapstructure:"rpcService"`
|
RpcService RpcService `yaml:"rpcService"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Kubernetes struct {
|
type Kubernetes struct {
|
||||||
Namespace string `mapstructure:"namespace"`
|
Namespace string `yaml:"namespace"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Etcd struct {
|
type Etcd struct {
|
||||||
RootDirectory string `mapstructure:"rootDirectory"`
|
RootDirectory string `yaml:"rootDirectory"`
|
||||||
Address []string `mapstructure:"address"`
|
Address []string `yaml:"address"`
|
||||||
Username string `mapstructure:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `yaml:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mongo) Build() *mongoutil.Config {
|
func (m *Mongo) Build() *mongoutil.Config {
|
||||||
@ -783,7 +785,7 @@ func (a *AllConfig) GetConfigNames() []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
const (
|
||||||
FileName = "config.yaml"
|
FileName = "config.yaml"
|
||||||
DiscoveryConfigFilename = "discovery.yml"
|
DiscoveryConfigFilename = "discovery.yml"
|
||||||
KafkaConfigFileName = "kafka.yml"
|
KafkaConfigFileName = "kafka.yml"
|
||||||
|
@ -35,7 +35,7 @@ func loadConfig(path string, envPrefix string, config any) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := v.Unmarshal(config, func(config *mapstructure.DecoderConfig) {
|
if err := v.Unmarshal(config, func(config *mapstructure.DecoderConfig) {
|
||||||
config.TagName = "mapstructure"
|
config.TagName = StructTagName
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return errs.WrapMsg(err, "failed to unmarshal config", "path", path, "envPrefix", envPrefix)
|
return errs.WrapMsg(err, "failed to unmarshal config", "path", path, "envPrefix", envPrefix)
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ import (
|
|||||||
func Start[T any](ctx context.Context, discovery *conf.Discovery, prometheusConfig *conf.Prometheus, listenIP,
|
func Start[T any](ctx context.Context, discovery *conf.Discovery, prometheusConfig *conf.Prometheus, listenIP,
|
||||||
registerIP string, autoSetPorts bool, rpcPorts []int, index int, rpcRegisterName string, notification *conf.Notification, config T,
|
registerIP string, autoSetPorts bool, rpcPorts []int, index int, rpcRegisterName string, notification *conf.Notification, config T,
|
||||||
watchConfigNames []string, watchServiceNames []string,
|
watchConfigNames []string, watchServiceNames []string,
|
||||||
rpcFn func(ctx context.Context, config T, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error,
|
rpcFn func(ctx context.Context, config T, client discovery.Conn, server grpc.ServiceRegistrar) error,
|
||||||
options ...grpc.ServerOption) error {
|
options ...grpc.ServerOption) error {
|
||||||
|
|
||||||
watchConfigNames = append(watchConfigNames, conf.LogConfigFileName)
|
watchConfigNames = append(watchConfigNames, conf.LogConfigFileName)
|
||||||
|
@ -1,134 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"sync"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/openimsdk/protocol/group"
|
|
||||||
"github.com/openimsdk/protocol/user"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ user.UnimplementedUserServer
|
|
||||||
_ group.UnimplementedGroupServer
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestName1(t *testing.T) {
|
|
||||||
cc := newStandaloneConn()
|
|
||||||
user.RegisterUserServer(cc.Registry(), &user.UnimplementedUserServer{})
|
|
||||||
group.RegisterGroupServer(cc.Registry(), &group.UnimplementedGroupServer{})
|
|
||||||
ctx := context.Background()
|
|
||||||
resp, err := user.NewUserClient(cc).GetUserStatus(ctx, &user.GetUserStatusReq{UserID: "imAdmin", UserIDs: []string{"10000", "20000"}})
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Log(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func newStandaloneConn() *standaloneConn {
|
|
||||||
return &standaloneConn{
|
|
||||||
registry: newStandaloneRegistry(),
|
|
||||||
serializer: NewProtoSerializer(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type standaloneConn struct {
|
|
||||||
registry *standaloneRegistry
|
|
||||||
serializer Serializer
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *standaloneConn) Registry() grpc.ServiceRegistrar {
|
|
||||||
return x.registry
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *standaloneConn) Invoke(ctx context.Context, method string, args any, reply any, opts ...grpc.CallOption) error {
|
|
||||||
handler := x.registry.getMethod(method)
|
|
||||||
if handler == nil {
|
|
||||||
return fmt.Errorf("service %s not found", method)
|
|
||||||
}
|
|
||||||
resp, err := handler(ctx, args, nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
tmp, err := x.serializer.Marshal(resp)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return x.serializer.Unmarshal(tmp, reply)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *standaloneConn) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method stream not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
type serverHandler func(ctx context.Context, req any, interceptor grpc.UnaryServerInterceptor) (any, error)
|
|
||||||
|
|
||||||
func newStandaloneRegistry() *standaloneRegistry {
|
|
||||||
return &standaloneRegistry{
|
|
||||||
methods: make(map[string]serverHandler),
|
|
||||||
serializer: NewProtoSerializer(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type standaloneRegistry struct {
|
|
||||||
lock sync.RWMutex
|
|
||||||
methods map[string]serverHandler
|
|
||||||
serializer Serializer
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *standaloneConn) emptyDec(req any) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *standaloneRegistry) RegisterService(desc *grpc.ServiceDesc, impl any) {
|
|
||||||
x.lock.Lock()
|
|
||||||
defer x.lock.Unlock()
|
|
||||||
for i := range desc.Methods {
|
|
||||||
method := desc.Methods[i]
|
|
||||||
name := fmt.Sprintf("/%s/%s", desc.ServiceName, method.MethodName)
|
|
||||||
if _, ok := x.methods[name]; ok {
|
|
||||||
panic(fmt.Errorf("service %s already registered, method %s", desc.ServiceName, method.MethodName))
|
|
||||||
}
|
|
||||||
x.methods[name] = func(ctx context.Context, req any, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
|
||||||
return method.Handler(impl, ctx, func(in any) error {
|
|
||||||
tmp, err := x.serializer.Marshal(req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return x.serializer.Unmarshal(tmp, in)
|
|
||||||
}, interceptor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *standaloneRegistry) getMethod(name string) serverHandler {
|
|
||||||
x.lock.RLock()
|
|
||||||
defer x.lock.RUnlock()
|
|
||||||
return x.methods[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
type Serializer interface {
|
|
||||||
Marshal(any) ([]byte, error)
|
|
||||||
Unmarshal([]byte, any) error
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewProtoSerializer() Serializer {
|
|
||||||
return protoSerializer{}
|
|
||||||
}
|
|
||||||
|
|
||||||
type protoSerializer struct{}
|
|
||||||
|
|
||||||
func (protoSerializer) Marshal(in any) ([]byte, error) {
|
|
||||||
return proto.Marshal(in.(proto.Message))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (protoSerializer) Unmarshal(b []byte, out any) error {
|
|
||||||
return proto.Unmarshal(b, out.(proto.Message))
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
//
|
|
||||||
//import (
|
|
||||||
// "context"
|
|
||||||
// "fmt"
|
|
||||||
// "sync"
|
|
||||||
//
|
|
||||||
// "google.golang.org/grpc"
|
|
||||||
//)
|
|
||||||
//
|
|
||||||
//type DiscoveryRegistry struct {
|
|
||||||
// lock sync.RWMutex
|
|
||||||
// services map[string]grpc.ClientConnInterface
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (x *DiscoveryRegistry) RegisterService(desc *grpc.ServiceDesc, impl any) {
|
|
||||||
// fmt.Println("RegisterService", desc, impl)
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (x *DiscoveryRegistry) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]grpc.ClientConnInterface, error) {
|
|
||||||
// //TODO implement me
|
|
||||||
// panic("implement me")
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (x *DiscoveryRegistry) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (grpc.ClientConnInterface, error) {
|
|
||||||
// //TODO implement me
|
|
||||||
// panic("implement me")
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (x *DiscoveryRegistry) IsSelfNode(cc grpc.ClientConnInterface) bool {
|
|
||||||
//
|
|
||||||
// return false
|
|
||||||
//}
|
|
@ -1,14 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GrpcServer struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GrpcServer) RegisterService(desc *grpc.ServiceDesc, impl any) {
|
|
||||||
fmt.Println("RegisterService", desc, impl)
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user