-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cli supports zset data structures (#249) #310
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c79454e
feat: prevent repeated creation of grpc connections and various comma…
halalala222 1814336
style: imports format
halalala222 4160cb3
feat: use a single client instance for the entire FlyDB client
halalala222 096ad56
feat: add zset grpc service & register zset grpc service
halalala222 3a412fa
feat: add zset grpc client
halalala222 8dfcf92
feat: add zset cmd client & add zset command
halalala222 004c0d9
fix: go lint - ineffectual assignment to responseMembers (ineffassign)
halalala222 bf0b596
fix: accidental code modifications.
halalala222 1afd4cc
feat: add prefixes to constants to indicate the data structure they a…
halalala222 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,5 +44,6 @@ func init() { | |
\/__/ \/__/ \/__/ \/__/ | ||
`}, "\r\n")) | ||
}) | ||
App.OnClosing(close) | ||
register(App) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ByteStorage/FlyDB/db/grpc/client" | ||
) | ||
|
||
var ( | ||
Addr string | ||
cliClient *client.Client | ||
) | ||
|
||
func newClient() *client.Client { | ||
var err error | ||
if cliClient != nil { | ||
return cliClient | ||
} | ||
|
||
if cliClient, err = client.NewClient(Addr); err != nil { | ||
fmt.Println("new client error: ", err) | ||
} | ||
|
||
return cliClient | ||
} | ||
|
||
func close() error { | ||
if cliClient == nil { | ||
return nil | ||
} | ||
|
||
if err := cliClient.Close(); err != nil { | ||
return err | ||
} | ||
|
||
cliClient = nil | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package client | ||
|
||
import "math" | ||
|
||
const ( | ||
CommonKeyArg = "key" | ||
CommonMemberArg = "member" | ||
CommonMembersArg = "members" | ||
CommonValueArg = "value" | ||
|
||
CommonDefaultEmptyString = "" | ||
|
||
ZSetScoreArg = "score" | ||
ZSetStartArg = "start" | ||
ZSetEndArg = "end" | ||
ZSetIncrByArg = "incrBy" | ||
ZSetMinArg = "min" | ||
ZSetMaxArg = "max" | ||
|
||
ZSetDefaultScore = 0 | ||
ZSetDefaultRangeStart = 0 | ||
ZSetDefaultRangeEnd = math.MaxInt | ||
ZSetDefaultIncrBy = 0 | ||
ZSetDefaultMin = 0 | ||
ZSetDefaultMax = math.MaxInt | ||
|
||
ZSetDefaultKeyHelp = "the key of the zset" | ||
ZSetDefaultMemberHelp = "the member of the zset" | ||
ZSetDefaultMembersHelp = "the members of the zset, separated by space, e.g. member1 member2 member3" | ||
ZSetDefaultValueHelp = "the value of the zset" | ||
ZSetDefaultScoreHelp = "the score of the zset" | ||
ZSetDefaultStartHelp = "the start index of the zset" | ||
ZSetDefaultEndHelp = "the end index of the zset" | ||
ZSetDefaultIncrByHelp = "the increment value of the zset" | ||
ZSetDefaultMinHelp = "the min score of the zset" | ||
ZSetDefaultMaxHelp = "the max score of the zset" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package client | |
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/desertbit/grumble" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package client | |
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/desertbit/grumble" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not recommend creating
consts
files for azset
, but please add appropriate comments to the file if necessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid hardcoding strings like 'key' in the codebase,not only for zset other data structures like set,hash, can use for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this, so please add comments to it, for example for
zset
data structuresThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I misunderstood you before. I'll go and modify my code later.