Skip to content
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

Go sharded client #43

Merged
merged 5 commits into from
Aug 4, 2022
Merged

Go sharded client #43

merged 5 commits into from
Aug 4, 2022

Conversation

kingster
Copy link
Member

Implements the sharded go-client #40

@kingster kingster requested a review from KalyanAkella April 19, 2021 07:15
@kingster kingster changed the title Go shared client Go sharded client Apr 19, 2021
@kingster kingster linked an issue Apr 19, 2021 that may be closed by this pull request
7 tasks
return m, nil
}

type SimpleDKVClient struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a public API(s) for initializing instances of this struct

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this private. There is already an existing api to create ctl.NewInSecureDKVClient(....)

BufferItems: 64,
OnExit: func(val interface{}) {
client := val.(*SimpleDKVClient)
log.Printf("Closing Client of %s \n", client.Addr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that Addr has this only logging usage here, please check if this log statement is needed. Or check if this can be logged from inside client.Close() itself.


type ShardProvider interface {
ProvideShard(key []byte) (*DKVShard, error)
ProvideShards(keys ...[]byte) (map[*DKVShard][][]byte, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the key used in the returned map is a pointer, only pointer equality is considered. In other words, the underlying DKVShard equality is never considered. Please check this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored it to return slice of DKVKeyGroup

clients/go/dkv/client.go Outdated Show resolved Hide resolved
clients/go/dkv/client.go Outdated Show resolved Hide resolved
clients/go/dkv/client.go Outdated Show resolved Hide resolved
clients/go/dkv/client.go Show resolved Hide resolved
clients/go/dkv/client.go Outdated Show resolved Hide resolved
shards []DKVShard
}

func NewShardedDKVClient(shardProvider ShardProvider) (*ShardedDKVClient, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please validate if the shardProvider is actually given.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

for _, serverRole := range role {
nodeSet, err = shard.GetNodesByType(serverRole)
if err == nil {
return nodeSet, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use return nil, err

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an early return, breaks out of the iteration by returning nodeSet

@kingster kingster force-pushed the go-shared-client branch 7 times, most recently from be8fe95 to e6ea193 Compare May 4, 2021 06:35
@kingster kingster self-assigned this May 4, 2021
@kingster kingster added the enhancement New feature or request label Jul 10, 2021
@kingster kingster merged commit 2ed6d9f into master Aug 4, 2022
@kingster kingster deleted the go-shared-client branch August 4, 2022 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GoLang based sharded client for DKV
2 participants