-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(admin): use singleflight to handle Admin's RPCs (#482)
### What this PR does This PR makes the admin server handle RPCs by using singleflight. It helps the admin to reduce redundant computation, especially read operations. I am only altering read operations. However, it is possible to refactor the admin server to eliminate the use of a single big lock.
- Loading branch information
Showing
2 changed files
with
148 additions
and
4 deletions.
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
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,44 @@ | ||
package sfgkey | ||
|
||
import ( | ||
"github.com/kakao/varlog/pkg/types" | ||
) | ||
|
||
const ( | ||
delimiter = "_" | ||
keyGetStorageNode = "getsn" | ||
keyListStorageNodes = "listsns" | ||
keyGetTopic = "gettp" | ||
keyListTopics = "listtps" | ||
keyGetLogStream = "getls" | ||
keyListLogStreams = "listlss" | ||
keyDescribeTopic = "desctp" | ||
) | ||
|
||
func GetStorageNodeKey(snid types.StorageNodeID) string { | ||
return keyGetStorageNode + delimiter + snid.String() | ||
} | ||
|
||
func ListStorageNodesKey() string { | ||
return keyListStorageNodes | ||
} | ||
|
||
func GetTopicKey(tpid types.TopicID) string { | ||
return keyGetTopic + delimiter + tpid.String() | ||
} | ||
|
||
func ListTopicsKey() string { | ||
return keyListTopics | ||
} | ||
|
||
func GetLogStreamKey(tpid types.TopicID, lsid types.LogStreamID) string { | ||
return keyGetLogStream + delimiter + tpid.String() + delimiter + lsid.String() | ||
} | ||
|
||
func ListLogStreamsKey(tpid types.TopicID) string { | ||
return keyListLogStreams + delimiter + tpid.String() | ||
} | ||
|
||
func DescribeTopicKey(tpid types.TopicID) string { | ||
return keyDescribeTopic + delimiter + tpid.String() | ||
} |