From eaeb342b0ec9590790adecd4722e471465c7754d Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Wed, 26 Jul 2023 16:56:25 +0800 Subject: [PATCH] chore: package path changes Signed-off-by: withchao <993506633@qq.com> --- cmd/openim-api/main.go | 4 +- cmd/openim-push/main.go | 2 +- cmd/openim-rpc/openim-rpc-auth/main.go | 2 +- .../openim-rpc-conversation/main.go | 2 +- cmd/openim-rpc/openim-rpc-friend/main.go | 2 +- cmd/openim-rpc/openim-rpc-group/main.go | 2 +- cmd/openim-rpc/openim-rpc-msg/main.go | 2 +- cmd/openim-rpc/openim-rpc-third/main.go | 2 +- cmd/openim-rpc/openim-rpc-user/main.go | 2 +- go.mod | 7 +- go.sum | 2 + internal/api/custom_validator.go | 2 +- internal/api/msg.go | 2 +- internal/api/route.go | 4 +- internal/api/user.go | 4 +- internal/msggateway/callback.go | 4 +- internal/msggateway/client.go | 2 +- internal/msggateway/context.go | 2 +- internal/msggateway/hub_server.go | 6 +- internal/msggateway/init.go | 2 +- internal/msggateway/n_ws_server.go | 4 +- internal/msgtransfer/init.go | 2 +- .../msgtransfer/online_history_msg_handler.go | 4 +- .../online_msg_to_mongo_handler.go | 2 +- .../msgtransfer/persistent_msg_handler.go | 4 +- internal/push/callback.go | 4 +- internal/push/offlinepush/fcm/push.go | 4 +- internal/push/offlinepush/getui/body.go | 2 +- internal/push/offlinepush/getui/push.go | 2 +- .../offlinepush/jpush/body/notification.go | 2 +- .../push/offlinepush/jpush/body/platform.go | 2 +- internal/push/offlinepush/jpush/push.go | 2 +- internal/push/push_handler.go | 4 +- internal/push/push_rpc_server.go | 2 +- internal/push/push_to_client.go | 4 +- internal/push/tools.go | 2 +- internal/rpc/auth/auth.go | 4 +- internal/rpc/conversation/conversaion.go | 2 +- internal/rpc/friend/callback.go | 4 +- internal/rpc/friend/friend.go | 2 +- internal/rpc/group/callback.go | 4 +- internal/rpc/group/group.go | 2 +- internal/rpc/group/super_group.go | 2 +- internal/rpc/msg/as_read.go | 2 +- internal/rpc/msg/callback.go | 4 +- internal/rpc/msg/delete.go | 2 +- internal/rpc/msg/message_interceptor.go | 4 +- internal/rpc/msg/msg_status.go | 2 +- internal/rpc/msg/revoke.go | 2 +- internal/rpc/msg/send.go | 2 +- internal/rpc/msg/server.go | 2 +- internal/rpc/msg/sync_msg.go | 2 +- internal/rpc/msg/utils.go | 4 +- internal/rpc/msg/verify.go | 4 +- internal/rpc/third/third.go | 2 +- internal/rpc/user/user.go | 4 +- internal/tools/cron_task.go | 2 +- internal/tools/msg.go | 2 +- internal/tools/msg_test.go | 2 +- pkg/common/cmd/msg_gateway.go | 2 +- pkg/common/cmd/root.go | 6 +- pkg/common/cmd/rpc.go | 2 +- pkg/common/config/config.go | 333 ++++++++++++++++++ pkg/common/config/parse.go | 15 +- pkg/common/db/cache/init_redis.go | 2 +- pkg/common/db/cache/msg.go | 4 +- pkg/common/db/controller/auth.go | 2 +- pkg/common/db/controller/conversation.go | 2 +- pkg/common/db/controller/friend.go | 2 +- pkg/common/db/controller/group.go | 2 +- pkg/common/db/controller/msg.go | 2 +- pkg/common/db/controller/msg_test.go | 4 +- pkg/common/db/relation/chat_log_model.go | 2 +- pkg/common/db/relation/conversation_model.go | 2 +- pkg/common/db/relation/group_member_model.go | 2 +- pkg/common/db/relation/group_model.go | 2 +- pkg/common/db/relation/mysql_init.go | 2 +- pkg/common/db/s3/cos/cos.go | 2 +- pkg/common/db/s3/minio/minio.go | 2 +- pkg/common/db/s3/oss/oss.go | 2 +- pkg/common/db/unrelation/mongo.go | 2 +- pkg/common/db/unrelation/msg.go | 2 +- pkg/common/http/http_client.go | 4 +- pkg/common/kafka/consumer.go | 2 +- pkg/common/kafka/producer.go | 4 +- pkg/common/prome/prometheus.go | 2 +- pkg/common/startrpc/start.go | 111 ++++++ pkg/rpcclient/auth.go | 2 +- pkg/rpcclient/conversation.go | 2 +- pkg/rpcclient/friend.go | 2 +- pkg/rpcclient/group.go | 4 +- pkg/rpcclient/msg.go | 4 +- pkg/rpcclient/notification/conevrsation.go | 2 +- pkg/rpcclient/notification/friend.go | 2 +- pkg/rpcclient/notification/group.go | 2 +- pkg/rpcclient/notification/msg.go | 2 +- pkg/rpcclient/push.go | 2 +- pkg/rpcclient/third.go | 2 +- pkg/rpcclient/user.go | 2 +- 99 files changed, 580 insertions(+), 134 deletions(-) create mode 100644 pkg/common/config/config.go create mode 100644 pkg/common/startrpc/start.go diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index c967906e9..8350f4d05 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -28,9 +28,9 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/internal/api" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/discoveryregistry" openKeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper" "github.com/OpenIMSDK/tools/log" diff --git a/cmd/openim-push/main.go b/cmd/openim-push/main.go index adc3a7cb7..03db8ae03 100644 --- a/cmd/openim-push/main.go +++ b/cmd/openim-push/main.go @@ -17,7 +17,7 @@ package main import ( "github.com/OpenIMSDK/Open-IM-Server/internal/push" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) func main() { diff --git a/cmd/openim-rpc/openim-rpc-auth/main.go b/cmd/openim-rpc/openim-rpc-auth/main.go index 62bb65fab..524804988 100644 --- a/cmd/openim-rpc/openim-rpc-auth/main.go +++ b/cmd/openim-rpc/openim-rpc-auth/main.go @@ -17,7 +17,7 @@ package main import ( "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/auth" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) func main() { diff --git a/cmd/openim-rpc/openim-rpc-conversation/main.go b/cmd/openim-rpc/openim-rpc-conversation/main.go index 0465de868..fec8226f8 100644 --- a/cmd/openim-rpc/openim-rpc-conversation/main.go +++ b/cmd/openim-rpc/openim-rpc-conversation/main.go @@ -17,7 +17,7 @@ package main import ( "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/conversation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) func main() { diff --git a/cmd/openim-rpc/openim-rpc-friend/main.go b/cmd/openim-rpc/openim-rpc-friend/main.go index 7a0631a20..fbd44038e 100644 --- a/cmd/openim-rpc/openim-rpc-friend/main.go +++ b/cmd/openim-rpc/openim-rpc-friend/main.go @@ -17,7 +17,7 @@ package main import ( "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/friend" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) func main() { diff --git a/cmd/openim-rpc/openim-rpc-group/main.go b/cmd/openim-rpc/openim-rpc-group/main.go index af78868d2..06baac155 100644 --- a/cmd/openim-rpc/openim-rpc-group/main.go +++ b/cmd/openim-rpc/openim-rpc-group/main.go @@ -17,7 +17,7 @@ package main import ( "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/group" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) func main() { diff --git a/cmd/openim-rpc/openim-rpc-msg/main.go b/cmd/openim-rpc/openim-rpc-msg/main.go index 6bdd4842d..356081d33 100644 --- a/cmd/openim-rpc/openim-rpc-msg/main.go +++ b/cmd/openim-rpc/openim-rpc-msg/main.go @@ -17,7 +17,7 @@ package main import ( "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/msg" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) func main() { diff --git a/cmd/openim-rpc/openim-rpc-third/main.go b/cmd/openim-rpc/openim-rpc-third/main.go index 2136bc157..c070e6811 100644 --- a/cmd/openim-rpc/openim-rpc-third/main.go +++ b/cmd/openim-rpc/openim-rpc-third/main.go @@ -17,7 +17,7 @@ package main import ( "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/third" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) func main() { diff --git a/cmd/openim-rpc/openim-rpc-user/main.go b/cmd/openim-rpc/openim-rpc-user/main.go index 16a24c812..6d6d9008d 100644 --- a/cmd/openim-rpc/openim-rpc-user/main.go +++ b/cmd/openim-rpc/openim-rpc-user/main.go @@ -17,7 +17,7 @@ package main import ( "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/user" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) func main() { diff --git a/go.mod b/go.mod index db50056c4..8f9474ca9 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( require github.com/google/uuid v1.3.0 require ( - github.com/OpenIMSDK/protocol v0.0.0-20230725064305-11f0568fe5e9 + github.com/OpenIMSDK/protocol v0.0.1 github.com/OpenIMSDK/tools v0.0.1 github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible github.com/go-redis/redis v6.15.9+incompatible @@ -140,3 +140,8 @@ require ( google.golang.org/genproto v0.0.0-20230525234025-438c736192d0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) + + +replace ( + github.com/OpenIMSDK/tools => C:\Users\Admin\Desktop\tools +) \ No newline at end of file diff --git a/go.sum b/go.sum index 0c585411e..b4e27d6a1 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,8 @@ firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIw github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/OpenIMSDK/protocol v0.0.0-20230725064305-11f0568fe5e9 h1:ZtW+z2j2kjk51awH9OFRXbgNI5Vcfq0Lu9//ax86ktc= github.com/OpenIMSDK/protocol v0.0.0-20230725064305-11f0568fe5e9/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= +github.com/OpenIMSDK/protocol v0.0.1 h1:Q6J1jCU00dfqmguxw2XI+IGcVfBAkb5Tz8LgvyeNkk0= +github.com/OpenIMSDK/protocol v0.0.1/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= github.com/OpenIMSDK/tools v0.0.1 h1:lxTzjv0vOCH890K9C5LxMq3UCvioDMw0ZZQQtioauuI= github.com/OpenIMSDK/tools v0.0.1/go.mod h1:/iSkny1+7i4Z09yddGa4o4fTu9dzJdOLxxe4pWuqI1A= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= diff --git a/internal/api/custom_validator.go b/internal/api/custom_validator.go index 7425ecb38..8c5890501 100644 --- a/internal/api/custom_validator.go +++ b/internal/api/custom_validator.go @@ -17,7 +17,7 @@ package api import ( "github.com/go-playground/validator/v10" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" ) func RequiredIf(fl validator.FieldLevel) bool { diff --git a/internal/api/msg.go b/internal/api/msg.go index d79be716b..f98cdef89 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -22,11 +22,11 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/tools/a2r" "github.com/OpenIMSDK/tools/apiresp" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/tokenverify" diff --git a/internal/api/route.go b/internal/api/route.go index 453224263..ee7a9493c 100644 --- a/internal/api/route.go +++ b/internal/api/route.go @@ -18,8 +18,8 @@ import ( "context" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/apiresp" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/tokenverify" "net/http" @@ -31,9 +31,9 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mw" diff --git a/internal/api/user.go b/internal/api/user.go index c7bcf7862..8595b3501 100644 --- a/internal/api/user.go +++ b/internal/api/user.go @@ -17,13 +17,13 @@ package api import ( "github.com/gin-gonic/gin" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msggateway" "github.com/OpenIMSDK/protocol/user" "github.com/OpenIMSDK/tools/a2r" "github.com/OpenIMSDK/tools/apiresp" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" ) diff --git a/internal/msggateway/callback.go b/internal/msggateway/callback.go index 530c18102..5ede3c854 100644 --- a/internal/msggateway/callback.go +++ b/internal/msggateway/callback.go @@ -19,9 +19,9 @@ import ( "time" cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/mcontext" ) diff --git a/internal/msggateway/client.go b/internal/msggateway/client.go index bc5fa1511..ef6df3e4f 100644 --- a/internal/msggateway/client.go +++ b/internal/msggateway/client.go @@ -23,9 +23,9 @@ import ( "google.golang.org/protobuf/proto" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/tools/apiresp" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" diff --git a/internal/msggateway/context.go b/internal/msggateway/context.go index 672ba1dbe..601c28a34 100644 --- a/internal/msggateway/context.go +++ b/internal/msggateway/context.go @@ -19,7 +19,7 @@ import ( "strconv" "time" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/utils" ) diff --git a/internal/msggateway/hub_server.go b/internal/msggateway/hub_server.go index dc440a7c8..62b5b200c 100644 --- a/internal/msggateway/hub_server.go +++ b/internal/msggateway/hub_server.go @@ -23,13 +23,13 @@ import ( "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/startrpc" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msggateway" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/log" - "github.com/OpenIMSDK/tools/startrpc" "github.com/OpenIMSDK/tools/utils" ) diff --git a/internal/msggateway/init.go b/internal/msggateway/init.go index 96dc4b89b..03fe9f581 100644 --- a/internal/msggateway/init.go +++ b/internal/msggateway/init.go @@ -18,7 +18,7 @@ import ( "fmt" "time" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error { diff --git a/internal/msggateway/n_ws_server.go b/internal/msggateway/n_ws_server.go index 9715f21b6..d19e23b83 100644 --- a/internal/msggateway/n_ws_server.go +++ b/internal/msggateway/n_ws_server.go @@ -23,9 +23,9 @@ import ( "sync/atomic" "time" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/redis/go-redis/v9" diff --git a/internal/msgtransfer/init.go b/internal/msgtransfer/init.go index 037564f7a..d54e81240 100644 --- a/internal/msgtransfer/init.go +++ b/internal/msgtransfer/init.go @@ -22,6 +22,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation" @@ -29,7 +30,6 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" - "github.com/OpenIMSDK/tools/config" openKeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mw" diff --git a/internal/msgtransfer/online_history_msg_handler.go b/internal/msgtransfer/online_history_msg_handler.go index 19121334a..17a310fb3 100644 --- a/internal/msgtransfer/online_history_msg_handler.go +++ b/internal/msgtransfer/online_history_msg_handler.go @@ -27,12 +27,12 @@ import ( "github.com/go-redis/redis" "google.golang.org/protobuf/proto" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" diff --git a/internal/msgtransfer/online_msg_to_mongo_handler.go b/internal/msgtransfer/online_msg_to_mongo_handler.go index 9ba4cb7b9..4a8b5e63e 100644 --- a/internal/msgtransfer/online_msg_to_mongo_handler.go +++ b/internal/msgtransfer/online_msg_to_mongo_handler.go @@ -20,10 +20,10 @@ import ( "github.com/Shopify/sarama" "google.golang.org/protobuf/proto" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka" pbMsg "github.com/OpenIMSDK/protocol/msg" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/log" ) diff --git a/internal/msgtransfer/persistent_msg_handler.go b/internal/msgtransfer/persistent_msg_handler.go index 7256a3442..b67e07cc0 100644 --- a/internal/msgtransfer/persistent_msg_handler.go +++ b/internal/msgtransfer/persistent_msg_handler.go @@ -17,11 +17,11 @@ package msgtransfer import ( "context" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka" + "github.com/OpenIMSDK/protocol/constant" pbMsg "github.com/OpenIMSDK/protocol/msg" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/utils" diff --git a/internal/push/callback.go b/internal/push/callback.go index bbc392a6e..d5e678301 100644 --- a/internal/push/callback.go +++ b/internal/push/callback.go @@ -18,10 +18,10 @@ import ( "context" "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" diff --git a/internal/push/offlinepush/fcm/push.go b/internal/push/offlinepush/fcm/push.go index 8f29f0258..cea90f865 100644 --- a/internal/push/offlinepush/fcm/push.go +++ b/internal/push/offlinepush/fcm/push.go @@ -25,9 +25,9 @@ import ( "google.golang.org/api/option" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" ) const SinglePushCountLimit = 400 diff --git a/internal/push/offlinepush/getui/body.go b/internal/push/offlinepush/getui/body.go index 43fcc84cc..915c6f603 100644 --- a/internal/push/offlinepush/getui/body.go +++ b/internal/push/offlinepush/getui/body.go @@ -17,7 +17,7 @@ package getui import ( "fmt" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) type Resp struct { diff --git a/internal/push/offlinepush/getui/push.go b/internal/push/offlinepush/getui/push.go index b440ef71b..a2f887a41 100644 --- a/internal/push/offlinepush/getui/push.go +++ b/internal/push/offlinepush/getui/push.go @@ -26,9 +26,9 @@ import ( "github.com/go-redis/redis" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" http2 "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" diff --git a/internal/push/offlinepush/jpush/body/notification.go b/internal/push/offlinepush/jpush/body/notification.go index 85581cb1f..cec725784 100644 --- a/internal/push/offlinepush/jpush/body/notification.go +++ b/internal/push/offlinepush/jpush/body/notification.go @@ -15,7 +15,7 @@ package body import ( - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) type Notification struct { diff --git a/internal/push/offlinepush/jpush/body/platform.go b/internal/push/offlinepush/jpush/body/platform.go index c779c8bdc..9de2b8711 100644 --- a/internal/push/offlinepush/jpush/body/platform.go +++ b/internal/push/offlinepush/jpush/body/platform.go @@ -17,7 +17,7 @@ package body import ( "errors" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" ) const ( diff --git a/internal/push/offlinepush/jpush/push.go b/internal/push/offlinepush/jpush/push.go index d661daee9..64933db50 100644 --- a/internal/push/offlinepush/jpush/push.go +++ b/internal/push/offlinepush/jpush/push.go @@ -21,8 +21,8 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush/jpush/body" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" http2 "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http" - "github.com/OpenIMSDK/tools/config" ) type JPush struct{} diff --git a/internal/push/push_handler.go b/internal/push/push_handler.go index f0a67faac..8e307c360 100644 --- a/internal/push/push_handler.go +++ b/internal/push/push_handler.go @@ -20,11 +20,11 @@ import ( "github.com/Shopify/sarama" "google.golang.org/protobuf/proto" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka" + "github.com/OpenIMSDK/protocol/constant" pbChat "github.com/OpenIMSDK/protocol/msg" pbPush "github.com/OpenIMSDK/protocol/push" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/utils" ) diff --git a/internal/push/push_rpc_server.go b/internal/push/push_rpc_server.go index dfcf07469..965f890a5 100644 --- a/internal/push/push_rpc_server.go +++ b/internal/push/push_rpc_server.go @@ -24,8 +24,8 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/localcache" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" + "github.com/OpenIMSDK/protocol/constant" pbPush "github.com/OpenIMSDK/protocol/push" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/log" ) diff --git a/internal/push/push_to_client.go b/internal/push/push_to_client.go index de6b78782..031fdc188 100644 --- a/internal/push/push_to_client.go +++ b/internal/push/push_to_client.go @@ -23,15 +23,15 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush/fcm" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush/getui" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush/jpush" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/localcache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msggateway" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" diff --git a/internal/push/tools.go b/internal/push/tools.go index ea8d160b1..2135c901e 100644 --- a/internal/push/tools.go +++ b/internal/push/tools.go @@ -1,8 +1,8 @@ package push import ( + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" "google.golang.org/protobuf/proto" ) diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index 48e4e5922..f89ba263d 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -19,13 +19,13 @@ import ( "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" pbAuth "github.com/OpenIMSDK/protocol/auth" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msggateway" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" diff --git a/internal/rpc/conversation/conversaion.go b/internal/rpc/conversation/conversaion.go index e27756749..3d6235149 100644 --- a/internal/rpc/conversation/conversaion.go +++ b/internal/rpc/conversation/conversaion.go @@ -26,8 +26,8 @@ import ( tableRelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" + "github.com/OpenIMSDK/protocol/constant" pbConversation "github.com/OpenIMSDK/protocol/conversation" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" diff --git a/internal/rpc/friend/callback.go b/internal/rpc/friend/callback.go index d3a793a6f..bd7716090 100644 --- a/internal/rpc/friend/callback.go +++ b/internal/rpc/friend/callback.go @@ -18,10 +18,10 @@ import ( "context" cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http" + "github.com/OpenIMSDK/protocol/constant" pbfriend "github.com/OpenIMSDK/protocol/friend" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mcontext" ) diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 5792fdb38..8ab2a9267 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -28,8 +28,8 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation" tablerelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" + "github.com/OpenIMSDK/protocol/constant" pbfriend "github.com/OpenIMSDK/protocol/friend" - "github.com/OpenIMSDK/tools/constant" registry "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/tokenverify" diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index 2f85a6674..72661d16b 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -20,12 +20,12 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct" "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/group" "github.com/OpenIMSDK/protocol/wrapperspb" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 4c041e13a..bbf09e13d 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -39,9 +39,9 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation" relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation" + "github.com/OpenIMSDK/protocol/constant" pbGroup "github.com/OpenIMSDK/protocol/group" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" diff --git a/internal/rpc/group/super_group.go b/internal/rpc/group/super_group.go index bdd810ba9..070e154bc 100644 --- a/internal/rpc/group/super_group.go +++ b/internal/rpc/group/super_group.go @@ -22,9 +22,9 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation" + "github.com/OpenIMSDK/protocol/constant" pbGroup "github.com/OpenIMSDK/protocol/group" sdkws "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/utils" ) diff --git a/internal/rpc/msg/as_read.go b/internal/rpc/msg/as_read.go index c2f07bd8e..d17b2b43a 100644 --- a/internal/rpc/msg/as_read.go +++ b/internal/rpc/msg/as_read.go @@ -19,9 +19,9 @@ import ( "github.com/redis/go-redis/v9" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" ) diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go index 47bd1f0f1..5ed6a5f09 100644 --- a/internal/rpc/msg/callback.go +++ b/internal/rpc/msg/callback.go @@ -20,10 +20,10 @@ import ( "google.golang.org/protobuf/proto" cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http" + "github.com/OpenIMSDK/protocol/constant" pbChat "github.com/OpenIMSDK/protocol/msg" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" diff --git a/internal/rpc/msg/delete.go b/internal/rpc/msg/delete.go index 8c20a5bc3..1523beb73 100644 --- a/internal/rpc/msg/delete.go +++ b/internal/rpc/msg/delete.go @@ -17,10 +17,10 @@ package msg import ( "context" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/conversation" "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/tokenverify" "github.com/OpenIMSDK/tools/utils" diff --git a/internal/rpc/msg/message_interceptor.go b/internal/rpc/msg/message_interceptor.go index 915a04ab1..3c8bf965d 100644 --- a/internal/rpc/msg/message_interceptor.go +++ b/internal/rpc/msg/message_interceptor.go @@ -17,10 +17,10 @@ package msg import ( "context" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" ) diff --git a/internal/rpc/msg/msg_status.go b/internal/rpc/msg/msg_status.go index bd89d61f4..68d6d6d4e 100644 --- a/internal/rpc/msg/msg_status.go +++ b/internal/rpc/msg/msg_status.go @@ -17,8 +17,8 @@ package msg import ( "context" + "github.com/OpenIMSDK/protocol/constant" pbMsg "github.com/OpenIMSDK/protocol/msg" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/mcontext" ) diff --git a/internal/rpc/msg/revoke.go b/internal/rpc/msg/revoke.go index 5651e79e0..de86c540f 100644 --- a/internal/rpc/msg/revoke.go +++ b/internal/rpc/msg/revoke.go @@ -20,9 +20,9 @@ import ( "time" unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/tokenverify" diff --git a/internal/rpc/msg/send.go b/internal/rpc/msg/send.go index 2c5df6408..b3a122bb6 100644 --- a/internal/rpc/msg/send.go +++ b/internal/rpc/msg/send.go @@ -18,11 +18,11 @@ import ( "context" promePkg "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" + "github.com/OpenIMSDK/protocol/constant" pbConversation "github.com/OpenIMSDK/protocol/conversation" pbMsg "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/wrapperspb" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index 542f59d4b..fe795e0eb 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -25,9 +25,9 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/conversation" "github.com/OpenIMSDK/protocol/msg" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/discoveryregistry" ) diff --git a/internal/rpc/msg/sync_msg.go b/internal/rpc/msg/sync_msg.go index edcb4ff89..7ae25f6cc 100644 --- a/internal/rpc/msg/sync_msg.go +++ b/internal/rpc/msg/sync_msg.go @@ -17,8 +17,8 @@ package msg import ( "context" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msg" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/tools/log" diff --git a/internal/rpc/msg/utils.go b/internal/rpc/msg/utils.go index 48f7b03f3..1579bcbef 100644 --- a/internal/rpc/msg/utils.go +++ b/internal/rpc/msg/utils.go @@ -18,9 +18,9 @@ import ( "github.com/redis/go-redis/v9" "gorm.io/gorm" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/utils" ) diff --git a/internal/rpc/msg/verify.go b/internal/rpc/msg/verify.go index 32c05ec82..c588d6cf7 100644 --- a/internal/rpc/msg/verify.go +++ b/internal/rpc/msg/verify.go @@ -20,10 +20,10 @@ import ( "strconv" "time" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/utils" ) diff --git a/internal/rpc/third/third.go b/internal/rpc/third/third.go index 5db6c39e4..555e9371c 100644 --- a/internal/rpc/third/third.go +++ b/internal/rpc/third/third.go @@ -27,13 +27,13 @@ import ( "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation" relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/protocol/third" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/discoveryregistry" ) diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 65e977274..3961f1ce0 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -22,6 +22,7 @@ import ( "github.com/OpenIMSDK/tools/log" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" @@ -29,10 +30,9 @@ import ( tablerelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/sdkws" pbuser "github.com/OpenIMSDK/protocol/user" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" registry "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/tokenverify" diff --git a/internal/tools/cron_task.go b/internal/tools/cron_task.go index 354682f8e..a7333a5d4 100644 --- a/internal/tools/cron_task.go +++ b/internal/tools/cron_task.go @@ -21,7 +21,7 @@ import ( "github.com/robfig/cron/v3" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/tools/log" ) diff --git a/internal/tools/msg.go b/internal/tools/msg.go index 8e67bc350..972877516 100644 --- a/internal/tools/msg.go +++ b/internal/tools/msg.go @@ -24,13 +24,13 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" diff --git a/internal/tools/msg_test.go b/internal/tools/msg_test.go index f4ce4d054..13ac4f97f 100644 --- a/internal/tools/msg_test.go +++ b/internal/tools/msg_test.go @@ -21,7 +21,7 @@ import ( "go.mongodb.org/mongo-driver/bson" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" diff --git a/pkg/common/cmd/msg_gateway.go b/pkg/common/cmd/msg_gateway.go index f7b7a03ea..aae63351d 100644 --- a/pkg/common/cmd/msg_gateway.go +++ b/pkg/common/cmd/msg_gateway.go @@ -19,7 +19,7 @@ import ( //"github.com/OpenIMSDK/Open-IM-Server/internal/msggateway". "github.com/spf13/cobra" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" ) type MsgGatewayCmd struct { diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go index 718d9bf7b..39865b9f8 100644 --- a/pkg/common/cmd/root.go +++ b/pkg/common/cmd/root.go @@ -20,8 +20,8 @@ import ( "github.com/spf13/cobra" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/log" ) @@ -65,7 +65,7 @@ func NewRootCmd(name string, opts ...func(*CmdOpts)) (rootCmd *RootCmd) { if cmdOpts.loggerPrefixName == "" { cmdOpts.loggerPrefixName = "OpenIM.log.all" } - if err := log.InitFromConfig(cmdOpts.loggerPrefixName, name, config.Config.Log.RemainLogLevel, config.Config.Log.IsStdout, config.Config.Log.IsJson, config.Config.Log.StorageLocation, config.Config.Log.RemainRotationCount); err != nil { + if err := log.InitFromConfig(cmdOpts.loggerPrefixName, name, config.Config.Log.RemainLogLevel, config.Config.Log.IsStdout, config.Config.Log.IsJson, config.Config.Log.StorageLocation, config.Config.Log.RemainRotationCount, config.Config.Log.RotationTime); err != nil { panic(err) } return nil diff --git a/pkg/common/cmd/rpc.go b/pkg/common/cmd/rpc.go index a2fbea34c..9a00353be 100644 --- a/pkg/common/cmd/rpc.go +++ b/pkg/common/cmd/rpc.go @@ -20,8 +20,8 @@ import ( "github.com/spf13/cobra" "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/startrpc" "github.com/OpenIMSDK/tools/discoveryregistry" - "github.com/OpenIMSDK/tools/startrpc" ) type RpcCmd struct { diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go new file mode 100644 index 000000000..1e0bbba16 --- /dev/null +++ b/pkg/common/config/config.go @@ -0,0 +1,333 @@ +// Copyright © 2023 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package config + +import ( + "bytes" + "github.com/OpenIMSDK/tools/discoveryregistry" + "gopkg.in/yaml.v3" +) + +var Config configStruct + +const ConfKey = "conf" + +type CallBackConfig struct { + Enable bool `yaml:"enable"` + CallbackTimeOut int `yaml:"timeout"` + CallbackFailedContinue *bool `yaml:"failedContinue"` +} + +type NotificationConf struct { + IsSendMsg bool `yaml:"isSendMsg"` + ReliabilityLevel int `yaml:"reliabilityLevel"` // 1 online 2 persistent + UnreadCount bool `yaml:"unreadCount"` + OfflinePush POfflinePush `yaml:"offlinePush"` +} + +type POfflinePush struct { + Enable bool `yaml:"enable"` + Title string `yaml:"title"` + Desc string `yaml:"desc"` + Ext string `yaml:"ext"` +} + +type configStruct struct { + Zookeeper struct { + Schema string `yaml:"schema"` + ZkAddr []string `yaml:"address"` + Username string `yaml:"username"` + Password string `yaml:"password"` + } `yaml:"zookeeper"` + + Mysql struct { + Address []string `yaml:"address"` + Username string `yaml:"username"` + Password string `yaml:"password"` + Database string `yaml:"database"` + MaxOpenConn int `yaml:"maxOpenConn"` + MaxIdleConn int `yaml:"maxIdleConn"` + MaxLifeTime int `yaml:"maxLifeTime"` + LogLevel int `yaml:"logLevel"` + SlowThreshold int `yaml:"slowThreshold"` + } `yaml:"mysql"` + + Mongo struct { + Uri string `yaml:"uri"` + Address []string `yaml:"address"` + Database string `yaml:"database"` + Username string `yaml:"username"` + Password string `yaml:"password"` + MaxPoolSize int `yaml:"maxPoolSize"` + } `yaml:"mongo"` + + Redis struct { + Address []string `yaml:"address"` + Username string `yaml:"username"` + Password string `yaml:"password"` + } `yaml:"redis"` + + Kafka struct { + Username string `yaml:"username"` + Password string `yaml:"password"` + Addr []string `yaml:"addr"` + LatestMsgToRedis struct { + Topic string `yaml:"topic"` + } `yaml:"latestMsgToRedis"` + MsgToMongo struct { + Topic string `yaml:"topic"` + } `yaml:"offlineMsgToMongo"` + MsgToPush struct { + Topic string `yaml:"topic"` + } `yaml:"msgToPush"` + ConsumerGroupID struct { + MsgToRedis string `yaml:"msgToRedis"` + MsgToMongo string `yaml:"msgToMongo"` + MsgToMySql string `yaml:"msgToMySql"` + MsgToPush string `yaml:"msgToPush"` + } `yaml:"consumerGroupID"` + } `yaml:"kafka"` + + Rpc struct { + RegisterIP string `yaml:"registerIP"` + ListenIP string `yaml:"listenIP"` + } `yaml:"rpc"` + + Api struct { + OpenImApiPort []int `yaml:"openImApiPort"` + ListenIP string `yaml:"listenIP"` + } `yaml:"api"` + + Object struct { + Enable string `yaml:"enable"` + ApiURL string `yaml:"apiURL"` + Minio struct { + Bucket string `yaml:"bucket"` + Endpoint string `yaml:"endpoint"` + AccessKeyID string `yaml:"accessKeyID"` + SecretAccessKey string `yaml:"secretAccessKey"` + SessionToken string `yaml:"sessionToken"` + } `yaml:"minio"` + Cos struct { + BucketURL string `yaml:"bucketURL"` + SecretID string `yaml:"secretID"` + SecretKey string `yaml:"secretKey"` + SessionToken string `yaml:"sessionToken"` + } `yaml:"cos"` + Oss struct { + Endpoint string `yaml:"endpoint"` + Bucket string `yaml:"bucket"` + BucketURL string `yaml:"bucketURL"` + AccessKeyID string `yaml:"accessKeyID"` + AccessKeySecret string `yaml:"accessKeySecret"` + SessionToken string `yaml:"sessionToken"` + } `yaml:"oss"` + } `yaml:"object"` + + RpcPort struct { + OpenImUserPort []int `yaml:"openImUserPort"` + OpenImFriendPort []int `yaml:"openImFriendPort"` + OpenImMessagePort []int `yaml:"openImMessagePort"` + OpenImMessageGatewayPort []int `yaml:"openImMessageGatewayPort"` + OpenImGroupPort []int `yaml:"openImGroupPort"` + OpenImAuthPort []int `yaml:"openImAuthPort"` + OpenImPushPort []int `yaml:"openImPushPort"` + OpenImConversationPort []int `yaml:"openImConversationPort"` + OpenImRtcPort []int `yaml:"openImRtcPort"` + OpenImThirdPort []int `yaml:"openImThirdPort"` + } `yaml:"rpcPort"` + + RpcRegisterName struct { + OpenImUserName string `yaml:"openImUserName"` + OpenImFriendName string `yaml:"openImFriendName"` + OpenImMsgName string `yaml:"openImMsgName"` + OpenImPushName string `yaml:"openImPushName"` + OpenImMessageGatewayName string `yaml:"openImMessageGatewayName"` + OpenImGroupName string `yaml:"openImGroupName"` + OpenImAuthName string `yaml:"openImAuthName"` + OpenImConversationName string `yaml:"openImConversationName"` + OpenImThirdName string `yaml:"openImThirdName"` + } `yaml:"rpcRegisterName"` + + Log struct { + StorageLocation string `yaml:"storageLocation"` + RotationTime uint `yaml:"rotationTime"` + RemainRotationCount uint `yaml:"remainRotationCount"` + RemainLogLevel int `yaml:"remainLogLevel"` + IsStdout bool `yaml:"isStdout"` + IsJson bool `yaml:"isJson"` + WithStack bool `yaml:"withStack"` + } `yaml:"log"` + + LongConnSvr struct { + OpenImWsPort []int `yaml:"openImWsPort"` + WebsocketMaxConnNum int `yaml:"websocketMaxConnNum"` + WebsocketMaxMsgLen int `yaml:"websocketMaxMsgLen"` + WebsocketTimeout int `yaml:"websocketTimeout"` + } `yaml:"longConnSvr"` + + Push struct { + Enable string `yaml:"enable"` + GeTui struct { + PushUrl string `yaml:"pushUrl"` + AppKey string `yaml:"appKey"` + Intent string `yaml:"intent"` + MasterSecret string `yaml:"masterSecret"` + ChannelID string `yaml:"channelID"` + ChannelName string `yaml:"channelName"` + } `yaml:"geTui"` + Fcm struct { + ServiceAccount string `yaml:"serviceAccount"` + } `yaml:"fcm"` + Jpns struct { + AppKey string `yaml:"appKey"` + MasterSecret string `yaml:"masterSecret"` + PushUrl string `yaml:"pushUrl"` + PushIntent string `yaml:"pushIntent"` + } `yaml:"jpns"` + } + Manager struct { + UserID []string `yaml:"userID"` + Nickname []string `yaml:"nickname"` + } `yaml:"manager"` + + MultiLoginPolicy int `yaml:"multiLoginPolicy"` + ChatPersistenceMysql bool `yaml:"chatPersistenceMysql"` + MsgCacheTimeout int `yaml:"msgCacheTimeout"` + GroupMessageHasReadReceiptEnable bool `yaml:"groupMessageHasReadReceiptEnable"` + SingleMessageHasReadReceiptEnable bool `yaml:"singleMessageHasReadReceiptEnable"` + RetainChatRecords int `yaml:"retainChatRecords"` + ChatRecordsClearTime string `yaml:"chatRecordsClearTime"` + MsgDestructTime string `yaml:"msgDestructTime"` + Secret string `yaml:"secret"` + TokenPolicy struct { + Expire int64 `yaml:"expire"` + } `yaml:"tokenPolicy"` + MessageVerify struct { + FriendVerify *bool `yaml:"friendVerify"` + } `yaml:"messageVerify"` + + IOSPush struct { + PushSound string `yaml:"pushSound"` + BadgeCount bool `yaml:"badgeCount"` + Production bool `yaml:"production"` + } `yaml:"iosPush"` + Callback struct { + CallbackUrl string `yaml:"url"` + CallbackBeforeSendSingleMsg CallBackConfig `yaml:"beforeSendSingleMsg"` + CallbackAfterSendSingleMsg CallBackConfig `yaml:"afterSendSingleMsg"` + CallbackBeforeSendGroupMsg CallBackConfig `yaml:"beforeSendGroupMsg"` + CallbackAfterSendGroupMsg CallBackConfig `yaml:"afterSendGroupMsg"` + CallbackMsgModify CallBackConfig `yaml:"msgModify"` + CallbackUserOnline CallBackConfig `yaml:"userOnline"` + CallbackUserOffline CallBackConfig `yaml:"userOffline"` + CallbackUserKickOff CallBackConfig `yaml:"userKickOff"` + CallbackOfflinePush CallBackConfig `yaml:"offlinePush"` + CallbackOnlinePush CallBackConfig `yaml:"onlinePush"` + CallbackBeforeSuperGroupOnlinePush CallBackConfig `yaml:"superGroupOnlinePush"` + CallbackBeforeAddFriend CallBackConfig `yaml:"beforeAddFriend"` + CallbackBeforeCreateGroup CallBackConfig `yaml:"beforeCreateGroup"` + CallbackBeforeMemberJoinGroup CallBackConfig `yaml:"beforeMemberJoinGroup"` + CallbackBeforeSetGroupMemberInfo CallBackConfig `yaml:"beforeSetGroupMemberInfo"` + } `yaml:"callback"` + + Prometheus struct { + Enable bool `yaml:"enable"` + UserPrometheusPort []int `yaml:"userPrometheusPort"` + FriendPrometheusPort []int `yaml:"friendPrometheusPort"` + MessagePrometheusPort []int `yaml:"messagePrometheusPort"` + MessageGatewayPrometheusPort []int `yaml:"messageGatewayPrometheusPort"` + GroupPrometheusPort []int `yaml:"groupPrometheusPort"` + AuthPrometheusPort []int `yaml:"authPrometheusPort"` + PushPrometheusPort []int `yaml:"pushPrometheusPort"` + ConversationPrometheusPort []int `yaml:"conversationPrometheusPort"` + RtcPrometheusPort []int `yaml:"rtcPrometheusPort"` + MessageTransferPrometheusPort []int `yaml:"messageTransferPrometheusPort"` + ThirdPrometheusPort []int `yaml:"thirdPrometheusPort"` + } `yaml:"prometheus"` + Notification notification `yaml:"notification"` +} + +type notification struct { + GroupCreated NotificationConf `yaml:"groupCreated"` + GroupInfoSet NotificationConf `yaml:"groupInfoSet"` + JoinGroupApplication NotificationConf `yaml:"joinGroupApplication"` + MemberQuit NotificationConf `yaml:"memberQuit"` + GroupApplicationAccepted NotificationConf `yaml:"groupApplicationAccepted"` + GroupApplicationRejected NotificationConf `yaml:"groupApplicationRejected"` + GroupOwnerTransferred NotificationConf `yaml:"groupOwnerTransferred"` + MemberKicked NotificationConf `yaml:"memberKicked"` + MemberInvited NotificationConf `yaml:"memberInvited"` + MemberEnter NotificationConf `yaml:"memberEnter"` + GroupDismissed NotificationConf `yaml:"groupDismissed"` + GroupMuted NotificationConf `yaml:"groupMuted"` + GroupCancelMuted NotificationConf `yaml:"groupCancelMuted"` + GroupMemberMuted NotificationConf `yaml:"groupMemberMuted"` + GroupMemberCancelMuted NotificationConf `yaml:"groupMemberCancelMuted"` + GroupMemberInfoSet NotificationConf `yaml:"groupMemberInfoSet"` + GroupMemberSetToAdmin NotificationConf `yaml:"groupMemberSetToAdmin"` + GroupMemberSetToOrdinary NotificationConf `yaml:"groupMemberSetToOrdinaryUser"` + GroupInfoSetAnnouncement NotificationConf `yaml:"groupInfoSetAnnouncement"` + GroupInfoSetName NotificationConf `yaml:"groupInfoSetName"` + ////////////////////////user/////////////////////// + UserInfoUpdated NotificationConf `yaml:"userInfoUpdated"` + //////////////////////friend/////////////////////// + FriendApplicationAdded NotificationConf `yaml:"friendApplicationAdded"` + FriendApplicationApproved NotificationConf `yaml:"friendApplicationApproved"` + FriendApplicationRejected NotificationConf `yaml:"friendApplicationRejected"` + FriendAdded NotificationConf `yaml:"friendAdded"` + FriendDeleted NotificationConf `yaml:"friendDeleted"` + FriendRemarkSet NotificationConf `yaml:"friendRemarkSet"` + BlackAdded NotificationConf `yaml:"blackAdded"` + BlackDeleted NotificationConf `yaml:"blackDeleted"` + FriendInfoUpdated NotificationConf `yaml:"friendInfoUpdated"` + //////////////////////conversation/////////////////////// + ConversationChanged NotificationConf `yaml:"conversationChanged"` + ConversationSetPrivate NotificationConf `yaml:"conversationSetPrivate"` +} + +func (c *configStruct) GetServiceNames() []string { + return []string{ + c.RpcRegisterName.OpenImUserName, + c.RpcRegisterName.OpenImFriendName, + c.RpcRegisterName.OpenImMsgName, + c.RpcRegisterName.OpenImPushName, + c.RpcRegisterName.OpenImMessageGatewayName, + c.RpcRegisterName.OpenImGroupName, + c.RpcRegisterName.OpenImAuthName, + c.RpcRegisterName.OpenImConversationName, + c.RpcRegisterName.OpenImThirdName, + } +} + +func (c *configStruct) RegisterConf2Registry(registry discoveryregistry.SvcDiscoveryRegistry) error { + data, err := yaml.Marshal(c) + if err != nil { + return err + } + return registry.RegisterConf2Registry(ConfKey, data) +} + +func (c *configStruct) GetConfFromRegistry(registry discoveryregistry.SvcDiscoveryRegistry) ([]byte, error) { + return registry.GetConfFromRegistry(ConfKey) +} + +func (c *configStruct) EncodeConfig() []byte { + buf := bytes.NewBuffer(nil) + if err := yaml.NewEncoder(buf).Encode(c); err != nil { + panic(err) + } + return buf.Bytes() +} diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index f31df39d2..1fc592b6d 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -17,23 +17,18 @@ package config import ( _ "embed" "fmt" - "github.com/OpenIMSDK/tools/config" "os" "path/filepath" "runtime" "gopkg.in/yaml.v3" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/utils" ) //go:embed version -var version string - -func init() { - config.Version = version -} +var Version string var ( _, b, _, _ = runtime.Caller(0) @@ -47,7 +42,7 @@ const ( DefaultFolderPath = "../config/" ) -func GetOptionsByNotification(cfg config.NotificationConf) utils.Options { +func GetOptionsByNotification(cfg NotificationConf) utils.Options { opts := utils.NewOptions() if cfg.UnreadCount { opts = utils.WithOptions(opts, utils.WithUnreadCount(true)) @@ -92,11 +87,11 @@ func initConfig(config interface{}, configName, configFolderPath string) error { } func InitConfig(configFolderPath string) error { - err := initConfig(&config.Config, FileName, configFolderPath) + err := initConfig(&Config, FileName, configFolderPath) if err != nil { return err } - err = initConfig(&config.Config.Notification, NotificationFileName, configFolderPath) + err = initConfig(&Config.Notification, NotificationFileName, configFolderPath) if err != nil { return err } diff --git a/pkg/common/db/cache/init_redis.go b/pkg/common/db/cache/init_redis.go index 307e40327..69bc0d484 100644 --- a/pkg/common/db/cache/init_redis.go +++ b/pkg/common/db/cache/init_redis.go @@ -22,7 +22,7 @@ import ( "github.com/redis/go-redis/v9" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mw/specialerror" ) diff --git a/pkg/common/db/cache/msg.go b/pkg/common/db/cache/msg.go index 66f3cacee..e208567d0 100644 --- a/pkg/common/db/cache/msg.go +++ b/pkg/common/db/cache/msg.go @@ -25,10 +25,10 @@ import ( "github.com/gogo/protobuf/jsonpb" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/utils" diff --git a/pkg/common/db/controller/auth.go b/pkg/common/db/controller/auth.go index 491a1394b..bb614438c 100644 --- a/pkg/common/db/controller/auth.go +++ b/pkg/common/db/controller/auth.go @@ -20,7 +20,7 @@ import ( "github.com/golang-jwt/jwt/v4" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/tokenverify" "github.com/OpenIMSDK/tools/utils" ) diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go index 0f3403084..cb6ac41f9 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -20,7 +20,7 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/tx" "github.com/OpenIMSDK/tools/utils" diff --git a/pkg/common/db/controller/friend.go b/pkg/common/db/controller/friend.go index 3c8d61a40..c44c1662e 100644 --- a/pkg/common/db/controller/friend.go +++ b/pkg/common/db/controller/friend.go @@ -22,7 +22,7 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/tx" diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go index ad0b4e548..af97d87ca 100644 --- a/pkg/common/db/controller/group.go +++ b/pkg/common/db/controller/group.go @@ -29,7 +29,7 @@ import ( relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/tx" "github.com/OpenIMSDK/tools/utils" ) diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go index 555828c22..7c03eb8b6 100644 --- a/pkg/common/db/controller/msg.go +++ b/pkg/common/db/controller/msg.go @@ -21,13 +21,13 @@ import ( "github.com/redis/go-redis/v9" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" diff --git a/pkg/common/db/controller/msg_test.go b/pkg/common/db/controller/msg_test.go index e322e6218..73226fa1b 100644 --- a/pkg/common/db/controller/msg_test.go +++ b/pkg/common/db/controller/msg_test.go @@ -27,9 +27,9 @@ import ( "go.mongodb.org/mongo-driver/bson" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation" - "github.com/OpenIMSDK/tools/config" ) func Test_BatchInsertChat2DB(t *testing.T) { @@ -203,7 +203,7 @@ func Test_Revoke(t *testing.T) { } func Test_FindBySeq(t *testing.T) { - if err := log.InitFromConfig("", "", 6, true, false, "", 2); err != nil { + if err := log.InitFromConfig("", "", 6, true, false, "", 2, 1); err != nil { t.Fatal(err) } db := GetDB() diff --git a/pkg/common/db/relation/chat_log_model.go b/pkg/common/db/relation/chat_log_model.go index 056295e15..76ed9be62 100644 --- a/pkg/common/db/relation/chat_log_model.go +++ b/pkg/common/db/relation/chat_log_model.go @@ -21,9 +21,9 @@ import ( "gorm.io/gorm" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" + "github.com/OpenIMSDK/protocol/constant" pbMsg "github.com/OpenIMSDK/protocol/msg" sdkws "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/utils" ) diff --git a/pkg/common/db/relation/conversation_model.go b/pkg/common/db/relation/conversation_model.go index 716d2cbe4..0efca79aa 100644 --- a/pkg/common/db/relation/conversation_model.go +++ b/pkg/common/db/relation/conversation_model.go @@ -20,7 +20,7 @@ import ( "gorm.io/gorm" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/utils" ) diff --git a/pkg/common/db/relation/group_member_model.go b/pkg/common/db/relation/group_member_model.go index 7c2ded83f..da6a58398 100644 --- a/pkg/common/db/relation/group_member_model.go +++ b/pkg/common/db/relation/group_member_model.go @@ -20,7 +20,7 @@ import ( "gorm.io/gorm" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/ormutil" "github.com/OpenIMSDK/tools/utils" ) diff --git a/pkg/common/db/relation/group_model.go b/pkg/common/db/relation/group_model.go index c95d51861..697427e04 100644 --- a/pkg/common/db/relation/group_model.go +++ b/pkg/common/db/relation/group_model.go @@ -18,7 +18,7 @@ import ( "context" "time" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "gorm.io/gorm" diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go index 29873cc89..9b8188ac4 100644 --- a/pkg/common/db/relation/mysql_init.go +++ b/pkg/common/db/relation/mysql_init.go @@ -21,7 +21,7 @@ import ( mysqlDriver "github.com/go-sql-driver/mysql" "gorm.io/driver/mysql" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mw/specialerror" diff --git a/pkg/common/db/s3/cos/cos.go b/pkg/common/db/s3/cos/cos.go index 29d74ceb4..cfdaaa5e4 100644 --- a/pkg/common/db/s3/cos/cos.go +++ b/pkg/common/db/s3/cos/cos.go @@ -26,8 +26,8 @@ import ( "github.com/tencentyun/cos-go-sdk-v5" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3" - "github.com/OpenIMSDK/tools/config" ) const ( diff --git a/pkg/common/db/s3/minio/minio.go b/pkg/common/db/s3/minio/minio.go index d5ac7de40..bb6e6ce24 100644 --- a/pkg/common/db/s3/minio/minio.go +++ b/pkg/common/db/s3/minio/minio.go @@ -29,8 +29,8 @@ import ( "github.com/minio/minio-go/v7/pkg/credentials" "github.com/minio/minio-go/v7/pkg/signer" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3" - "github.com/OpenIMSDK/tools/config" ) const ( diff --git a/pkg/common/db/s3/oss/oss.go b/pkg/common/db/s3/oss/oss.go index ee4d19464..774150389 100644 --- a/pkg/common/db/s3/oss/oss.go +++ b/pkg/common/db/s3/oss/oss.go @@ -26,8 +26,8 @@ import ( "github.com/aliyun/aliyun-oss-go-sdk/oss" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3" - "github.com/OpenIMSDK/tools/config" ) const ( diff --git a/pkg/common/db/unrelation/mongo.go b/pkg/common/db/unrelation/mongo.go index 44077a838..b580f4dbd 100644 --- a/pkg/common/db/unrelation/mongo.go +++ b/pkg/common/db/unrelation/mongo.go @@ -24,8 +24,8 @@ import ( "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mw/specialerror" "github.com/OpenIMSDK/tools/utils" diff --git a/pkg/common/db/unrelation/msg.go b/pkg/common/db/unrelation/msg.go index 2f4a166e9..27f7cf5ce 100644 --- a/pkg/common/db/unrelation/msg.go +++ b/pkg/common/db/unrelation/msg.go @@ -23,7 +23,7 @@ import ( "github.com/OpenIMSDK/protocol/msg" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/protocol/constant" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" diff --git a/pkg/common/http/http_client.go b/pkg/common/http/http_client.go index 46d5f23c3..a646f774e 100644 --- a/pkg/common/http/http_client.go +++ b/pkg/common/http/http_client.go @@ -25,8 +25,8 @@ import ( "time" "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" ) diff --git a/pkg/common/kafka/consumer.go b/pkg/common/kafka/consumer.go index e04abe944..67bc3977b 100644 --- a/pkg/common/kafka/consumer.go +++ b/pkg/common/kafka/consumer.go @@ -17,7 +17,7 @@ package kafka import ( "sync" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/Shopify/sarama" ) diff --git a/pkg/common/kafka/producer.go b/pkg/common/kafka/producer.go index 8eeaa6825..754f2166d 100644 --- a/pkg/common/kafka/producer.go +++ b/pkg/common/kafka/producer.go @@ -19,8 +19,8 @@ import ( "errors" "time" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/protocol/constant" log "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" diff --git a/pkg/common/prome/prometheus.go b/pkg/common/prome/prometheus.go index 26efb9dae..d66b1df70 100644 --- a/pkg/common/prome/prometheus.go +++ b/pkg/common/prome/prometheus.go @@ -19,7 +19,7 @@ import ( "net/http" "strconv" - "github.com/OpenIMSDK/tools/config" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/gin-gonic/gin" "github.com/prometheus/client_golang/prometheus" diff --git a/pkg/common/startrpc/start.go b/pkg/common/startrpc/start.go new file mode 100644 index 000000000..3f8fc8fa2 --- /dev/null +++ b/pkg/common/startrpc/start.go @@ -0,0 +1,111 @@ +// Copyright © 2023 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package startrpc + +import ( + "fmt" + "net" + "strconv" + "time" + + grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + + "github.com/OpenIMSDK/tools/discoveryregistry" + "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper" + "github.com/OpenIMSDK/tools/log" + "github.com/OpenIMSDK/tools/mw" + "github.com/OpenIMSDK/tools/network" + "github.com/OpenIMSDK/tools/prome" + "github.com/OpenIMSDK/tools/utils" +) + +func Start( + rpcPort int, + rpcRegisterName string, + prometheusPort int, + rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, + options ...grpc.ServerOption, +) error { + fmt.Println( + "start", + rpcRegisterName, + "server, port: ", + rpcPort, + "prometheusPort:", + prometheusPort, + ", OpenIM version: ", + config.Version, + ) + listener, err := net.Listen( + "tcp", + net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)), + ) + if err != nil { + return err + } + defer listener.Close() + zkClient, err := zookeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, + zookeeper.WithFreq(time.Hour), zookeeper.WithUserNameAndPassword( + config.Config.Zookeeper.Username, + config.Config.Zookeeper.Password, + ), zookeeper.WithRoundRobin(), zookeeper.WithTimeout(10), zookeeper.WithLogger(log.NewZkLogger())) + if err != nil { + return utils.Wrap1(err) + } + defer zkClient.CloseZK() + zkClient.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials())) + registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP) + if err != nil { + return err + } + // ctx 中间件 + if config.Config.Prometheus.Enable { + prome.NewGrpcRequestCounter() + prome.NewGrpcRequestFailedCounter() + prome.NewGrpcRequestSuccessCounter() + unaryInterceptor := mw.InterceptChain(grpcPrometheus.UnaryServerInterceptor, mw.RpcServerInterceptor) + options = append(options, []grpc.ServerOption{ + grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor), + grpc.UnaryInterceptor(unaryInterceptor), + }...) + } else { + options = append(options, mw.GrpcServer()) + } + srv := grpc.NewServer(options...) + defer srv.GracefulStop() + err = rpcFn(zkClient, srv) + if err != nil { + return utils.Wrap1(err) + } + err = zkClient.Register( + rpcRegisterName, + registerIP, + rpcPort, + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + if err != nil { + return utils.Wrap1(err) + } + go func() { + if config.Config.Prometheus.Enable && prometheusPort != 0 { + if err := prome.StartPrometheusSrv(prometheusPort); err != nil { + panic(err.Error()) + } + } + }() + return utils.Wrap1(srv.Serve(listener)) +} diff --git a/pkg/rpcclient/auth.go b/pkg/rpcclient/auth.go index 9d667f1ad..cbf1324e0 100644 --- a/pkg/rpcclient/auth.go +++ b/pkg/rpcclient/auth.go @@ -19,8 +19,8 @@ import ( "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/protocol/auth" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/discoveryregistry" ) diff --git a/pkg/rpcclient/conversation.go b/pkg/rpcclient/conversation.go index d4116e9f9..2b7d2c392 100644 --- a/pkg/rpcclient/conversation.go +++ b/pkg/rpcclient/conversation.go @@ -20,8 +20,8 @@ import ( "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" pbConversation "github.com/OpenIMSDK/protocol/conversation" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/errs" ) diff --git a/pkg/rpcclient/friend.go b/pkg/rpcclient/friend.go index c27f4ef3f..f1aaaa319 100644 --- a/pkg/rpcclient/friend.go +++ b/pkg/rpcclient/friend.go @@ -19,9 +19,9 @@ import ( "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/protocol/friend" sdkws "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/discoveryregistry" ) diff --git a/pkg/rpcclient/group.go b/pkg/rpcclient/group.go index ce624a085..57dcd0fa5 100644 --- a/pkg/rpcclient/group.go +++ b/pkg/rpcclient/group.go @@ -20,10 +20,10 @@ import ( "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/group" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/utils" diff --git a/pkg/rpcclient/msg.go b/pkg/rpcclient/msg.go index bfc7bf73f..8e9416af9 100644 --- a/pkg/rpcclient/msg.go +++ b/pkg/rpcclient/msg.go @@ -21,10 +21,10 @@ import ( "google.golang.org/grpc" "google.golang.org/protobuf/proto" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/config" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/utils" diff --git a/pkg/rpcclient/notification/conevrsation.go b/pkg/rpcclient/notification/conevrsation.go index ac40eb887..9c8066d00 100644 --- a/pkg/rpcclient/notification/conevrsation.go +++ b/pkg/rpcclient/notification/conevrsation.go @@ -18,8 +18,8 @@ import ( "context" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" ) type ConversationNotificationSender struct { diff --git a/pkg/rpcclient/notification/friend.go b/pkg/rpcclient/notification/friend.go index 05c2b1e6f..ddce86c8c 100644 --- a/pkg/rpcclient/notification/friend.go +++ b/pkg/rpcclient/notification/friend.go @@ -23,9 +23,9 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" + "github.com/OpenIMSDK/protocol/constant" pbFriend "github.com/OpenIMSDK/protocol/friend" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" ) type FriendNotificationSender struct { diff --git a/pkg/rpcclient/notification/group.go b/pkg/rpcclient/notification/group.go index e70bf38e1..fdf77500f 100644 --- a/pkg/rpcclient/notification/group.go +++ b/pkg/rpcclient/notification/group.go @@ -21,9 +21,9 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" + "github.com/OpenIMSDK/protocol/constant" pbGroup "github.com/OpenIMSDK/protocol/group" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" diff --git a/pkg/rpcclient/notification/msg.go b/pkg/rpcclient/notification/msg.go index f9cf68bcb..ba5aef684 100644 --- a/pkg/rpcclient/notification/msg.go +++ b/pkg/rpcclient/notification/msg.go @@ -18,8 +18,8 @@ import ( "context" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/sdkws" - "github.com/OpenIMSDK/tools/constant" ) type MsgNotificationSender struct { diff --git a/pkg/rpcclient/push.go b/pkg/rpcclient/push.go index a4b122a29..4401221c3 100644 --- a/pkg/rpcclient/push.go +++ b/pkg/rpcclient/push.go @@ -19,8 +19,8 @@ import ( "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/protocol/push" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/discoveryregistry" ) diff --git a/pkg/rpcclient/third.go b/pkg/rpcclient/third.go index 9822f48fa..c01ab4d0c 100644 --- a/pkg/rpcclient/third.go +++ b/pkg/rpcclient/third.go @@ -23,8 +23,8 @@ import ( "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/protocol/third" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/discoveryregistry" ) diff --git a/pkg/rpcclient/user.go b/pkg/rpcclient/user.go index 7e5079f8c..05cce5531 100644 --- a/pkg/rpcclient/user.go +++ b/pkg/rpcclient/user.go @@ -20,9 +20,9 @@ import ( "google.golang.org/grpc" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/user" - "github.com/OpenIMSDK/tools/config" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/tokenverify"