Skip to content

Commit

Permalink
feat: return events with log offset
Browse files Browse the repository at this point in the history
  • Loading branch information
ZYunfeii committed Jul 25, 2022
1 parent 1b2c752 commit bab2b54
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions client/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
"github.com/linkall-labs/vanus/client/pkg/eventlog"
)

const (
XVanusLogOffset = eventlog.XVanusLogOffset
)

// EventBus functions.
var (
// OpenBusWriter open a Writer of EventBus identified by vrn.
Expand Down
1 change: 1 addition & 0 deletions client/internal/vanus/eventlog/log_segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func (s *logSegment) Read(ctx context.Context, from int64, size int16) ([]*ce.Ev
buf := make([]byte, 8)
binary.BigEndian.PutUint64(buf, uint64(offset))
e.SetExtension(eventlog.XVanusLogOffset, buf)
e.SetExtension(segment.XVanusBlockOffset, nil)
}

return events, err
Expand Down
5 changes: 2 additions & 3 deletions internal/store/segment/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package segment

import (
"context"
stdCtx "context"
"fmt"
"os"
"path"
Expand All @@ -40,7 +39,7 @@ func TestServer_RemoveBlock(t *testing.T) {
Convey("test RemoveBlock", t, func() {
cfg := store.Config{}
srv := NewServer(cfg).(*server)
ctx := stdCtx.Background()
ctx := context.Background()
Convey("test state checking", func() {
err := srv.RemoveBlock(ctx, vanus.NewID())
et := err.(*errors.ErrorType)
Expand All @@ -66,7 +65,7 @@ func TestServer_RemoveBlock(t *testing.T) {
}()
p := path.Join(dir, "/vanus/test/store/test")
_ = os.MkdirAll(p, 0777)
blk, err := file.Create(stdCtx.Background(), p, vanus.NewID(), 1024*1024*64)
blk, err := file.Create(context.Background(), p, vanus.NewID(), 1024*1024*64)
So(err, ShouldBeNil)

Convey("the block not found", func() {
Expand Down

0 comments on commit bab2b54

Please sign in to comment.