Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
remove proto prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed Jan 23, 2014
1 parent c906836 commit 10bd647
Show file tree
Hide file tree
Showing 28 changed files with 293 additions and 295 deletions.
8 changes: 4 additions & 4 deletions append_entries_request.go
Expand Up @@ -15,13 +15,13 @@ type AppendEntriesRequest struct {
PrevLogTerm uint64
CommitIndex uint64
LeaderName string
Entries []*protobuf.ProtoLogEntry
Entries []*protobuf.LogEntry
}

// Creates a new AppendEntries request.
func newAppendEntriesRequest(term uint64, prevLogIndex uint64, prevLogTerm uint64,
commitIndex uint64, leaderName string, entries []*LogEntry) *AppendEntriesRequest {
pbEntries := make([]*protobuf.ProtoLogEntry, len(entries))
pbEntries := make([]*protobuf.LogEntry, len(entries))

for i := range entries {
pbEntries[i] = entries[i].pb
Expand All @@ -40,7 +40,7 @@ func newAppendEntriesRequest(term uint64, prevLogIndex uint64, prevLogTerm uint6
// Encodes the AppendEntriesRequest to a buffer. Returns the number of bytes
// written and any error that may have occurred.
func (req *AppendEntriesRequest) Encode(w io.Writer) (int, error) {
pb := &protobuf.ProtoAppendEntriesRequest{
pb := &protobuf.AppendEntriesRequest{
Term: proto.Uint64(req.Term),
PrevLogIndex: proto.Uint64(req.PrevLogIndex),
PrevLogTerm: proto.Uint64(req.PrevLogTerm),
Expand All @@ -66,7 +66,7 @@ func (req *AppendEntriesRequest) Decode(r io.Reader) (int, error) {
return -1, err
}

pb := new(protobuf.ProtoAppendEntriesRequest)
pb := new(protobuf.AppendEntriesRequest)
if err := proto.Unmarshal(data, pb); err != nil {
return -1, err
}
Expand Down
6 changes: 3 additions & 3 deletions append_entries_response.go
Expand Up @@ -10,14 +10,14 @@ import (

// The response returned from a server appending entries to the log.
type AppendEntriesResponse struct {
pb *protobuf.ProtoAppendEntriesResponse
pb *protobuf.AppendEntriesResponse
peer string
append bool
}

// Creates a new AppendEntries response.
func newAppendEntriesResponse(term uint64, success bool, index uint64, commitIndex uint64) *AppendEntriesResponse {
pb := &protobuf.ProtoAppendEntriesResponse{
pb := &protobuf.AppendEntriesResponse{
Term: proto.Uint64(term),
Index: proto.Uint64(index),
Success: proto.Bool(success),
Expand Down Expand Up @@ -64,7 +64,7 @@ func (resp *AppendEntriesResponse) Decode(r io.Reader) (int, error) {
return -1, err
}

resp.pb = new(protobuf.ProtoAppendEntriesResponse)
resp.pb = new(protobuf.AppendEntriesResponse)
if err := proto.Unmarshal(data, resp.pb); err != nil {
return -1, err
}
Expand Down
6 changes: 3 additions & 3 deletions log.go
Expand Up @@ -27,7 +27,7 @@ type Log struct {
mutex sync.RWMutex
startIndex uint64 // the index before the first entry in the Log entries
startTerm uint64
pLogEntry *protobuf.ProtoLogEntry
pLogEntry *protobuf.LogEntry
}

// The results of the applying a log entry.
Expand All @@ -46,7 +46,7 @@ type logResult struct {
func newLog() *Log {
return &Log{
entries: make([]*LogEntry, 0),
pLogEntry: &protobuf.ProtoLogEntry{},
pLogEntry: &protobuf.LogEntry{},
}
}

Expand Down Expand Up @@ -455,7 +455,7 @@ func (l *Log) truncate(index uint64, term uint64) error {
//--------------------------------------

// Appends a series of entries to the log.
func (l *Log) appendEntries(entries []*protobuf.ProtoLogEntry) error {
func (l *Log) appendEntries(entries []*protobuf.LogEntry) error {
l.mutex.Lock()
defer l.mutex.Unlock()

Expand Down
4 changes: 2 additions & 2 deletions log_entry.go
Expand Up @@ -12,7 +12,7 @@ import (

// A log entry stores a single item in the log.
type LogEntry struct {
pb *protobuf.ProtoLogEntry
pb *protobuf.LogEntry
Position int64 // position in the log file
log *Log
event *ev
Expand All @@ -33,7 +33,7 @@ func newLogEntry(log *Log, event *ev, index uint64, term uint64, command Command
}
}

pb := &protobuf.ProtoLogEntry{
pb := &protobuf.LogEntry{
Index: proto.Uint64(index),
Term: proto.Uint64(term),
CommandName: proto.String(commandName),
Expand Down
74 changes: 37 additions & 37 deletions protobuf/append_entries_request.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions protobuf/append_entries_request.proto
Expand Up @@ -15,11 +15,11 @@ option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;

message ProtoAppendEntriesRequest {
message AppendEntriesRequest {
required uint64 Term=1;
required uint64 PrevLogIndex=2;
required uint64 PrevLogTerm=3;
required uint64 CommitIndex=4;
required string LeaderName=5;
repeated ProtoLogEntry Entries=6;
repeated LogEntry Entries=6;
}

0 comments on commit 10bd647

Please sign in to comment.