Skip to content
Open
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
5 changes: 5 additions & 0 deletions kvs.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,9 @@ func (ps *SwarmKvs) Delete(ctx context.Context, key []byte) error {
}
return nil
}

Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace on this line. Remove it to maintain code consistency.

Suggested change

Copilot uses AI. Check for mistakes.
// Close stops the mutex
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is inaccurate. According to the Index.Close() implementation, it closes the quit channel to stop the muxProcess goroutine, not a mutex. Consider updating the comment to better reflect what the function does, such as "Close stops the background process loop" or "Close shuts down the index".

Suggested change
// Close stops the mutex
// Close shuts down the index and stops the background process loop.

Copilot uses AI. Check for mistakes.
func (ps *SwarmKvs) Close() error {
return ps.idx.Close()
}

13 changes: 13 additions & 0 deletions kvs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,17 @@ func TestPotKvs_Save(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, val2, val)
})
t.Run("Create KVS, write to it, close it", func(t *testing.T) {
ls := createLs()
kvs1, _ := pot.NewSwarmKvs(ls)

err := kvs1.Put(ctx, key1, val1)
assert.NoError(t, err)

_, err = kvs1.Save(ctx)
assert.NoError(t, err)

err = kvs1.Close()
assert.NoError(t, err)
})
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace on this line. Remove it to maintain code consistency.

Suggested change
})
})

Copilot uses AI. Check for mistakes.
}
Loading