Skip to content

Commit

Permalink
refactor: Remove unnecessary code from proto/varlogpb/log_entry.go
Browse files Browse the repository at this point in the history
- replaced InvalidLogEntry with an empty LogEntry across the codebase
- removed proto/varlogpb/log_entry.go as it contained unused code
- updated related files to reflect these changes
  • Loading branch information
ijsong committed Dec 13, 2024
1 parent 9ab27cb commit a62e2db
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 24 deletions.
2 changes: 1 addition & 1 deletion internal/storagenode/client/log_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type SubscribeResult struct {
}

var InvalidSubscribeResult = SubscribeResult{
LogEntry: varlogpb.InvalidLogEntry(),
LogEntry: varlogpb.LogEntry{},
Error: errors.New("invalid subscribe result"),
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/varlog/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func (p *dispatcher) dispatch(_ context.Context) {
sentErr = sentErr || res.Error != nil
}
if !sentErr {
p.onNextFunc(varlogpb.InvalidLogEntry(), io.EOF)
p.onNextFunc(varlogpb.LogEntry{}, io.EOF)
}
}

Expand All @@ -532,7 +532,7 @@ type invalidSubscriber struct {
}

func (s invalidSubscriber) Next() (varlogpb.LogEntry, error) {
return varlogpb.InvalidLogEntry(), s.err
return varlogpb.LogEntry{}, s.err
}

func (s invalidSubscriber) Close() error {
Expand Down
7 changes: 3 additions & 4 deletions pkg/varlogtest/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (c *testAdmin) ListStorageNodes(ctx context.Context, opts ...varlog.AdminCa

return ret, nil
}

func (c *testAdmin) GetStorageNodes(ctx context.Context, opts ...varlog.AdminCallOption) (map[types.StorageNodeID]admpb.StorageNodeMetadata, error) {
snms, err := c.ListStorageNodes(ctx)
if err != nil {
Expand Down Expand Up @@ -182,8 +183,7 @@ func (c *testAdmin) AddTopic(ctx context.Context, opts ...varlog.AdminCallOption
c.vt.topics[topicID] = topicDesc
c.vt.trimGLSNs[topicID] = types.InvalidGLSN

invalidLogEntry := varlogpb.InvalidLogEntry()
c.vt.globalLogEntries[topicID] = []*varlogpb.LogEntry{&invalidLogEntry}
c.vt.globalLogEntries[topicID] = []*varlogpb.LogEntry{{}}

return proto.Clone(&topicDesc).(*varlogpb.TopicDescriptor), nil
}
Expand Down Expand Up @@ -294,8 +294,7 @@ func (c *testAdmin) AddLogStream(_ context.Context, topicID types.TopicID, logSt

c.vt.logStreams[logStreamID] = lsd

invalidLogEntry := varlogpb.InvalidLogEntry()
c.vt.localLogEntries[logStreamID] = []*varlogpb.LogEntry{&invalidLogEntry}
c.vt.localLogEntries[logStreamID] = []*varlogpb.LogEntry{{}}

topicDesc.LogStreams = append(topicDesc.LogStreams, logStreamID)
c.vt.topics[topicID] = topicDesc
Expand Down
7 changes: 3 additions & 4 deletions pkg/varlogtest/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (c *testLog) Subscribe(ctx context.Context, topicID types.TopicID, begin ty
for _, logEntry := range copiedLogEntries {
onNextFunc(logEntry, nil)
}
onNextFunc(varlogpb.InvalidLogEntry(), io.EOF)
onNextFunc(varlogpb.LogEntry{}, io.EOF)
}()

return func() {
Expand Down Expand Up @@ -319,7 +319,6 @@ func (c *testLog) PeekLogStream(ctx context.Context, tpid types.TopicID, lsid ty
GLSN: tail.GLSN,
}
return first, last, nil

}

func (c *testLog) AppendableLogStreams(tpid types.TopicID) map[types.LogStreamID]struct{} {
Expand Down Expand Up @@ -463,7 +462,7 @@ func newErrSubscriber(err error) *errSubscriber {
}

func (s errSubscriber) Next() (varlogpb.LogEntry, error) {
return varlogpb.InvalidLogEntry(), s.err
return varlogpb.LogEntry{}, s.err
}

func (s errSubscriber) Close() error {
Expand Down Expand Up @@ -496,7 +495,7 @@ func (s *subscriberImpl) Next() (varlogpb.LogEntry, error) {
logEntry, err := s.next()
if err != nil {
s.setErr(err)
return varlogpb.InvalidLogEntry(), err
return varlogpb.LogEntry{}, err
}
if s.cursor == s.end {
s.setErr(io.EOF)
Expand Down
13 changes: 0 additions & 13 deletions proto/varlogpb/log_entry.go

This file was deleted.

0 comments on commit a62e2db

Please sign in to comment.