Commit e0a060fd authored by Sushant Mahajan's avatar Sushant Mahajan

completed reaft structure and started append

parent cab533d6
......@@ -26,7 +26,7 @@ type LogEntry interface {
}
type LogEntryData struct {
id uint64
id Lsn
data []byte
committed bool
}
......@@ -48,13 +48,15 @@ type SharedLog interface {
}
type Raft struct {
//some good stuff needs to go here
cluster *ClusterConfig //cluster
id uint64 //leader
commitCh chan LogEntry
}
var cluster_config *ClusterConfig
//make LogEntryData implement the
func (entry *LogEntryData) Lsn() uint64 {
func (entry *LogEntryData) Lsn() Lsn {
return entry.id
}
......@@ -67,8 +69,18 @@ func (entry *LogEntryData) Committed() bool {
}
//make raft implement the append function
//func (raft *Raft) Append(data []byte) (LogEntry, error) {
//}
func (raft *Raft) Append(data []byte) (LogEntry, error) {
if raft.server.Id != 0 {
return nil, raft.Id
}
temp := LogEntry{1, data, false}
//broadcast to other servers
//wait for acks
//send commit on channel
raft.commitCh <- temp
}
func AppendEntriesRPC()
func NewServerConfig(server_id int) (*ServerConfig, error) {
server := new(ServerConfig)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment