func (dcmd *delCommand) Apply(server raft.Server) (interface{}, error) { if server.Name() == server.Leader() { return nil, nil } kvs := server.Context().(KVstore) err := kvs.Delete(dcmd.Key) return nil, err }
// Apply implements goraft Command interface's Apply function // It puts a key-value pair in KVstore func (pcmd *putCommand) Apply(server raft.Server) (interface{}, error) { if server.Name() == server.Leader() { return nil, nil } kvs := server.Context().(KVstore) err := kvs.Put(pcmd.Key, pcmd.Val) return nil, err }