mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-16 06:49:02 +08:00
feat: add openim images config path
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
// 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 convert
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
||||
)
|
||||
|
||||
func TestFriendPb2DB(t *testing.T) {
|
||||
type args struct {
|
||||
friend *sdkws.FriendInfo
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want *relation.FriendModel
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := FriendPb2DB(tt.args.friend); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("FriendPb2DB() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFriendDB2Pb(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
friendDB *relation.FriendModel
|
||||
getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error)
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want *sdkws.FriendInfo
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := FriendDB2Pb(tt.args.ctx, tt.args.friendDB, tt.args.getUsers)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("FriendDB2Pb() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("FriendDB2Pb() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFriendsDB2Pb(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
friendsDB []*relation.FriendModel
|
||||
getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error)
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantFriendsPb []*sdkws.FriendInfo
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
gotFriendsPb, err := FriendsDB2Pb(tt.args.ctx, tt.args.friendsDB, tt.args.getUsers)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("FriendsDB2Pb() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(gotFriendsPb, tt.wantFriendsPb) {
|
||||
t.Errorf("FriendsDB2Pb() = %v, want %v", gotFriendsPb, tt.wantFriendsPb)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFriendRequestDB2Pb(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
friendRequests []*relation.FriendRequestModel
|
||||
getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error)
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []*sdkws.FriendRequest
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := FriendRequestDB2Pb(tt.args.ctx, tt.args.friendRequests, tt.args.getUsers)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("FriendRequestDB2Pb() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("FriendRequestDB2Pb() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ package controller
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prom_metrics"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
@@ -31,6 +30,7 @@ import (
|
||||
unrelationtb "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/unrelation"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/unrelation"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/kafka"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/metrics"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
|
||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
||||
@@ -376,20 +376,20 @@ func (db *commonMsgDatabase) BatchInsertChat2Cache(ctx context.Context, conversa
|
||||
}
|
||||
failedNum, err := db.cache.SetMessageToCache(ctx, conversationID, msgs)
|
||||
if err != nil {
|
||||
prom_metrics.MsgInsertRedisFailedCounter.Add(float64(failedNum))
|
||||
metrics.MsgInsertRedisFailedCounter.Add(float64(failedNum))
|
||||
log.ZError(ctx, "setMessageToCache error", err, "len", len(msgs), "conversationID", conversationID)
|
||||
} else {
|
||||
prom_metrics.MsgInsertRedisSuccessCounter.Inc()
|
||||
metrics.MsgInsertRedisSuccessCounter.Inc()
|
||||
}
|
||||
err = db.cache.SetMaxSeq(ctx, conversationID, currentMaxSeq)
|
||||
if err != nil {
|
||||
log.ZError(ctx, "db.cache.SetMaxSeq error", err, "conversationID", conversationID)
|
||||
prom_metrics.SeqSetFailedCounter.Inc()
|
||||
metrics.SeqSetFailedCounter.Inc()
|
||||
}
|
||||
err2 := db.cache.SetHasReadSeqs(ctx, conversationID, userSeqMap)
|
||||
if err != nil {
|
||||
log.ZError(ctx, "SetHasReadSeqs error", err2, "userSeqMap", userSeqMap, "conversationID", conversationID)
|
||||
prom_metrics.SeqSetFailedCounter.Inc()
|
||||
metrics.SeqSetFailedCounter.Inc()
|
||||
}
|
||||
return lastMaxSeq, isNew, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
// 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 http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
)
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
type args struct {
|
||||
url string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantResponse []byte
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
gotResponse, err := Get(tt.args.url)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("Get() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(gotResponse, tt.wantResponse) {
|
||||
t.Errorf("Get() = %v, want %v", gotResponse, tt.wantResponse)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPost(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
url string
|
||||
header map[string]string
|
||||
data interface{}
|
||||
timeout int
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantContent []byte
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
gotContent, err := Post(tt.args.ctx, tt.args.url, tt.args.header, tt.args.data, tt.args.timeout)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("Post() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(gotContent, tt.wantContent) {
|
||||
t.Errorf("Post() = %v, want %v", gotContent, tt.wantContent)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPostReturn(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
url string
|
||||
header map[string]string
|
||||
input interface{}
|
||||
output interface{}
|
||||
timeOutSecond int
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := PostReturn(tt.args.ctx, tt.args.url, tt.args.header, tt.args.input, tt.args.output, tt.args.timeOutSecond); (err != nil) != tt.wantErr {
|
||||
t.Errorf("PostReturn() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_callBackPostReturn(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
url string
|
||||
command string
|
||||
input interface{}
|
||||
output callbackstruct.CallbackResp
|
||||
callbackConfig config.CallBackConfig
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := callBackPostReturn(tt.args.ctx, tt.args.url, tt.args.command, tt.args.input, tt.args.output, tt.args.callbackConfig); (err != nil) != tt.wantErr {
|
||||
t.Errorf("callBackPostReturn() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCallBackPostReturn(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
url string
|
||||
req callbackstruct.CallbackReq
|
||||
resp callbackstruct.CallbackResp
|
||||
callbackConfig config.CallBackConfig
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := CallBackPostReturn(tt.args.ctx, tt.args.url, tt.args.req, tt.args.resp, tt.args.callbackConfig); (err != nil) != tt.wantErr {
|
||||
t.Errorf("CallBackPostReturn() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package discovery_register
|
||||
package kdisc
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -0,0 +1,157 @@
|
||||
// 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 locker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/cache"
|
||||
)
|
||||
|
||||
func TestNewLockerMessage(t *testing.T) {
|
||||
type args struct {
|
||||
cache cache.MsgModel
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want *LockerMessage
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := NewLockerMessage(tt.args.cache); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("NewLockerMessage() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLockerMessage_LockMessageTypeKey(t *testing.T) {
|
||||
type fields struct {
|
||||
cache cache.MsgModel
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
clientMsgID string
|
||||
typeKey string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
l := &LockerMessage{
|
||||
cache: tt.fields.cache,
|
||||
}
|
||||
if err := l.LockMessageTypeKey(tt.args.ctx, tt.args.clientMsgID, tt.args.typeKey); (err != nil) != tt.wantErr {
|
||||
t.Errorf("LockerMessage.LockMessageTypeKey() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLockerMessage_LockGlobalMessage(t *testing.T) {
|
||||
type fields struct {
|
||||
cache cache.MsgModel
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
clientMsgID string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
l := &LockerMessage{
|
||||
cache: tt.fields.cache,
|
||||
}
|
||||
if err := l.LockGlobalMessage(tt.args.ctx, tt.args.clientMsgID); (err != nil) != tt.wantErr {
|
||||
t.Errorf("LockerMessage.LockGlobalMessage() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLockerMessage_UnLockMessageTypeKey(t *testing.T) {
|
||||
type fields struct {
|
||||
cache cache.MsgModel
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
clientMsgID string
|
||||
typeKey string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
l := &LockerMessage{
|
||||
cache: tt.fields.cache,
|
||||
}
|
||||
if err := l.UnLockMessageTypeKey(tt.args.ctx, tt.args.clientMsgID, tt.args.typeKey); (err != nil) != tt.wantErr {
|
||||
t.Errorf("LockerMessage.UnLockMessageTypeKey() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLockerMessage_UnLockGlobalMessage(t *testing.T) {
|
||||
type fields struct {
|
||||
cache cache.MsgModel
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
clientMsgID string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
l := &LockerMessage{
|
||||
cache: tt.fields.cache,
|
||||
}
|
||||
if err := l.UnLockGlobalMessage(tt.args.ctx, tt.args.clientMsgID); (err != nil) != tt.wantErr {
|
||||
t.Errorf("LockerMessage.UnLockGlobalMessage() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package prom_metrics
|
||||
|
||||
import ginProm "github.com/openimsdk/open-im-server/v3/pkg/common/ginPrometheus"
|
||||
import ginProm "github.com/openimsdk/open-im-server/v3/pkg/common/ginprom"
|
||||
|
||||
/*
|
||||
labels := prometheus.Labels{"label_one": "any", "label_two": "value"}
|
||||
@@ -3,7 +3,7 @@ package prom_metrics
|
||||
import (
|
||||
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/ginPrometheus"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/ginprom"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/collectors"
|
||||
)
|
||||
@@ -35,11 +35,11 @@ func GetGrpcCusMetrics(registerName string) []prometheus.Collector {
|
||||
}
|
||||
}
|
||||
|
||||
func GetGinCusMetrics(name string) []*ginPrometheus.Metric {
|
||||
func GetGinCusMetrics(name string) []*ginprom.Metric {
|
||||
switch name {
|
||||
case "Api":
|
||||
return []*ginPrometheus.Metric{ApiCustomCnt}
|
||||
return []*ginprom.Metric{ApiCustomCnt}
|
||||
default:
|
||||
return []*ginPrometheus.Metric{ApiCustomCnt}
|
||||
return []*ginprom.Metric{ApiCustomCnt}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package prom_metrics
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/ginprom"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
func TestNewGrpcPromObj(t *testing.T) {
|
||||
type args struct {
|
||||
cusMetrics []prometheus.Collector
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want *prometheus.Registry
|
||||
want1 *grpc_prometheus.ServerMetrics
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, got1, err := NewGrpcPromObj(tt.args.cusMetrics)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("NewGrpcPromObj() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("NewGrpcPromObj() got = %v, want %v", got, tt.want)
|
||||
}
|
||||
if !reflect.DeepEqual(got1, tt.want1) {
|
||||
t.Errorf("NewGrpcPromObj() got1 = %v, want %v", got1, tt.want1)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetGrpcCusMetrics(t *testing.T) {
|
||||
type args struct {
|
||||
registerName string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []prometheus.Collector
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := GetGrpcCusMetrics(tt.args.registerName); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("GetGrpcCusMetrics() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetGinCusMetrics(t *testing.T) {
|
||||
type args struct {
|
||||
name string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []*ginprom.Metric
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := GetGinCusMetrics(tt.args.name); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("GetGinCusMetrics() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -16,16 +16,17 @@ package startrpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prom_metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/kdisc"
|
||||
|
||||
grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||
"google.golang.org/grpc"
|
||||
@@ -55,7 +56,7 @@ func Start(
|
||||
return err
|
||||
}
|
||||
defer listener.Close()
|
||||
client, err := discovery_register.NewDiscoveryRegister(config.Config.Envs.Discovery)
|
||||
client, err := kdisc.NewDiscoveryRegister(config.Config.Envs.Discovery)
|
||||
if err != nil {
|
||||
return utils.Wrap1(err)
|
||||
}
|
||||
@@ -70,8 +71,8 @@ func Start(
|
||||
// ctx 中间件
|
||||
if config.Config.Prometheus.Enable {
|
||||
//////////////////////////
|
||||
cusMetrics := prom_metrics.GetGrpcCusMetrics(rpcRegisterName)
|
||||
reg, metric, err = prom_metrics.NewGrpcPromObj(cusMetrics)
|
||||
cusMetrics := metrics.GetGrpcCusMetrics(rpcRegisterName)
|
||||
reg, metric, err = metrics.NewGrpcPromObj(cusMetrics)
|
||||
options = append(options, mw.GrpcServer(), grpc.StreamInterceptor(metric.StreamServerInterceptor()),
|
||||
grpc.UnaryInterceptor(metric.UnaryServerInterceptor()))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user