You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
starmap/server_basicrw.go

40 lines
876 B
Go

4 years ago
package starmap
import (
"b612.me/notify"
)
4 years ago
func (r *RemoteKv) dispatch(msg *notify.Message) {
switch msg.Key {
case "get":
data, err := r.kvmap.Get(msg.Value.MustToInterface())
msg.ReplyObj(kvMsg{
Key: msg.Value.MustToInterface(),
Value: data,
Err: newStarMapErr(err),
})
case "delete":
err := r.kvmap.Delete(msg.Value.MustToInterface())
msg.ReplyObj(kvMsg{
Key: msg.Value.MustToInterface(),
Value: nil,
Err: newStarMapErr(err),
})
case "exists":
ext := r.kvmap.Exists(msg.Value.MustToInterface())
msg.ReplyObj(kvMsg{
Key: msg.Value.MustToInterface(),
Value: ext,
Err: newStarMapErr(nil),
})
case "store":
ext := msg.Value.MustToInterface().(kvMsg)
err := r.kvmap.Store(ext.Key, ext.Value)
msg.ReplyObj(kvMsg{
Key: msg.Value.MustToInterface(),
Value: nil,
Err: newStarMapErr(err),
})
4 years ago
}
}