mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-11 12:36:00 +08:00
mv src/common src/utils src/grpc-etcdv3 to pkg
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v3"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
var Config config
|
||||
|
||||
type config struct {
|
||||
ServerIP string `yaml:"serverip"`
|
||||
|
||||
Api struct {
|
||||
GinPort []int `yaml:"openImApiPort"`
|
||||
}
|
||||
Sdk struct {
|
||||
WsPort []int `yaml:"sdkWsPort"`
|
||||
}
|
||||
Credential struct {
|
||||
Tencent struct {
|
||||
AppID string `yaml:"appID"`
|
||||
Region string `yaml:"region"`
|
||||
Bucket string `yaml:"bucket"`
|
||||
SecretID string `yaml:"secretID"`
|
||||
SecretKey string `yaml:"secretKey"`
|
||||
}
|
||||
}
|
||||
|
||||
Mysql struct {
|
||||
DBAddress []string `yaml:"dbMysqlAddress"`
|
||||
DBUserName string `yaml:"dbMysqlUserName"`
|
||||
DBPassword string `yaml:"dbMysqlPassword"`
|
||||
DBDatabaseName string `yaml:"dbMysqlDatabaseName"`
|
||||
DBTableName string `yaml:"DBTableName"`
|
||||
DBMsgTableNum int `yaml:"dbMsgTableNum"`
|
||||
DBMaxOpenConns int `yaml:"dbMaxOpenConns"`
|
||||
DBMaxIdleConns int `yaml:"dbMaxIdleConns"`
|
||||
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
|
||||
}
|
||||
Mongo struct {
|
||||
DBAddress []string `yaml:"dbAddress"`
|
||||
DBDirect bool `yaml:"dbDirect"`
|
||||
DBTimeout int `yaml:"dbTimeout"`
|
||||
DBDatabase string `yaml:"dbDatabase"`
|
||||
DBSource string `yaml:"dbSource"`
|
||||
DBUserName string `yaml:"dbUserName"`
|
||||
DBPassword string `yaml:"dbPassword"`
|
||||
DBMaxPoolSize int `yaml:"dbMaxPoolSize"`
|
||||
DBRetainChatRecords int `yaml:"dbRetainChatRecords"`
|
||||
}
|
||||
Redis struct {
|
||||
DBAddress string `yaml:"dbAddress"`
|
||||
DBMaxIdle int `yaml:"dbMaxIdle"`
|
||||
DBMaxActive int `yaml:"dbMaxActive"`
|
||||
DBIdleTimeout int `yaml:"dbIdleTimeout"`
|
||||
DBPassWord string `yaml:"dbPassWord"`
|
||||
}
|
||||
RpcPort struct {
|
||||
OpenImUserPort []int `yaml:"openImUserPort"`
|
||||
openImFriendPort []int `yaml:"openImFriendPort"`
|
||||
RpcMessagePort []int `yaml:"rpcMessagePort"`
|
||||
RpcPushMessagePort []int `yaml:"rpcPushMessagePort"`
|
||||
OpenImGroupPort []int `yaml:"openImGroupPort"`
|
||||
RpcModifyUserInfoPort []int `yaml:"rpcModifyUserInfoPort"`
|
||||
RpcGetTokenPort []int `yaml:"rpcGetTokenPort"`
|
||||
}
|
||||
RpcRegisterName struct {
|
||||
OpenImUserName string `yaml:"openImUserName"`
|
||||
OpenImFriendName string `yaml:"openImFriendName"`
|
||||
OpenImOfflineMessageName string `yaml:"openImOfflineMessageName"`
|
||||
OpenImPushName string `yaml:"openImPushName"`
|
||||
OpenImOnlineMessageRelayName string `yaml:"openImOnlineMessageRelayName"`
|
||||
OpenImGroupName string `yaml:"openImGroupName"`
|
||||
RpcGetTokenName string `yaml:"rpcGetTokenName"`
|
||||
}
|
||||
Etcd struct {
|
||||
EtcdSchema string `yaml:"etcdSchema"`
|
||||
EtcdAddr []string `yaml:"etcdAddr"`
|
||||
}
|
||||
Log struct {
|
||||
StorageLocation string `yaml:"storageLocation"`
|
||||
RotationTime int `yaml:"rotationTime"`
|
||||
RemainRotationCount uint `yaml:"remainRotationCount"`
|
||||
ElasticSearchSwitch bool `yaml:"elasticSearchSwitch"`
|
||||
ElasticSearchAddr []string `yaml:"elasticSearchAddr"`
|
||||
ElasticSearchUser string `yaml:"elasticSearchUser"`
|
||||
ElasticSearchPassword string `yaml:"elasticSearchPassword"`
|
||||
}
|
||||
ModuleName struct {
|
||||
LongConnSvrName string `yaml:"longConnSvrName"`
|
||||
MsgTransferName string `yaml:"msgTransferName"`
|
||||
PushName string `yaml:"pushName"`
|
||||
}
|
||||
LongConnSvr struct {
|
||||
WebsocketPort []int `yaml:"websocketPort"`
|
||||
WebsocketMaxConnNum int `yaml:"websocketMaxConnNum"`
|
||||
WebsocketMaxMsgLen int `yaml:"websocketMaxMsgLen"`
|
||||
WebsocketTimeOut int `yaml:"websocketTimeOut"`
|
||||
}
|
||||
|
||||
Push struct {
|
||||
Tpns struct {
|
||||
Ios struct {
|
||||
AccessID string `yaml:"accessID"`
|
||||
SecretKey string `yaml:"secretKey"`
|
||||
}
|
||||
Android struct {
|
||||
AccessID string `yaml:"accessID"`
|
||||
SecretKey string `yaml:"secretKey"`
|
||||
}
|
||||
}
|
||||
}
|
||||
Manager struct {
|
||||
AppManagerUid []string `yaml:"appManagerUid"`
|
||||
Secrets []string `yaml:"secrets"`
|
||||
}
|
||||
Kafka struct {
|
||||
Ws2mschat struct {
|
||||
Addr []string `yaml:"addr"`
|
||||
Topic string `yaml:"topic"`
|
||||
}
|
||||
Ms2pschat struct {
|
||||
Addr []string `yaml:"addr"`
|
||||
Topic string `yaml:"topic"`
|
||||
}
|
||||
ConsumerGroupID struct {
|
||||
MsgToMongo string `yaml:"msgToMongo"`
|
||||
MsgToMySql string `yaml:"msgToMySql"`
|
||||
MsgToPush string `yaml:"msgToPush"`
|
||||
}
|
||||
}
|
||||
Secret string `yaml:"secret"`
|
||||
MultiLoginPolicy struct {
|
||||
OnlyOneTerminalAccess bool `yaml:"onlyOneTerminalAccess"`
|
||||
MobileAndPCTerminalAccessButOtherTerminalKickEachOther bool `yaml:"mobileAndPCTerminalAccessButOtherTerminalKickEachOther"`
|
||||
AllTerminalAccess bool `yaml:"allTerminalAccess"`
|
||||
}
|
||||
TokenPolicy struct {
|
||||
AccessSecret string `yaml:"accessSecret"`
|
||||
AccessExpire int64 `yaml:"accessExpire"`
|
||||
}
|
||||
MessageCallBack struct {
|
||||
CallbackSwitch bool `yaml:"callbackSwitch"`
|
||||
CallbackUrl string `yaml:"callbackUrl"`
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
bytes, err := ioutil.ReadFile("config/config.yaml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return
|
||||
}
|
||||
if err = yaml.Unmarshal(bytes, &Config); err != nil {
|
||||
panic(err)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package config
|
||||
|
||||
// key = errCode, string = errMsg
|
||||
type ErrInfo struct {
|
||||
ErrCode int32
|
||||
ErrMsg string
|
||||
}
|
||||
|
||||
var (
|
||||
OK = ErrInfo{0, ""}
|
||||
|
||||
ErrMysql = ErrInfo{100, ""}
|
||||
ErrMongo = ErrInfo{110, ""}
|
||||
ErrRedis = ErrInfo{120, ""}
|
||||
ErrParseToken = ErrInfo{200, "Parse token failed"}
|
||||
ErrCreateToken = ErrInfo{201, "Create token failed"}
|
||||
ErrAppServerKey = ErrInfo{300, "key error"}
|
||||
ErrTencentCredential = ErrInfo{400, ""}
|
||||
|
||||
ErrorUserRegister = ErrInfo{600, "User registration failed"}
|
||||
ErrAccountExists = ErrInfo{601, "The account is already registered and cannot be registered again"}
|
||||
ErrUserPassword = ErrInfo{602, "User password error"}
|
||||
ErrTokenIncorrect = ErrInfo{603, "Invalid token"}
|
||||
ErrTokenExpired = ErrInfo{604, "Expired token"}
|
||||
ErrRefreshToken = ErrInfo{605, "Failed to refresh token"}
|
||||
ErrAddFriend = ErrInfo{606, "Failed to add friends"}
|
||||
ErrAgreeToAddFriend = ErrInfo{607, "Failed to agree application"}
|
||||
ErrAddFriendToBlack = ErrInfo{608, "Failed to add friends to the blacklist"}
|
||||
ErrGetBlackList = ErrInfo{609, "Failed to get blacklist"}
|
||||
ErrDeleteFriend = ErrInfo{610, "Failed to delete friend"}
|
||||
ErrGetFriendApplyList = ErrInfo{611, "Failed to get friend application list"}
|
||||
ErrGetFriendList = ErrInfo{612, "Failed to get friend list"}
|
||||
ErrRemoveBlackList = ErrInfo{613, "Failed to remove blacklist"}
|
||||
ErrSearchUserInfo = ErrInfo{614, "Can't find the user information"}
|
||||
ErrDelAppleDeviceToken = ErrInfo{615, ""}
|
||||
ErrModifyUserInfo = ErrInfo{616, "update user some attribute failed"}
|
||||
ErrSetFriendComment = ErrInfo{617, "set friend comment failed"}
|
||||
ErrSearchUserInfoFromTheGroup = ErrInfo{618, "There is no such group or the user not in the group"}
|
||||
ErrCreateGroup = ErrInfo{619, "create group chat failed"}
|
||||
ErrJoinGroupApplication = ErrInfo{620, "Failed to apply to join the group"}
|
||||
ErrQuitGroup = ErrInfo{621, "Failed to quit the group"}
|
||||
ErrSetGroupInfo = ErrInfo{622, "Failed to set group info"}
|
||||
ErrParam = ErrInfo{ErrCode: 700, ErrMsg: "param failed"}
|
||||
|
||||
ErrAccess = ErrInfo{ErrCode: 800, ErrMsg: "no permission"}
|
||||
|
||||
ErrDb = ErrInfo{ErrCode: 900, ErrMsg: "db failed"}
|
||||
)
|
||||
Reference in New Issue
Block a user