Skip to content

Commit

Permalink
Merge pull request #54 from cmushroom/dev
Browse files Browse the repository at this point in the history
2.4.0
  • Loading branch information
chengpan168 committed Sep 18, 2022
2 parents ea399ab + 951ae43 commit 16fe479
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 138 deletions.
6 changes: 3 additions & 3 deletions .version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"latestVersionNum": 17,
"latestVersion": "2.3.0",
"latestVersionNum": 18,
"latestVersion": "2.4.0",
"updateType": "hint",
"releaseNotes": "1. 使用reids 连接池。 \n2. table通用组件支持拷贝行数据, 右键菜单添加快捷键。 #49 \n3. 文本框禁用情况下支持选中复制 #49。 \n4. 表格拖动排序问题修复。 \n5. 点击一个失败的链接,正常redis服务器也无法登录bug修复 #48。 \n6. redis client 重构。"
"releaseNotes": "1. 切换db Bug 修复 #53。 \n2. 连接池关闭错误修复。 \n3. 最小化到dock后无法唤起问题修复 #38。"
}
12 changes: 4 additions & 8 deletions redis-pro.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
430A09E225C1559400B60DFC /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430A09E125C1559400B60DFC /* FormLabel.swift */; };
430A09E625C155F800B60DFC /* FormItemText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430A09E525C155F800B60DFC /* FormItemText.swift */; };
431266CC261C450300FB6B69 /* Tag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431266CB261C450300FB6B69 /* Tag.swift */; };
431266CF261C4E0900FB6B69 /* RedisKeySearchRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431266CE261C4E0900FB6B69 /* RedisKeySearchRowView.swift */; };
431266D5261C5C9000FB6B69 /* ButtonTypeEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431266D4261C5C9000FB6B69 /* ButtonTypeEnum.swift */; };
431266D8261C66E100FB6B69 /* MTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431266D7261C66E100FB6B69 /* MTheme.swift */; };
431266DE261D45C500FB6B69 /* MIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 431266DD261D45C500FB6B69 /* MIcon.swift */; };
Expand Down Expand Up @@ -213,7 +212,6 @@
430A09E125C1559400B60DFC /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = "<group>"; };
430A09E525C155F800B60DFC /* FormItemText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormItemText.swift; sourceTree = "<group>"; };
431266CB261C450300FB6B69 /* Tag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tag.swift; sourceTree = "<group>"; };
431266CE261C4E0900FB6B69 /* RedisKeySearchRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedisKeySearchRowView.swift; sourceTree = "<group>"; };
431266D4261C5C9000FB6B69 /* ButtonTypeEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonTypeEnum.swift; sourceTree = "<group>"; };
431266D7261C66E100FB6B69 /* MTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MTheme.swift; sourceTree = "<group>"; };
431266DD261D45C500FB6B69 /* MIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MIcon.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -595,7 +593,6 @@
isa = PBXGroup;
children = (
62CB3D742619AEC20061E8C3 /* RedisKeysListView.swift */,
431266CE261C4E0900FB6B69 /* RedisKeySearchRowView.swift */,
437C09342649039000F1904C /* DatabasePicker.swift */,
);
path = Sidebar;
Expand Down Expand Up @@ -1026,7 +1023,6 @@
62E8F9D92765F197006A5326 /* MPasswordField.swift in Sources */,
431266F5261D912500FB6B69 /* StringEditorView.swift in Sources */,
43CD28AC267B67C600E11876 /* PuppyLogger.swift in Sources */,
431266CF261C4E0900FB6B69 /* RedisKeySearchRowView.swift in Sources */,
43F22EF5269FCE6000A00F97 /* DateHelper.swift in Sources */,
4314A34126243ED500053FEE /* PageBar.swift in Sources */,
62CB3D7D2619AF990061E8C3 /* RedisKeyModel.swift in Sources */,
Expand Down Expand Up @@ -1260,7 +1256,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 17;
CURRENT_PROJECT_VERSION = 18;
DEVELOPMENT_ASSET_PATHS = "\"redis-pro/Preview Content\"";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "redis-pro/Info.plist";
Expand All @@ -1269,7 +1265,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 2.3.0;
MARKETING_VERSION = 2.4.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.cmushroom.redis-pro";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1285,7 +1281,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 17;
CURRENT_PROJECT_VERSION = 18;
DEVELOPMENT_ASSET_PATHS = "\"redis-pro/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
Expand All @@ -1295,7 +1291,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 2.3.0;
MARKETING_VERSION = 2.4.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.cmushroom.redis-pro";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "5BE6502F-970F-4408-94FF-3C0CD5C53636"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redis-pro/Common/RedisClient/RediStackClient.swift"
Expand All @@ -55,17 +55,33 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "A2780896-FB71-452E-B32B-7FA169DB1346"
shouldBeEnabled = "Yes"
uuid = "C83B50A6-5CE2-4A4F-BC9F-34837FA9E29A"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redis-pro/Common/RedisClient/RediStackClient.swift"
filePath = "redis-pro/Common/RedisClient/RedisClientSystem.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "308"
endingLineNumber = "308"
landmarkName = "RediStackClient"
landmarkType = "3">
startingLineNumber = "22"
endingLineNumber = "22"
landmarkName = "selectDB(_:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "06DDB51C-119C-4DEF-80DB-9901923A6A49"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../../Library/Developer/Xcode/DerivedData/redis-pro-dqdhwgmlxxtepdhgbmpmdcldlrxf/SourcePackages/checkouts/RediStack/Sources/RediStack/Commands/ConnectionCommands.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "58"
endingLineNumber = "58"
landmarkName = "select(database:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
Expand Down
14 changes: 8 additions & 6 deletions redis-pro/Common/RedisClient/RediStackClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RediStackClient {
var redisModel:RedisModel

// conn
private let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 3)
private let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 2)
var connection:RedisConnection?
var connPool:RedisConnectionPool?

