Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions index/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ func (w *Writer) SyncAndClose() error {
return w.Close()
}

func Write(path string, opts Params, index []Item) error {
func Write(path string, opts Params, index []Item) (retErr error) {
w, err := OpenWriter(path, opts)
if err != nil {
return err
}
defer func() { _ = w.Close() }() // ignoring since its only applicable if an error has happened
defer func() {
if retErr != nil {
_ = w.Close()
}
}()

for _, item := range index {
if err := w.Write(item); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion log.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var errDeleteRelative = fmt.Errorf("%w: delete relative offsets", message.ErrInv

// Open opens or creates a [Log] based on a dir and set of options
func Open(dir string, opts Options) (result Log, err error) {
if opts.Rollover == 0 {
if opts.Rollover <= 0 {
opts.Rollover = 1024 * 1024
}

Expand Down
2 changes: 1 addition & 1 deletion typed_blocking.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (l *tlogBlocking[K, V]) Publish(tmessages []TMessage[K, V]) (int64, error)
}

l.notify.Set(nextOffset)
return nextOffset, err
return nextOffset, nil
}

func (l *tlogBlocking[K, V]) ConsumeBlocking(ctx context.Context, offset int64, maxCount int64) (int64, []TMessage[K, V], error) {
Expand Down