fix: redis集群修复

This commit is contained in:
meilin.huang
2023-03-17 09:46:41 +08:00
parent 110abc4ac7
commit 738ff86344
8 changed files with 30 additions and 16 deletions

View File

@@ -9,7 +9,7 @@
<span v-if="data.type == NodeType.Redis">
<el-popover placement="right-start" title="redis实例信息" trigger="hover" :width="210">
<template #reference>
<SvgIcon name="iconfont icon-op-redis" :size="18"/>
<SvgIcon name="iconfont icon-op-redis" :size="18" />
</template>
<template #default>
<el-form class="instances-pop-form" label-width="50px" :size="'small'">
@@ -24,7 +24,7 @@
</el-popover>
</span>
<SvgIcon v-if="data.type == NodeType.Db" name="Coin" color="#67c23a"/>
<SvgIcon v-if="data.type == NodeType.Db" name="Coin" color="#67c23a" />
</template>
</tag-tree>
</el-col>
@@ -64,7 +64,7 @@
</div>
</el-form>
</el-col>
<el-table v-loading="state.loading" :data="state.keys" stripe :highlight-current-row="true"
<el-table v-loading="state.loading" :data="state.keys" :height="tableHeight" stripe :highlight-current-row="true"
style="cursor: pointer">
<el-table-column show-overflow-tooltip prop="key" label="key"></el-table-column>
<el-table-column prop="type" label="type" width="80">
@@ -79,10 +79,10 @@
</el-table-column>
<el-table-column label="操作">
<template #default="scope">
<el-button @click="getValue(scope.row)" type="success" icon="search" plain
size="small">查看
<el-button @click="getValue(scope.row)" type="success" icon="search" plain size="small">查看
</el-button>
<el-button v-auth="'redis:data:del'" @click="del(scope.row.key)" type="danger" icon="delete" plain size="small">删除
<el-button v-auth="'redis:data:del'" @click="del(scope.row.key)" type="danger" icon="delete"
plain size="small">删除
</el-button>
</template>
</el-table-column>
@@ -133,8 +133,8 @@ class NodeType {
}
const state = reactive({
instanceMenuMaxHeight: '600',
loading: false,
tableHeight: 600,
tags: [],
redisList: [] as any,
dbList: [],
@@ -176,6 +176,7 @@ const state = reactive({
});
const {
tableHeight,
scanParam,
dataEdit,
hashValueDialog,
@@ -190,7 +191,7 @@ onMounted(async () => {
})
const setHeight = () => {
state.instanceMenuMaxHeight = window.innerHeight - 115 + 'px';
state.tableHeight = window.innerHeight - 159;
}
/**
@@ -259,13 +260,18 @@ const nodeClick = (data: any) => {
*/
const getDbs = async (redisInfo: any) => {
let dbs: TagTreeNode[] = redisInfo.db.split(',').map((x: string) => {
return new TagTreeNode(x, x, NodeType.Db).withIsLeaf(true).withParams({
return new TagTreeNode(x, `db${x}`, NodeType.Db).withIsLeaf(true).withParams({
id: redisInfo.id,
db: x,
name: `db${x}`,
keys: 0,
})
})
if (redisInfo.mode == 'cluster') {
return dbs;
}
const res = await redisApi.redisInfo.request({ id: redisInfo.id, host: redisInfo.host, section: "Keyspace" });
for (let db in res.Keyspace) {
for (let d of dbs) {

View File

@@ -4,13 +4,13 @@ go 1.20
require (
github.com/gin-gonic/gin v1.9.0
github.com/go-redis/redis/v8 v8.11.5
github.com/go-sql-driver/mysql v1.7.0
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/gorilla/websocket v1.5.0
github.com/lib/pq v1.10.7
github.com/mojocn/base64Captcha v1.3.5 //
github.com/pkg/sftp v1.13.5
github.com/redis/go-redis/v9 v9.0.2
github.com/robfig/cron/v3 v3.0.1 //
github.com/sirupsen/logrus v1.9.0
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
@@ -24,7 +24,7 @@ require (
require (
github.com/bytedance/sonic v1.8.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
@@ -59,6 +59,5 @@ require (
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)

View File

@@ -87,6 +87,9 @@ func (d *dbAppImpl) Save(dbEntity *entity.Db) {
// 查找是否存在该库
oldDb := &entity.Db{Host: dbEntity.Host, Port: dbEntity.Port, Username: dbEntity.Username}
if dbEntity.SshTunnelMachineId > 0 {
oldDb.SshTunnelMachineId = dbEntity.SshTunnelMachineId
}
err := d.GetDbBy(oldDb)
if dbEntity.Id == 0 {

View File

@@ -62,6 +62,9 @@ func (m *machineAppImpl) Count(condition *entity.MachineQuery) int64 {
func (m *machineAppImpl) Save(me *entity.Machine) {
oldMachine := &entity.Machine{Ip: me.Ip, Port: me.Port, Username: me.Username}
if me.SshTunnelMachineId > 0 {
oldMachine.SshTunnelMachineId = me.SshTunnelMachineId
}
err := m.GetMachine(oldMachine)
me.PwdEncrypt()

View File

@@ -18,7 +18,7 @@ import (
"sync"
"time"
"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"
)
type Redis struct {

View File

@@ -18,7 +18,7 @@ import (
"strings"
"time"
"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"
)
type Redis interface {
@@ -81,6 +81,9 @@ func (r *redisAppImpl) Save(re *entity.Redis) {
// 查找是否存在该库
oldRedis := &entity.Redis{Host: re.Host}
if re.SshTunnelMachineId > 0 {
oldRedis.SshTunnelMachineId = re.SshTunnelMachineId
}
err := r.GetRedisBy(oldRedis)
if re.Id == 0 {

View File

@@ -4,7 +4,7 @@ import (
"context"
"time"
"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"
)
var cli *redis.Client

View File

@@ -7,7 +7,7 @@ import (
"mayfly-go/pkg/global"
"mayfly-go/pkg/rediscli"
"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"
)
func initRedis() {