Expand Down Expand Up @@ -264,7 +264,7 @@ class RediStackClient {
, boundEventLoop: eventLoop)

pool.activate()

// _keepalive()
self.logger.info("init redis connection pool complete...")
return pool
Expand Down Expand Up @@ -305,10 +305,12 @@ class RediStackClient {
}

deinit {
logger.info("gracefully shutdown event loop group start...")
self.eventLoopGroup.shutdownGracefully({ _ in
self.logger.info("gracefully shutdown event loop group complete...")
})
do {
logger.info("gracefully shutdown event loop group start...")
try self.eventLoopGroup.syncShutdownGracefully()
} catch {
logger.info("gracefully shutdown event loop group error: \(error)")
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion redis-pro/Common/RedisClient/RedisClientSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import RediStack
extension RediStackClient {

func selectDB(_ database: Int) async -> Bool {

self.logger.info("select db: \(database)")
self.redisModel.database = database

self.connPool?.close()
self.connPool = nil

let command: RedisCommand<Void> = .select(database: database)
let _ = await send(command)
return true
Expand Down
2 changes: 1 addition & 1 deletion redis-pro/RedisProCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct RedisProCommands: Commands {
Button("New Tab", action: {

if let currentWindow = NSApp.keyWindow,
let windowController = currentWindow.windowController {
let windowController = currentWindow.windowController {
windowController.newWindowForTab(nil)
if let newWindow = NSApp.keyWindow,
currentWindow != newWindow {
Expand Down
23 changes: 18 additions & 5 deletions redis-pro/Store/DatabaseStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ struct DatabaseState: Equatable {
enum DatabaseAction:BindableAction, Equatable {
case initial
case getDatabases
case updateDatabases(Int)
case change(Int)
case setDB(Int)
case selectDB(Int)
case onDBChange(Int)
case none
case binding(BindingAction<DatabaseState>)
}
Expand All @@ -49,15 +50,27 @@ let databaseReducer = Reducer<DatabaseState, DatabaseAction, DatabaseEnvironment
case .getDatabases:
return .task {
let r = await env.redisInstanceModel.getClient().databases()
return .updateDatabases(r)
return .setDB(r)
}
.receive(on: env.mainQueue)
.eraseToEffect()
case let .updateDatabases(databases):
case let .setDB(databases):
state.databases = databases
return .none
case let .change(database):
case let .selectDB(database):
state.database = database

return .task {
let r = await env.redisInstanceModel.getClient().selectDB(database)
if r {
return .onDBChange(database)
}
return .none
}
.receive(on: env.mainQueue)
.eraseToEffect()

case .onDBChange:
return .none
case .none:
return .none
Expand Down
13 changes: 4 additions & 9 deletions redis-pro/Store/RedisKeysStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -349,17 +349,12 @@ let redisKeysReducer = Reducer<RedisKeysState, RedisKeysAction, RedisKeysEnviron
return .none

//MARK: --------------------------- database action ---------------------------
case let .databaseAction(.change(database)):
case let .databaseAction(.onDBChange(database)):
logger.info("change database, \(database)")
return .task {
let r = await env.redisInstanceModel.getClient().selectDB(database)
if r {
return .initial
}
return .none
return .result {
.success(.initial)
}
.receive(on: env.mainQueue)
.eraseToEffect()

case .databaseAction:
return .none

Expand Down
28 changes: 3 additions & 25 deletions redis-pro/Views/Sidebar/DatabasePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,15 @@ import SwiftUI
import ComposableArchitecture

struct DatabasePicker: View {
// @EnvironmentObject var redisInstanceModel:RedisInstanceModel
// @State private var databases:Int = 16
// @State var database:Int = 0
// @State var selection = 0
// var onChange: (() -> Void)?
//

var store:Store<DatabaseState, DatabaseAction>

var body: some View {
WithViewStore(store) {viewStore in

Menu(content: {
ForEach(0 ..< viewStore.databases, id: \.self) { item in
Button("DB\(item)", action: { viewStore.send(.change(item))})
Button("DB\(item)", action: { viewStore.send(.selectDB(item))})
.font(.system(size: 10.0))
.foregroundColor(.primary)
}
Expand All @@ -37,23 +32,6 @@ struct DatabasePicker: View {
}
}
}

//
// func onSelectDatabaseAction(_ database:Int) -> Void {
// Task {
// let r = await redisInstanceModel.getClient().selectDB(database)
// if r {
// self.database = database
// self.onChange?()
// }
// }
// }
//
// func queryDBList() -> Void {
// Task {
// let r = await redisInstanceModel.getClient().databases()
// self.databases = r
// }
// }

}

52 changes: 0 additions & 52 deletions redis-pro/Views/Sidebar/RedisKeySearchRowView.swift

This file was deleted.

Loading

0 comments on commit 16fe479

Please sign in to comment.