Skip to content

Commit 88c1479

Browse files
committed
Merge branch 'main' of github.com:linkall-labs/vanus into segment
Signed-off-by: jyjiangkai <[email protected]>
2 parents 9351af1 + 4ed721d commit 88c1479

File tree

172 files changed

+4131
-2604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+4131
-2604
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ GIT_COMMIT=$(shell git log -1 --format='%h' | awk '{print $0}')
44
DATE=$(shell date +%Y-%m-%d_%H:%M:%S%z)
55
GO_VERSION=$(shell go version)
66

7-
export VANUS_LOG_LEVEL=debug
7+
export VANUS_LOG_LEVEL=info
88

99
DOCKER_REGISTRY ?= public.ecr.aws
1010
DOCKER_REPO ?= ${DOCKER_REGISTRY}/vanus

client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type client struct {
4040
}
4141

4242
func (c *client) Eventbus(ctx context.Context, ebName string) api.Eventbus {
43-
_, span := c.tracer.Start(ctx, "Eventbus")
43+
_, span := c.tracer.Start(ctx, "EventbusService")
4444
defer span.End()
4545

4646
bus := func() api.Eventbus {

client/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ require (
66
cloudevents.io/genproto v1.0.2
77
github.com/cloudevents/sdk-go/v2 v2.11.0
88
github.com/golang/mock v1.6.0
9-
github.com/linkall-labs/vanus/observability v0.5.0
10-
github.com/linkall-labs/vanus/pkg v0.5.0
11-
github.com/linkall-labs/vanus/proto v0.5.0
9+
github.com/linkall-labs/vanus/observability v0.5.1
10+
github.com/linkall-labs/vanus/pkg v0.5.1
11+
github.com/linkall-labs/vanus/proto v0.5.1
1212
github.com/scylladb/go-set v1.0.2
1313
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.36.4
1414
go.opentelemetry.io/otel/trace v1.11.1

client/internal/vanus/eventbus/name_service.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ package eventbus
1717
import (
1818
// standard libraries
1919
"context"
20+
"github.com/linkall-labs/vanus/pkg/cluster"
2021

2122
"github.com/linkall-labs/vanus/observability/tracing"
2223
"go.opentelemetry.io/otel/trace"
2324

24-
// third-party libraries
25-
"github.com/linkall-labs/vanus/pkg/controller"
2625
"google.golang.org/grpc/credentials/insecure"
2726

2827
// first-party libraries
@@ -33,7 +32,7 @@ import (
3332

3433
func NewNameService(endpoints []string) *NameService {
3534
return &NameService{
36-
client: controller.NewEventbusClient(endpoints, insecure.NewCredentials()),
35+
client: cluster.NewClusterController(endpoints, insecure.NewCredentials()).EventbusService().RawClient(),
3736
tracer: tracing.NewTracer("internal.discovery.eventbus", trace.SpanKindClient),
3837
}
3938
}

client/internal/vanus/eventlog/name_service.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ import (
2525
"google.golang.org/grpc/credentials/insecure"
2626

2727
// first-party libraries.
28+
"github.com/linkall-labs/vanus/observability/log"
2829
"github.com/linkall-labs/vanus/observability/tracing"
29-
"github.com/linkall-labs/vanus/pkg/controller"
30+
"github.com/linkall-labs/vanus/pkg/cluster"
3031
ctrlpb "github.com/linkall-labs/vanus/proto/pkg/controller"
3132
metapb "github.com/linkall-labs/vanus/proto/pkg/meta"
3233

3334
// this project.
34-
"github.com/linkall-labs/vanus/client/pkg/errors"
3535
"github.com/linkall-labs/vanus/client/pkg/record"
36+
"github.com/linkall-labs/vanus/pkg/errors"
3637
)
3738

3839
func NewNameService(endpoints []string) *NameService {
3940
return &NameService{
40-
client: controller.NewEventlogClient(endpoints, insecure.NewCredentials()),
41+
client: cluster.NewClusterController(endpoints, insecure.NewCredentials()).EventlogService().RawClient(),
4142
tracer: tracing.NewTracer("internal.discovery.eventlog", trace.SpanKindClient),
4243
}
4344
}
@@ -58,9 +59,18 @@ func (ns *NameService) LookupWritableSegment(ctx context.Context, logID uint64)
5859

5960
resp, err := ns.client.GetAppendableSegment(ctx, req)
6061
if err != nil {
62+
log.Warning(ctx, "failed to GetAppendableSegment", map[string]interface{}{
63+
"req": req,
64+
"res": resp,
65+
log.KeyError: err,
66+
})
6167
return nil, err
6268
}
6369

70+
log.Debug(ctx, "GetAppendableSegment result", map[string]interface{}{
71+
"req": req,
72+
"res": resp,
73+
})
6474
segments := toSegments(resp.GetSegments())
6575
if len(segments) == 0 {
6676
return nil, errors.ErrNotWritable

client/internal/vanus/net/rpc/bare/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ package bare
1717
import (
1818
// standard libraries
1919
"context"
20-
"github.com/linkall-labs/vanus/observability/tracing"
21-
"go.opentelemetry.io/otel/trace"
2220
"sync"
2321
"time"
2422

2523
// third-party libraries
24+
"go.opentelemetry.io/otel/trace"
2625
"go.uber.org/atomic"
2726
"google.golang.org/grpc"
2827
"google.golang.org/grpc/connectivity"
2928

3029
// this project
3130
"github.com/linkall-labs/vanus/client/internal/vanus/net/connection"
3231
"github.com/linkall-labs/vanus/client/internal/vanus/net/rpc"
33-
"github.com/linkall-labs/vanus/client/pkg/errors"
32+
"github.com/linkall-labs/vanus/observability/tracing"
33+
"github.com/linkall-labs/vanus/pkg/errors"
3434
)
3535

3636
const (

client/internal/vanus/store/allocator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ package store
1616

1717
import (
1818
"context"
19+
1920
"github.com/linkall-labs/vanus/observability/tracing"
2021
"go.opentelemetry.io/otel/trace"
2122

2223
// standard libraries.
2324
"sync"
2425

2526
// this project.
26-
"github.com/linkall-labs/vanus/client/pkg/errors"
27+
"github.com/linkall-labs/vanus/pkg/errors"
2728
)
2829

2930
func NewAllocator() *Allocator {

client/internal/vanus/store/block_store.go

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package store
1717
import (
1818
// standard libraries
1919
"context"
20-
"strings"
2120
"time"
2221

2322
"github.com/linkall-labs/vanus/observability/tracing"
@@ -27,18 +26,14 @@ import (
2726
cepb "cloudevents.io/genproto/v1"
2827
ce "github.com/cloudevents/sdk-go/v2"
2928
"google.golang.org/grpc"
30-
"google.golang.org/grpc/codes"
31-
"google.golang.org/grpc/status"
3229

3330
// first-party libraries
34-
3531
segpb "github.com/linkall-labs/vanus/proto/pkg/segment"
3632

3733
// this project
3834
"github.com/linkall-labs/vanus/client/internal/vanus/codec"
3935
"github.com/linkall-labs/vanus/client/internal/vanus/net/rpc"
4036
"github.com/linkall-labs/vanus/client/internal/vanus/net/rpc/bare"
41-
"github.com/linkall-labs/vanus/client/pkg/errors"
4237
"github.com/linkall-labs/vanus/client/pkg/primitive"
4338
)
4439

@@ -94,12 +89,7 @@ func (s *BlockStore) Append(ctx context.Context, block uint64, event *ce.Event)
9489

9590
res, err := client.(segpb.SegmentServerClient).AppendToBlock(_ctx, req)
9691
if err != nil {
97-
sts := status.Convert(err)
98-
// TODO: temporary scheme, wait for error code reconstruction
99-
if strings.Contains(sts.Message(), "SEGMENT_FULL") {
100-
return -1, errors.ErrNoSpace
101-
}
102-
return -1, errors.ErrNotWritable
92+
return -1, err
10393
}
10494
// TODO(Y. F. Zhang): batch events
10595
return res.GetOffsets()[0], nil
@@ -125,17 +115,6 @@ func (s *BlockStore) Read(
125115

126116
resp, err := client.(segpb.SegmentServerClient).ReadFromBlock(ctx, req)
127117
if err != nil {
128-
// TODO: convert error
129-
if errStatus, ok := status.FromError(err); ok {
130-
errMsg := errStatus.Message()
131-
if strings.Contains(errMsg, "the offset on end") {
132-
err = errors.ErrOnEnd
133-
} else if strings.Contains(errMsg, "the offset exceeded") {
134-
err = errors.ErrOverflow
135-
} else if errStatus.Code() == codes.DeadlineExceeded {
136-
err = errors.ErrTimeout
137-
}
138-
}
139118
return nil, err
140119
}
141120

client/mock_client.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/pkg/errors/errors.go

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)