diff --git a/client/internal/vanus/store/block_store.go b/client/internal/vanus/store/block_store.go index 0064dbdc5..e8c1bc340 100644 --- a/client/internal/vanus/store/block_store.go +++ b/client/internal/vanus/store/block_store.go @@ -38,13 +38,9 @@ import ( "github.com/linkall-labs/vanus/client/internal/vanus/codec" "github.com/linkall-labs/vanus/client/internal/vanus/net/rpc" "github.com/linkall-labs/vanus/client/internal/vanus/net/rpc/bare" - "github.com/linkall-labs/vanus/client/pkg/api" "github.com/linkall-labs/vanus/client/pkg/primitive" "github.com/linkall-labs/vanus/observability/log" -) - -const ( - defaultTaskChannelBuffer = 512 + "github.com/linkall-labs/vanus/pkg/errors" ) func newBlockStore(endpoint string) (*BlockStore, error) { @@ -56,94 +52,82 @@ func newBlockStore(endpoint string) (*BlockStore, error) { })), tracer: tracing.NewTracer("internal.store.BlockStore", trace.SpanKindClient), } - s.stream, err = s.connect(context.Background()) + s.appendStream, err = s.connectAppendStream(context.Background()) if err != nil { // TODO: check error return nil, err } - s.taskC = make(chan Task, defaultTaskChannelBuffer) - s.run(context.Background()) - s.receive(context.Background(), s.stream) + s.readStream, err = s.connectReadStream(context.Background()) + if err != nil { + // TODO: check error + return nil, err + } + s.runAppendStreamRecv(context.Background(), s.appendStream) + s.runReadStreamRecv(context.Background(), s.readStream) return s, nil } type BlockStore struct { primitive.RefCount - client rpc.Client - tracer *tracing.Tracer - stream segpb.SegmentServer_AppendToBlockStreamClient - taskC chan Task - callbacks sync.Map - mu sync.Mutex + client rpc.Client + tracer *tracing.Tracer + appendStream segpb.SegmentServer_AppendToBlockStreamClient + readStream segpb.SegmentServer_ReadFromBlockStreamClient + appendCallbacks sync.Map + readCallbacks sync.Map + appendMu sync.Mutex + readMu sync.Mutex } -type Task struct { - request *segpb.AppendToBlockStreamRequest - cb api.Callback -} +type appendCallback func(*segpb.AppendToBlockStreamResponse) +type readCallback func(*segpb.ReadFromBlockStreamResponse) -func (s *BlockStore) run(ctx context.Context) { +func (s *BlockStore) runAppendStreamRecv(ctx context.Context, stream segpb.SegmentServer_AppendToBlockStreamClient) { go func() { for { - var err error - select { - case <-ctx.Done(): - s.stream.CloseSend() - s.stream = nil - return - case task := <-s.taskC: - stream := s.stream - if stream == nil { - if stream, err = s.connect(ctx); err != nil { - task.cb(err) - break - } - s.receive(ctx, stream) - s.stream = stream - } - if err = stream.Send(task.request); err != nil { - log.Warning(ctx, "===Send failed===", map[string]interface{}{ - log.KeyError: err, - }) - s.processSendError(task, err) - } + res, err := stream.Recv() + if err != nil { + log.Error(ctx, "append stream recv failed", map[string]interface{}{ + log.KeyError: err, + }) + break + } + c, _ := s.appendCallbacks.LoadAndDelete(res.ResponseId) + if c != nil { + c.(appendCallback)(res) } } }() } -func (s *BlockStore) receive(ctx context.Context, stream segpb.SegmentServer_AppendToBlockStreamClient) { +func (s *BlockStore) runReadStreamRecv(ctx context.Context, stream segpb.SegmentServer_ReadFromBlockStreamClient) { go func() { for { res, err := stream.Recv() if err != nil { - log.Warning(ctx, "===Recv failed===", map[string]interface{}{ + log.Error(ctx, "read stream recv failed", map[string]interface{}{ log.KeyError: err, }) break } - c, _ := s.callbacks.LoadAndDelete(res.ResponseId) - if c == nil { - // TODO(jiangkai): check err - continue - } - if res.ResponseCode != segpb.ResponseCode_SUCCESS { - c.(api.Callback)(stderr.New(res.ResponseCode.String())) + c, _ := s.readCallbacks.LoadAndDelete(res.ResponseId) + if c != nil { + c.(readCallback)(res) } } }() } -func (s *BlockStore) connect(ctx context.Context) (segpb.SegmentServer_AppendToBlockStreamClient, error) { - if s.stream != nil { - return s.stream, nil +func (s *BlockStore) connectAppendStream(ctx context.Context) (segpb.SegmentServer_AppendToBlockStreamClient, error) { + if s.appendStream != nil { + return s.appendStream, nil } - s.mu.Lock() - defer s.mu.Unlock() + s.appendMu.Lock() + defer s.appendMu.Unlock() - if s.stream != nil { //double check - return s.stream, nil + if s.appendStream != nil { //double check + return s.appendStream, nil } client, err := s.client.Get(ctx) @@ -151,9 +135,9 @@ func (s *BlockStore) connect(ctx context.Context) (segpb.SegmentServer_AppendToB return nil, err } - stream, err := client.(segpb.SegmentServerClient).AppendToBlockStream(context.Background()) + stream, err := client.(segpb.SegmentServerClient).AppendToBlockStream(ctx) if err != nil { - log.Warning(ctx, "===Get Stream failed===", map[string]interface{}{ + log.Warning(ctx, "get append stream failed", map[string]interface{}{ log.KeyError: err, }) return nil, err @@ -161,15 +145,31 @@ func (s *BlockStore) connect(ctx context.Context) (segpb.SegmentServer_AppendToB return stream, nil } -func (s *BlockStore) processSendError(t Task, err error) { - cb, _ := s.callbacks.LoadAndDelete(t.request.RequestId) - if cb != nil { - cb.(api.Callback)(err) +func (s *BlockStore) connectReadStream(ctx context.Context) (segpb.SegmentServer_ReadFromBlockStreamClient, error) { + if s.readStream != nil { + return s.readStream, nil } - if stderr.Is(err, io.EOF) { - s.stream.CloseSend() - s.stream = nil + + s.readMu.Lock() + defer s.readMu.Unlock() + + if s.readStream != nil { //double check + return s.readStream, nil + } + + client, err := s.client.Get(ctx) + if err != nil { + return nil, err + } + + stream, err := client.(segpb.SegmentServerClient).ReadFromBlockStream(ctx) + if err != nil { + log.Warning(ctx, "get read stream failed", map[string]interface{}{ + log.KeyError: err, + }) + return nil, err } + return stream, nil } func (s *BlockStore) Endpoint() string { @@ -207,34 +207,79 @@ func (s *BlockStore) Append(ctx context.Context, block uint64, event *ce.Event) return res.GetOffsets()[0], nil } -func (s *BlockStore) AppendStream(ctx context.Context, block uint64, event *ce.Event, cb api.Callback) { - _, span := s.tracer.Start(ctx, "AppendStream") +func (s *BlockStore) SyncAppendStream(ctx context.Context, block uint64, event *ce.Event) (int64, error) { + _ctx, span := s.tracer.Start(ctx, "SyncAppendStream") defer span.End() var ( - err error + err error + wg sync.WaitGroup + resp *segpb.AppendToBlockStreamResponse ) - eventpb, err := codec.ToProto(event) - if err != nil { - cb(err) - return + if s.appendStream == nil { + s.appendStream, err = s.connectAppendStream(_ctx) + if err != nil { + return -1, err + } + s.runAppendStreamRecv(_ctx, s.appendStream) } // generate unique RequestId requestID := rand.Uint64() - s.callbacks.Store(requestID, cb) - task := Task{ - request: &segpb.AppendToBlockStreamRequest{ - RequestId: requestID, - BlockId: block, - Events: &cepb.CloudEventBatch{ - Events: []*cepb.CloudEvent{eventpb}, - }, + + wg.Add(1) + + eventpb, err := codec.ToProto(event) + if err != nil { + return -1, err + } + + s.appendCallbacks.Store(requestID, appendCallback(func(res *segpb.AppendToBlockStreamResponse) { + resp = res + wg.Done() + })) + + req := &segpb.AppendToBlockStreamRequest{ + RequestId: requestID, + BlockId: block, + Events: &cepb.CloudEventBatch{ + Events: []*cepb.CloudEvent{eventpb}, }, - cb: cb, } - s.taskC <- task + + if err = s.appendStream.Send(req); err != nil { + log.Error(ctx, "append stream send failed", map[string]interface{}{ + log.KeyError: err, + }) + if stderr.Is(err, io.EOF) { + s.appendStream.CloseSend() + s.appendStream = nil + c, _ := s.appendCallbacks.LoadAndDelete(requestID) + if c != nil { + c.(appendCallback)(&segpb.AppendToBlockStreamResponse{ + ResponseId: requestID, + ResponseCode: segpb.ResponseCode_UNKNOWN, + Offsets: []int64{}, + }) + } + } + return -1, err + } + + wg.Wait() + + if resp.ResponseCode == segpb.ResponseCode_SegmentFull { + log.Warning(ctx, "block append failed cause the segment is full", nil) + return -1, errors.ErrSegmentFull + } + + if resp.ResponseCode != segpb.ResponseCode_SUCCESS { + log.Warning(ctx, "block append failed cause unknown error", nil) + return -1, errors.ErrUnknown + } + + return resp.Offsets[0], nil } func (s *BlockStore) Read( @@ -278,6 +323,88 @@ func (s *BlockStore) Read( return []*ce.Event{}, err } +func (s *BlockStore) SyncReadStream( + ctx context.Context, block uint64, offset int64, size int16, pollingTimeout uint32, +) ([]*ce.Event, error) { + _ctx, span := s.tracer.Start(ctx, "SyncReadStream") + defer span.End() + + var ( + err error + wg sync.WaitGroup + resp *segpb.ReadFromBlockStreamResponse + ) + + if s.readStream == nil { + s.readStream, err = s.connectReadStream(_ctx) + if err != nil { + return []*ce.Event{}, err + } + s.runReadStreamRecv(_ctx, s.readStream) + } + + // generate unique RequestId + requestID := rand.Uint64() + + wg.Add(1) + + s.appendCallbacks.Store(requestID, readCallback(func(res *segpb.ReadFromBlockStreamResponse) { + resp = res + wg.Done() + })) + + req := &segpb.ReadFromBlockStreamRequest{ + BlockId: block, + Offset: offset, + Number: int64(size), + PollingTimeout: pollingTimeout, + } + + if err = s.readStream.Send(req); err != nil { + log.Error(ctx, "read stream send failed", map[string]interface{}{ + log.KeyError: err, + }) + if stderr.Is(err, io.EOF) { + s.readStream.CloseSend() + s.readStream = nil + c, _ := s.readCallbacks.LoadAndDelete(requestID) + if c != nil { + c.(readCallback)(&segpb.ReadFromBlockStreamResponse{ + ResponseId: requestID, + ResponseCode: segpb.ResponseCode_UNKNOWN, + Events: &cepb.CloudEventBatch{ + Events: []*cepb.CloudEvent{}, + }, + }) + } + } + return []*ce.Event{}, err + } + + wg.Wait() + + if resp.ResponseCode != segpb.ResponseCode_SUCCESS { + log.Warning(ctx, "block append failed cause unknown error", nil) + return []*ce.Event{}, errors.ErrUnknown + } + + if batch := resp.GetEvents(); batch != nil { + if eventpbs := batch.GetEvents(); len(eventpbs) > 0 { + events := make([]*ce.Event, 0, len(eventpbs)) + for _, eventpb := range eventpbs { + event, err2 := codec.FromProto(eventpb) + if err2 != nil { + // TODO: return events or error? + return events, err2 + } + events = append(events, event) + } + return events, nil + } + } + return []*ce.Event{}, errors.ErrUnknown +} + func (s *BlockStore) LookupOffset(ctx context.Context, blockID uint64, t time.Time) (int64, error) { ctx, span := s.tracer.Start(ctx, "LookupOffset") defer span.End() diff --git a/client/pkg/api/client.go b/client/pkg/api/client.go index 6f518e291..b3ac510b3 100644 --- a/client/pkg/api/client.go +++ b/client/pkg/api/client.go @@ -37,11 +37,12 @@ type Eventbus interface { type BusWriter interface { AppendOne(ctx context.Context, event *ce.Event, opts ...WriteOption) (eid string, err error) AppendMany(ctx context.Context, events []*ce.Event, opts ...WriteOption) (eid string, err error) - AppendOneStream(ctx context.Context, event *ce.Event, cb Callback, opts ...WriteOption) + SyncAppendOneStream(ctx context.Context, event *ce.Event, opts ...WriteOption) (eid string, err error) } type BusReader interface { Read(ctx context.Context, opts ...ReadOption) ([]*ce.Event, int64, uint64, error) + SyncReadStream(ctx context.Context, opts ...ReadOption) ([]*ce.Event, int64, uint64, error) } type Eventlog interface { diff --git a/client/pkg/api/mock_client.go b/client/pkg/api/mock_client.go index 288eedf98..21ed1ed96 100644 --- a/client/pkg/api/mock_client.go +++ b/client/pkg/api/mock_client.go @@ -186,21 +186,24 @@ func (mr *MockBusWriterMockRecorder) AppendOne(ctx, event interface{}, opts ...i return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendOne", reflect.TypeOf((*MockBusWriter)(nil).AppendOne), varargs...) } -// AppendOneStream mocks base method. -func (m *MockBusWriter) AppendOneStream(ctx context.Context, event *v2.Event, cb Callback, opts ...WriteOption) { +// SyncAppendOneStream mocks base method. +func (m *MockBusWriter) SyncAppendOneStream(ctx context.Context, event *v2.Event, opts ...WriteOption) (string, error) { m.ctrl.T.Helper() - varargs := []interface{}{ctx, event, cb} + varargs := []interface{}{ctx, event} for _, a := range opts { varargs = append(varargs, a) } - m.ctrl.Call(m, "AppendOneStream", varargs...) + ret := m.ctrl.Call(m, "SyncAppendOneStream", varargs...) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// AppendOneStream indicates an expected call of AppendOneStream. -func (mr *MockBusWriterMockRecorder) AppendOneStream(ctx, event, cb interface{}, opts ...interface{}) *gomock.Call { +// SyncAppendOneStream indicates an expected call of SyncAppendOneStream. +func (mr *MockBusWriterMockRecorder) SyncAppendOneStream(ctx, event interface{}, opts ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, event, cb}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendOneStream", reflect.TypeOf((*MockBusWriter)(nil).AppendOneStream), varargs...) + varargs := append([]interface{}{ctx, event}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncAppendOneStream", reflect.TypeOf((*MockBusWriter)(nil).SyncAppendOneStream), varargs...) } // MockBusReader is a mock of BusReader interface. @@ -248,6 +251,28 @@ func (mr *MockBusReaderMockRecorder) Read(ctx interface{}, opts ...interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockBusReader)(nil).Read), varargs...) } +// SyncReadStream mocks base method. +func (m *MockBusReader) SyncReadStream(ctx context.Context, opts ...ReadOption) ([]*v2.Event, int64, uint64, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SyncReadStream", varargs...) + ret0, _ := ret[0].([]*v2.Event) + ret1, _ := ret[1].(int64) + ret2, _ := ret[2].(uint64) + ret3, _ := ret[3].(error) + return ret0, ret1, ret2, ret3 +} + +// SyncReadStream indicates an expected call of SyncReadStream. +func (mr *MockBusReaderMockRecorder) SyncReadStream(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncReadStream", reflect.TypeOf((*MockBusReader)(nil).SyncReadStream), varargs...) +} + // MockEventlog is a mock of Eventlog interface. type MockEventlog struct { ctrl *gomock.Controller diff --git a/client/pkg/eventbus/eventbus.go b/client/pkg/eventbus/eventbus.go index 399927922..f5fb5abae 100644 --- a/client/pkg/eventbus/eventbus.go +++ b/client/pkg/eventbus/eventbus.go @@ -478,8 +478,8 @@ func (w *busWriter) AppendOne(ctx context.Context, event *ce.Event, opts ...api. return encoded, nil } -func (w *busWriter) AppendOneStream(ctx context.Context, event *ce.Event, cb api.Callback, opts ...api.WriteOption) { - _ctx, span := w.tracer.Start(ctx, "AppendOneStream") +func (w *busWriter) SyncAppendOneStream(ctx context.Context, event *ce.Event, opts ...api.WriteOption) (eid string, err error) { + _ctx, span := w.tracer.Start(ctx, "SyncAppendOneStream") defer span.End() var writeOpts *api.WriteOptions = w.opts @@ -493,12 +493,22 @@ func (w *busWriter) AppendOneStream(ctx context.Context, event *ce.Event, cb api // 1. pick a writer of eventlog lw, err := w.pickWritableLog(_ctx, writeOpts) if err != nil { - cb(err) - return + return "", err } // 2. append the event to the eventlog - lw.AppendStream(_ctx, event, cb) + off, err := lw.SyncAppendStream(_ctx, event) + if err != nil { + return "", err + } + + // 3. generate event ID + var buf [16]byte + binary.BigEndian.PutUint64(buf[0:8], lw.Log().ID()) + binary.BigEndian.PutUint64(buf[8:16], uint64(off)) + encoded := base64.StdEncoding.EncodeToString(buf[:]) + + return encoded, nil } func (w *busWriter) AppendMany(ctx context.Context, events []*ce.Event, opts ...api.WriteOption) (eid string, err error) { @@ -567,6 +577,38 @@ func (r *busReader) Read(ctx context.Context, opts ...api.ReadOption) ([]*ce.Eve return events, off, lr.Log().ID(), nil } +func (r *busReader) SyncReadStream(ctx context.Context, opts ...api.ReadOption) ([]*ce.Event, int64, uint64, error) { + _ctx, span := r.tracer.Start(ctx, "Read") + defer span.End() + + var readOpts *api.ReadOptions = r.opts + if len(opts) > 0 { + readOpts = r.opts.Copy() + for _, opt := range opts { + opt(readOpts) + } + } + + // 1. pick a reader of eventlog + lr, err := r.pickReadableLog(_ctx, readOpts) + if err != nil { + return []*ce.Event{}, 0, 0, err + } + + // TODO(jiangkai): refactor eventlog interface to avoid seek every time, by jiangkai, 2022.10.24 + off, err := lr.Seek(_ctx, readOpts.Policy.Offset(), io.SeekStart) + if err != nil { + return []*ce.Event{}, 0, 0, err + } + + // 2. read the event to the eventlog + events, err := lr.SyncReadStream(_ctx, int16(readOpts.BatchSize)) + if err != nil { + return []*ce.Event{}, 0, 0, err + } + return events, off, lr.Log().ID(), nil +} + func (r *busReader) Bus() api.Eventbus { return r.ebus } diff --git a/client/pkg/eventlog/eventlog.go b/client/pkg/eventlog/eventlog.go index 1af467e99..58a319e90 100644 --- a/client/pkg/eventlog/eventlog.go +++ b/client/pkg/eventlog/eventlog.go @@ -51,7 +51,7 @@ type LogWriter interface { Append(ctx context.Context, event *ce.Event) (off int64, err error) - AppendStream(ctx context.Context, event *ce.Event, cb api.Callback) + SyncAppendStream(ctx context.Context, event *ce.Event) (int64, error) } type LogReader interface { @@ -62,6 +62,8 @@ type LogReader interface { // TODO: async Read(ctx context.Context, size int16) (events []*ce.Event, err error) + SyncReadStream(ctx context.Context, size int16) (events []*ce.Event, err error) + // Seek sets the offset for the next Read to offset, // interpreted according to whence. // diff --git a/client/pkg/eventlog/eventlog_impl.go b/client/pkg/eventlog/eventlog_impl.go index c7132bfae..97d716e7b 100644 --- a/client/pkg/eventlog/eventlog_impl.go +++ b/client/pkg/eventlog/eventlog_impl.go @@ -30,7 +30,6 @@ import ( // this project. el "github.com/linkall-labs/vanus/client/internal/vanus/eventlog" - "github.com/linkall-labs/vanus/client/pkg/api" "github.com/linkall-labs/vanus/client/pkg/record" vlog "github.com/linkall-labs/vanus/observability/log" "github.com/linkall-labs/vanus/pkg/errors" @@ -386,13 +385,43 @@ func (w *logWriter) doAppend(ctx context.Context, event *ce.Event) (int64, error return offset, nil } -func (w *logWriter) AppendStream(ctx context.Context, event *ce.Event, cb api.Callback) { +func (w *logWriter) SyncAppendStream(ctx context.Context, event *ce.Event) (int64, error) { + // TODO: async for throughput + + retryTimes := defaultRetryTimes + for i := 1; i <= retryTimes; i++ { + offset, err := w.doSyncAppendStream(ctx, event) + if err == nil { + return offset, nil + } + vlog.Warning(ctx, "failed to Append", map[string]interface{}{ + vlog.KeyError: err, + "offset": offset, + }) + if errors.Is(err, errors.ErrSegmentFull) { + if i < retryTimes { + continue + } + } + return -1, err + } + + return -1, errors.ErrUnknown +} + +func (w *logWriter) doSyncAppendStream(ctx context.Context, event *ce.Event) (int64, error) { segment, err := w.selectWritableSegment(ctx) if err != nil { - cb(err) - return + return -1, err } - segment.AppendStream(ctx, event, cb) + offset, err := segment.SyncAppendStream(ctx, event) + if err != nil { + if errors.Is(err, errors.ErrSegmentFull) { + segment.SetNotWritable() + } + return -1, err + } + return offset, nil } func (w *logWriter) selectWritableSegment(ctx context.Context) (*segment, error) { @@ -470,6 +499,38 @@ func (r *logReader) Read(ctx context.Context, size int16) ([]*ce.Event, error) { return events, nil } +func (r *logReader) SyncReadStream(ctx context.Context, size int16) ([]*ce.Event, error) { + if r.cur == nil { + segment, err := r.elog.selectReadableSegment(ctx, r.pos) + if errors.Is(err, errors.ErrOffsetOnEnd) { + r.elog.refreshReadableSegments(ctx) + segment, err = r.elog.selectReadableSegment(ctx, r.pos) + } + if err != nil { + return nil, err + } + r.cur = segment + } + + events, err := r.cur.SyncReadStream(ctx, r.pos, size, uint32(r.pollingTimeout(ctx))) + if err != nil { + if errors.Is(err, errors.ErrOffsetOverflow) { + r.elog.refreshReadableSegments(ctx) + if r.switchSegment(ctx) { + return nil, errors.ErrTryAgain + } + } + return nil, err + } + + r.pos += int64(len(events)) + if r.pos == r.cur.EndOffset() { + r.switchSegment(ctx) + } + + return events, nil +} + func (r *logReader) pollingTimeout(ctx context.Context) int64 { if r.cfg.PollingTimeout == 0 { return 0 diff --git a/client/pkg/eventlog/log_segment.go b/client/pkg/eventlog/log_segment.go index bd81bfd4d..25f83f35b 100644 --- a/client/pkg/eventlog/log_segment.go +++ b/client/pkg/eventlog/log_segment.go @@ -33,7 +33,7 @@ import ( segpb "github.com/linkall-labs/vanus/proto/pkg/segment" // this project. - "github.com/linkall-labs/vanus/client/pkg/api" + "github.com/linkall-labs/vanus/client/pkg/record" "github.com/linkall-labs/vanus/pkg/errors" ) @@ -171,16 +171,19 @@ func (s *segment) Append(ctx context.Context, event *ce.Event) (int64, error) { return off + s.startOffset, nil } -func (s *segment) AppendStream(ctx context.Context, event *ce.Event, cb api.Callback) { +func (s *segment) SyncAppendStream(ctx context.Context, event *ce.Event) (int64, error) { _ctx, span := s.tracer.Start(ctx, "AppendStream") defer span.End() b := s.preferSegmentBlock() if b == nil { - cb(errors.ErrNotLeader) - return + return -1, errors.ErrNotLeader + } + off, err := b.SyncAppendStream(_ctx, event) + if err != nil { + return -1, err } - b.AppendStream(_ctx, event, cb) + return off + s.startOffset, nil } func (s *segment) Read(ctx context.Context, from int64, size int16, pollingTimeout uint32) ([]*ce.Event, error) { @@ -227,6 +230,50 @@ func (s *segment) Read(ctx context.Context, from int64, size int16, pollingTimeo return events, err } +func (s *segment) SyncReadStream(ctx context.Context, from int64, size int16, pollingTimeout uint32) ([]*ce.Event, error) { + if from < s.startOffset { + return nil, errors.ErrOffsetUnderflow + } + ctx, span := s.tracer.Start(ctx, "Read") + defer span.End() + + if eo := s.endOffset.Load(); eo >= 0 { + if from > eo { + return nil, errors.ErrOffsetOverflow + } + if int64(size) > eo-from { + size = int16(eo - from) + } + } + // TODO: cached read + b := s.preferSegmentBlock() + if b == nil { + return nil, errors.ErrBlockNotFound + } + events, err := b.SyncReadStream(ctx, from-s.startOffset, size, pollingTimeout) + if err != nil { + return nil, err + } + + for _, e := range events { + v, ok := e.Extensions()[segpb.XVanusBlockOffset] + if !ok { + continue + } + off, ok := v.(int32) + if !ok { + return events, errors.ErrCorruptedEvent + } + offset := s.startOffset + int64(off) + buf := make([]byte, 8) + binary.BigEndian.PutUint64(buf, uint64(offset)) + e.SetExtension(XVanusLogOffset, buf) + e.SetExtension(segpb.XVanusBlockOffset, nil) + } + + return events, err +} + func (s *segment) preferSegmentBlock() *block { s.mu.RLock() defer s.mu.RUnlock() diff --git a/client/pkg/eventlog/segment_block.go b/client/pkg/eventlog/segment_block.go index 3abc06001..329ff09eb 100644 --- a/client/pkg/eventlog/segment_block.go +++ b/client/pkg/eventlog/segment_block.go @@ -23,7 +23,6 @@ import ( // this project "github.com/linkall-labs/vanus/client/internal/vanus/store" - "github.com/linkall-labs/vanus/client/pkg/api" "github.com/linkall-labs/vanus/client/pkg/record" "github.com/linkall-labs/vanus/pkg/errors" ) @@ -57,8 +56,8 @@ func (s *block) Append(ctx context.Context, event *ce.Event) (int64, error) { return s.store.Append(ctx, s.id, event) } -func (s *block) AppendStream(ctx context.Context, event *ce.Event, cb api.Callback) { - s.store.AppendStream(ctx, s.id, event, cb) +func (s *block) SyncAppendStream(ctx context.Context, event *ce.Event) (int64, error) { + return s.store.SyncAppendStream(ctx, s.id, event) } func (s *block) Read(ctx context.Context, offset int64, size int16, pollingTimeout uint32) ([]*ce.Event, error) { @@ -74,3 +73,17 @@ func (s *block) Read(ctx context.Context, offset int64, size int16, pollingTimeo } return s.store.Read(ctx, s.id, offset, size, pollingTimeout) } + +func (s *block) SyncReadStream(ctx context.Context, offset int64, size int16, pollingTimeout uint32) ([]*ce.Event, error) { + if offset < 0 { + return nil, errors.ErrOffsetUnderflow + } + if size > 0 { + // doRead + } else if size == 0 { + return make([]*ce.Event, 0), nil + } else if size < 0 { + return nil, errors.ErrInvalidArgument + } + return s.store.SyncReadStream(ctx, s.id, offset, size, pollingTimeout) +} diff --git a/internal/store/segment/api.go b/internal/store/segment/api.go index e61e6c730..d0565c0d9 100644 --- a/internal/store/segment/api.go +++ b/internal/store/segment/api.go @@ -17,19 +17,18 @@ package segment import ( // standard libraries. "context" - "sync" // third-party libraries. cepb "cloudevents.io/genproto/v1" "google.golang.org/protobuf/types/known/emptypb" // first-party libraries. + "github.com/linkall-labs/vanus/pkg/errors" segpb "github.com/linkall-labs/vanus/proto/pkg/segment" // this project. "github.com/linkall-labs/vanus/internal/primitive/vanus" "github.com/linkall-labs/vanus/observability/log" - "github.com/linkall-labs/vanus/pkg/errors" ) type segmentServer struct { @@ -125,77 +124,89 @@ func (s *segmentServer) AppendToBlock( if err != nil { return nil, err } - return &segpb.AppendToBlockResponse{Offsets: offs}, nil } func (s *segmentServer) AppendToBlockStream(stream segpb.SegmentServer_AppendToBlockStreamServer) error { - var ( - wg sync.WaitGroup - errc chan error - ) - errc = make(chan error, 1) - ctx, cancel := context.WithCancel(context.Background()) - go func() { - defer wg.Done() - for { - select { - case <-ctx.Done(): - return - default: - request, err := stream.Recv() - if err != nil { - log.Warning(ctx, "===Recv failed===", map[string]interface{}{ - log.KeyError: err, - }) - errc <- err - return + ctx := context.Background() + for { + request, err := stream.Recv() + if err != nil { + log.Warning(ctx, "append stream recv failed", map[string]interface{}{ + log.KeyError: err, + }) + return err + } + + go func(stream segpb.SegmentServer_AppendToBlockStreamServer, req *segpb.AppendToBlockStreamRequest) { + responseCode := segpb.ResponseCode_SUCCESS + offsets, err := s.srv.AppendToBlock(ctx, vanus.ID(request.BlockId), request.Events.Events) + if err != nil { + if errors.Is(err, errors.ErrSegmentFull) { + responseCode = segpb.ResponseCode_SegmentFull + } else { + responseCode = segpb.ResponseCode_UNKNOWN } + log.Error(ctx, "append to block failed", map[string]interface{}{ + log.KeyError: err, + }) + } - wg.Add(1) - go func() { - defer wg.Done() - offsets, err := s.srv.AppendToBlock(ctx, vanus.ID(request.BlockId), request.Events.Events) - responseCode := segpb.ResponseCode_SUCCESS - if err != nil { - log.Warning(ctx, "===AppendToBlock failed===", map[string]interface{}{ - log.KeyError: err, - }) - if errors.Is(err, errors.ErrSegmentFull) { - responseCode = segpb.ResponseCode_SegmentFull - } - responseCode = segpb.ResponseCode_UNKNOWN - } - - err = stream.Send(&segpb.AppendToBlockStreamResponse{ - ResponseId: request.RequestId, - ResponseCode: responseCode, - Offsets: offsets, - }) - if err != nil { - log.Warning(ctx, "===Send failed===", map[string]interface{}{ - log.KeyError: err, - }) - errc <- err - cancel() - return - } - }() + err = stream.Send(&segpb.AppendToBlockStreamResponse{ + ResponseId: request.RequestId, + ResponseCode: responseCode, + Offsets: offsets, + }) + if err != nil { + log.Warning(ctx, "read stream send failed", map[string]interface{}{ + log.KeyError: err, + }) + return } + }(stream, request) + } +} + +func (s *segmentServer) ReadFromBlockStream(stream segpb.SegmentServer_ReadFromBlockStreamServer) error { + ctx := context.Background() + for { + request, err := stream.Recv() + if err != nil { + log.Error(ctx, "read stream recv failed", map[string]interface{}{ + log.KeyError: err, + }) + return err } - }() - - var err error - select { - case err = <-errc: - log.Warning(ctx, "===AppendToBlockStream Exit===", map[string]interface{}{ - log.KeyError: err, - }) - case <-stream.Context().Done(): - err = stream.Context().Err() + + go func(stream segpb.SegmentServer_ReadFromBlockStreamServer, req *segpb.ReadFromBlockStreamRequest) { + responseCode := segpb.ResponseCode_SUCCESS + blockID := vanus.NewIDFromUint64(req.BlockId) + events, err := s.srv.ReadFromBlock(ctx, blockID, req.Offset, int(req.Number), req.PollingTimeout) + if err != nil { + responseCode = segpb.ResponseCode_UNKNOWN + log.Error(ctx, "read from block failed", map[string]interface{}{ + log.KeyError: err, + }) + } + + err = stream.Send(&segpb.ReadFromBlockStreamResponse{ + ResponseId: request.RequestId, + ResponseCode: responseCode, + Events: &cepb.CloudEventBatch{Events: events}, + }) + if err != nil { + log.Error(ctx, "read stream send failed", map[string]interface{}{ + log.KeyError: err, + }) + return + } + }(stream, request) } - wg.Wait() - return err +} + +func (s *segmentServer) AppendToBlockAsyncStream(stream segpb.SegmentServer_AppendToBlockAsyncStreamServer) error { + // TODO(jiangkai): implementation AppendToBlockAsyncStream() + return nil } func (s *segmentServer) ReadFromBlock( diff --git a/proto/pkg/segment/mock_segment.go b/proto/pkg/segment/mock_segment.go index 163877088..f42600e54 100644 --- a/proto/pkg/segment/mock_segment.go +++ b/proto/pkg/segment/mock_segment.go @@ -77,6 +77,26 @@ func (mr *MockSegmentServerClientMockRecorder) AppendToBlock(ctx, in interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendToBlock", reflect.TypeOf((*MockSegmentServerClient)(nil).AppendToBlock), varargs...) } +// AppendToBlockAsyncStream mocks base method. +func (m *MockSegmentServerClient) AppendToBlockAsyncStream(ctx context.Context, opts ...grpc.CallOption) (SegmentServer_AppendToBlockAsyncStreamClient, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "AppendToBlockAsyncStream", varargs...) + ret0, _ := ret[0].(SegmentServer_AppendToBlockAsyncStreamClient) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AppendToBlockAsyncStream indicates an expected call of AppendToBlockAsyncStream. +func (mr *MockSegmentServerClientMockRecorder) AppendToBlockAsyncStream(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendToBlockAsyncStream", reflect.TypeOf((*MockSegmentServerClient)(nil).AppendToBlockAsyncStream), varargs...) +} + // AppendToBlockStream mocks base method. func (m *MockSegmentServerClient) AppendToBlockStream(ctx context.Context, opts ...grpc.CallOption) (SegmentServer_AppendToBlockStreamClient, error) { m.ctrl.T.Helper() @@ -197,6 +217,26 @@ func (mr *MockSegmentServerClientMockRecorder) ReadFromBlock(ctx, in interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadFromBlock", reflect.TypeOf((*MockSegmentServerClient)(nil).ReadFromBlock), varargs...) } +// ReadFromBlockStream mocks base method. +func (m *MockSegmentServerClient) ReadFromBlockStream(ctx context.Context, opts ...grpc.CallOption) (SegmentServer_ReadFromBlockStreamClient, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ReadFromBlockStream", varargs...) + ret0, _ := ret[0].(SegmentServer_ReadFromBlockStreamClient) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReadFromBlockStream indicates an expected call of ReadFromBlockStream. +func (mr *MockSegmentServerClientMockRecorder) ReadFromBlockStream(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadFromBlockStream", reflect.TypeOf((*MockSegmentServerClient)(nil).ReadFromBlockStream), varargs...) +} + // RemoveBlock mocks base method. func (m *MockSegmentServerClient) RemoveBlock(ctx context.Context, in *RemoveBlockRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { m.ctrl.T.Helper() @@ -414,6 +454,280 @@ func (mr *MockSegmentServer_AppendToBlockStreamClientMockRecorder) Trailer() *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Trailer", reflect.TypeOf((*MockSegmentServer_AppendToBlockStreamClient)(nil).Trailer)) } +// MockSegmentServer_ReadFromBlockStreamClient is a mock of SegmentServer_ReadFromBlockStreamClient interface. +type MockSegmentServer_ReadFromBlockStreamClient struct { + ctrl *gomock.Controller + recorder *MockSegmentServer_ReadFromBlockStreamClientMockRecorder +} + +// MockSegmentServer_ReadFromBlockStreamClientMockRecorder is the mock recorder for MockSegmentServer_ReadFromBlockStreamClient. +type MockSegmentServer_ReadFromBlockStreamClientMockRecorder struct { + mock *MockSegmentServer_ReadFromBlockStreamClient +} + +// NewMockSegmentServer_ReadFromBlockStreamClient creates a new mock instance. +func NewMockSegmentServer_ReadFromBlockStreamClient(ctrl *gomock.Controller) *MockSegmentServer_ReadFromBlockStreamClient { + mock := &MockSegmentServer_ReadFromBlockStreamClient{ctrl: ctrl} + mock.recorder = &MockSegmentServer_ReadFromBlockStreamClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSegmentServer_ReadFromBlockStreamClient) EXPECT() *MockSegmentServer_ReadFromBlockStreamClientMockRecorder { + return m.recorder +} + +// CloseSend mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamClient) CloseSend() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CloseSend") + ret0, _ := ret[0].(error) + return ret0 +} + +// CloseSend indicates an expected call of CloseSend. +func (mr *MockSegmentServer_ReadFromBlockStreamClientMockRecorder) CloseSend() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseSend", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamClient)(nil).CloseSend)) +} + +// Context mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamClient) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockSegmentServer_ReadFromBlockStreamClientMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamClient)(nil).Context)) +} + +// Header mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamClient) Header() (metadata.MD, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Header") + ret0, _ := ret[0].(metadata.MD) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Header indicates an expected call of Header. +func (mr *MockSegmentServer_ReadFromBlockStreamClientMockRecorder) Header() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Header", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamClient)(nil).Header)) +} + +// Recv mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamClient) Recv() (*ReadFromBlockStreamResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Recv") + ret0, _ := ret[0].(*ReadFromBlockStreamResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Recv indicates an expected call of Recv. +func (mr *MockSegmentServer_ReadFromBlockStreamClientMockRecorder) Recv() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamClient)(nil).Recv)) +} + +// RecvMsg mocks base method. +func (m_2 *MockSegmentServer_ReadFromBlockStreamClient) RecvMsg(m interface{}) error { + m_2.ctrl.T.Helper() + ret := m_2.ctrl.Call(m_2, "RecvMsg", m) + ret0, _ := ret[0].(error) + return ret0 +} + +// RecvMsg indicates an expected call of RecvMsg. +func (mr *MockSegmentServer_ReadFromBlockStreamClientMockRecorder) RecvMsg(m interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamClient)(nil).RecvMsg), m) +} + +// Send mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamClient) Send(arg0 *ReadFromBlockStreamRequest) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Send", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Send indicates an expected call of Send. +func (mr *MockSegmentServer_ReadFromBlockStreamClientMockRecorder) Send(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamClient)(nil).Send), arg0) +} + +// SendMsg mocks base method. +func (m_2 *MockSegmentServer_ReadFromBlockStreamClient) SendMsg(m interface{}) error { + m_2.ctrl.T.Helper() + ret := m_2.ctrl.Call(m_2, "SendMsg", m) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendMsg indicates an expected call of SendMsg. +func (mr *MockSegmentServer_ReadFromBlockStreamClientMockRecorder) SendMsg(m interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamClient)(nil).SendMsg), m) +} + +// Trailer mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamClient) Trailer() metadata.MD { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Trailer") + ret0, _ := ret[0].(metadata.MD) + return ret0 +} + +// Trailer indicates an expected call of Trailer. +func (mr *MockSegmentServer_ReadFromBlockStreamClientMockRecorder) Trailer() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Trailer", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamClient)(nil).Trailer)) +} + +// MockSegmentServer_AppendToBlockAsyncStreamClient is a mock of SegmentServer_AppendToBlockAsyncStreamClient interface. +type MockSegmentServer_AppendToBlockAsyncStreamClient struct { + ctrl *gomock.Controller + recorder *MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder +} + +// MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder is the mock recorder for MockSegmentServer_AppendToBlockAsyncStreamClient. +type MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder struct { + mock *MockSegmentServer_AppendToBlockAsyncStreamClient +} + +// NewMockSegmentServer_AppendToBlockAsyncStreamClient creates a new mock instance. +func NewMockSegmentServer_AppendToBlockAsyncStreamClient(ctrl *gomock.Controller) *MockSegmentServer_AppendToBlockAsyncStreamClient { + mock := &MockSegmentServer_AppendToBlockAsyncStreamClient{ctrl: ctrl} + mock.recorder = &MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSegmentServer_AppendToBlockAsyncStreamClient) EXPECT() *MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder { + return m.recorder +} + +// CloseSend mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamClient) CloseSend() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CloseSend") + ret0, _ := ret[0].(error) + return ret0 +} + +// CloseSend indicates an expected call of CloseSend. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder) CloseSend() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseSend", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamClient)(nil).CloseSend)) +} + +// Context mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamClient) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamClient)(nil).Context)) +} + +// Header mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamClient) Header() (metadata.MD, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Header") + ret0, _ := ret[0].(metadata.MD) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Header indicates an expected call of Header. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder) Header() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Header", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamClient)(nil).Header)) +} + +// Recv mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamClient) Recv() (*AppendToBlockAsyncStreamResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Recv") + ret0, _ := ret[0].(*AppendToBlockAsyncStreamResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Recv indicates an expected call of Recv. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder) Recv() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamClient)(nil).Recv)) +} + +// RecvMsg mocks base method. +func (m_2 *MockSegmentServer_AppendToBlockAsyncStreamClient) RecvMsg(m interface{}) error { + m_2.ctrl.T.Helper() + ret := m_2.ctrl.Call(m_2, "RecvMsg", m) + ret0, _ := ret[0].(error) + return ret0 +} + +// RecvMsg indicates an expected call of RecvMsg. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder) RecvMsg(m interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamClient)(nil).RecvMsg), m) +} + +// Send mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamClient) Send(arg0 *AppendToBlockAsyncStreamRequest) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Send", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Send indicates an expected call of Send. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder) Send(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamClient)(nil).Send), arg0) +} + +// SendMsg mocks base method. +func (m_2 *MockSegmentServer_AppendToBlockAsyncStreamClient) SendMsg(m interface{}) error { + m_2.ctrl.T.Helper() + ret := m_2.ctrl.Call(m_2, "SendMsg", m) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendMsg indicates an expected call of SendMsg. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder) SendMsg(m interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamClient)(nil).SendMsg), m) +} + +// Trailer mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamClient) Trailer() metadata.MD { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Trailer") + ret0, _ := ret[0].(metadata.MD) + return ret0 +} + +// Trailer indicates an expected call of Trailer. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamClientMockRecorder) Trailer() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Trailer", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamClient)(nil).Trailer)) +} + // MockSegmentServerServer is a mock of SegmentServerServer interface. type MockSegmentServerServer struct { ctrl *gomock.Controller @@ -467,6 +781,20 @@ func (mr *MockSegmentServerServerMockRecorder) AppendToBlock(arg0, arg1 interfac return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendToBlock", reflect.TypeOf((*MockSegmentServerServer)(nil).AppendToBlock), arg0, arg1) } +// AppendToBlockAsyncStream mocks base method. +func (m *MockSegmentServerServer) AppendToBlockAsyncStream(arg0 SegmentServer_AppendToBlockAsyncStreamServer) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AppendToBlockAsyncStream", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// AppendToBlockAsyncStream indicates an expected call of AppendToBlockAsyncStream. +func (mr *MockSegmentServerServerMockRecorder) AppendToBlockAsyncStream(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendToBlockAsyncStream", reflect.TypeOf((*MockSegmentServerServer)(nil).AppendToBlockAsyncStream), arg0) +} + // AppendToBlockStream mocks base method. func (m *MockSegmentServerServer) AppendToBlockStream(arg0 SegmentServer_AppendToBlockStreamServer) error { m.ctrl.T.Helper() @@ -556,6 +884,20 @@ func (mr *MockSegmentServerServerMockRecorder) ReadFromBlock(arg0, arg1 interfac return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadFromBlock", reflect.TypeOf((*MockSegmentServerServer)(nil).ReadFromBlock), arg0, arg1) } +// ReadFromBlockStream mocks base method. +func (m *MockSegmentServerServer) ReadFromBlockStream(arg0 SegmentServer_ReadFromBlockStreamServer) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadFromBlockStream", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// ReadFromBlockStream indicates an expected call of ReadFromBlockStream. +func (mr *MockSegmentServerServerMockRecorder) ReadFromBlockStream(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadFromBlockStream", reflect.TypeOf((*MockSegmentServerServer)(nil).ReadFromBlockStream), arg0) +} + // RemoveBlock mocks base method. func (m *MockSegmentServerServer) RemoveBlock(arg0 context.Context, arg1 *RemoveBlockRequest) (*emptypb.Empty, error) { m.ctrl.T.Helper() @@ -784,3 +1126,271 @@ func (mr *MockSegmentServer_AppendToBlockStreamServerMockRecorder) SetTrailer(ar mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockSegmentServer_AppendToBlockStreamServer)(nil).SetTrailer), arg0) } + +// MockSegmentServer_ReadFromBlockStreamServer is a mock of SegmentServer_ReadFromBlockStreamServer interface. +type MockSegmentServer_ReadFromBlockStreamServer struct { + ctrl *gomock.Controller + recorder *MockSegmentServer_ReadFromBlockStreamServerMockRecorder +} + +// MockSegmentServer_ReadFromBlockStreamServerMockRecorder is the mock recorder for MockSegmentServer_ReadFromBlockStreamServer. +type MockSegmentServer_ReadFromBlockStreamServerMockRecorder struct { + mock *MockSegmentServer_ReadFromBlockStreamServer +} + +// NewMockSegmentServer_ReadFromBlockStreamServer creates a new mock instance. +func NewMockSegmentServer_ReadFromBlockStreamServer(ctrl *gomock.Controller) *MockSegmentServer_ReadFromBlockStreamServer { + mock := &MockSegmentServer_ReadFromBlockStreamServer{ctrl: ctrl} + mock.recorder = &MockSegmentServer_ReadFromBlockStreamServerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSegmentServer_ReadFromBlockStreamServer) EXPECT() *MockSegmentServer_ReadFromBlockStreamServerMockRecorder { + return m.recorder +} + +// Context mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamServer) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockSegmentServer_ReadFromBlockStreamServerMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamServer)(nil).Context)) +} + +// Recv mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamServer) Recv() (*ReadFromBlockStreamRequest, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Recv") + ret0, _ := ret[0].(*ReadFromBlockStreamRequest) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Recv indicates an expected call of Recv. +func (mr *MockSegmentServer_ReadFromBlockStreamServerMockRecorder) Recv() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamServer)(nil).Recv)) +} + +// RecvMsg mocks base method. +func (m_2 *MockSegmentServer_ReadFromBlockStreamServer) RecvMsg(m interface{}) error { + m_2.ctrl.T.Helper() + ret := m_2.ctrl.Call(m_2, "RecvMsg", m) + ret0, _ := ret[0].(error) + return ret0 +} + +// RecvMsg indicates an expected call of RecvMsg. +func (mr *MockSegmentServer_ReadFromBlockStreamServerMockRecorder) RecvMsg(m interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamServer)(nil).RecvMsg), m) +} + +// Send mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamServer) Send(arg0 *ReadFromBlockStreamResponse) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Send", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Send indicates an expected call of Send. +func (mr *MockSegmentServer_ReadFromBlockStreamServerMockRecorder) Send(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamServer)(nil).Send), arg0) +} + +// SendHeader mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamServer) SendHeader(arg0 metadata.MD) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendHeader", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendHeader indicates an expected call of SendHeader. +func (mr *MockSegmentServer_ReadFromBlockStreamServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamServer)(nil).SendHeader), arg0) +} + +// SendMsg mocks base method. +func (m_2 *MockSegmentServer_ReadFromBlockStreamServer) SendMsg(m interface{}) error { + m_2.ctrl.T.Helper() + ret := m_2.ctrl.Call(m_2, "SendMsg", m) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendMsg indicates an expected call of SendMsg. +func (mr *MockSegmentServer_ReadFromBlockStreamServerMockRecorder) SendMsg(m interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamServer)(nil).SendMsg), m) +} + +// SetHeader mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamServer) SetHeader(arg0 metadata.MD) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetHeader", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetHeader indicates an expected call of SetHeader. +func (mr *MockSegmentServer_ReadFromBlockStreamServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamServer)(nil).SetHeader), arg0) +} + +// SetTrailer mocks base method. +func (m *MockSegmentServer_ReadFromBlockStreamServer) SetTrailer(arg0 metadata.MD) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTrailer", arg0) +} + +// SetTrailer indicates an expected call of SetTrailer. +func (mr *MockSegmentServer_ReadFromBlockStreamServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockSegmentServer_ReadFromBlockStreamServer)(nil).SetTrailer), arg0) +} + +// MockSegmentServer_AppendToBlockAsyncStreamServer is a mock of SegmentServer_AppendToBlockAsyncStreamServer interface. +type MockSegmentServer_AppendToBlockAsyncStreamServer struct { + ctrl *gomock.Controller + recorder *MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder +} + +// MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder is the mock recorder for MockSegmentServer_AppendToBlockAsyncStreamServer. +type MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder struct { + mock *MockSegmentServer_AppendToBlockAsyncStreamServer +} + +// NewMockSegmentServer_AppendToBlockAsyncStreamServer creates a new mock instance. +func NewMockSegmentServer_AppendToBlockAsyncStreamServer(ctrl *gomock.Controller) *MockSegmentServer_AppendToBlockAsyncStreamServer { + mock := &MockSegmentServer_AppendToBlockAsyncStreamServer{ctrl: ctrl} + mock.recorder = &MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSegmentServer_AppendToBlockAsyncStreamServer) EXPECT() *MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder { + return m.recorder +} + +// Context mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamServer) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamServer)(nil).Context)) +} + +// Recv mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamServer) Recv() (*AppendToBlockAsyncStreamRequest, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Recv") + ret0, _ := ret[0].(*AppendToBlockAsyncStreamRequest) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Recv indicates an expected call of Recv. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder) Recv() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamServer)(nil).Recv)) +} + +// RecvMsg mocks base method. +func (m_2 *MockSegmentServer_AppendToBlockAsyncStreamServer) RecvMsg(m interface{}) error { + m_2.ctrl.T.Helper() + ret := m_2.ctrl.Call(m_2, "RecvMsg", m) + ret0, _ := ret[0].(error) + return ret0 +} + +// RecvMsg indicates an expected call of RecvMsg. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder) RecvMsg(m interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamServer)(nil).RecvMsg), m) +} + +// Send mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamServer) Send(arg0 *AppendToBlockAsyncStreamResponse) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Send", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Send indicates an expected call of Send. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder) Send(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamServer)(nil).Send), arg0) +} + +// SendHeader mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamServer) SendHeader(arg0 metadata.MD) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendHeader", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendHeader indicates an expected call of SendHeader. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamServer)(nil).SendHeader), arg0) +} + +// SendMsg mocks base method. +func (m_2 *MockSegmentServer_AppendToBlockAsyncStreamServer) SendMsg(m interface{}) error { + m_2.ctrl.T.Helper() + ret := m_2.ctrl.Call(m_2, "SendMsg", m) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendMsg indicates an expected call of SendMsg. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder) SendMsg(m interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamServer)(nil).SendMsg), m) +} + +// SetHeader mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamServer) SetHeader(arg0 metadata.MD) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetHeader", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetHeader indicates an expected call of SetHeader. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamServer)(nil).SetHeader), arg0) +} + +// SetTrailer mocks base method. +func (m *MockSegmentServer_AppendToBlockAsyncStreamServer) SetTrailer(arg0 metadata.MD) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTrailer", arg0) +} + +// SetTrailer indicates an expected call of SetTrailer. +func (mr *MockSegmentServer_AppendToBlockAsyncStreamServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockSegmentServer_AppendToBlockAsyncStreamServer)(nil).SetTrailer), arg0) +} diff --git a/proto/pkg/segment/segment.pb.go b/proto/pkg/segment/segment.pb.go index fb3c9226d..68cd6a9af 100644 --- a/proto/pkg/segment/segment.pb.go +++ b/proto/pkg/segment/segment.pb.go @@ -968,6 +968,285 @@ func (x *AppendToBlockStreamResponse) GetOffsets() []int64 { return nil } +type ReadFromBlockStreamRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + BlockId uint64 `protobuf:"varint,2,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` + Offset int64 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"` + Number int64 `protobuf:"varint,4,opt,name=number,proto3" json:"number,omitempty"` + // polling timeout in milliseconds, 0 is disable. + PollingTimeout uint32 `protobuf:"varint,5,opt,name=polling_timeout,json=pollingTimeout,proto3" json:"polling_timeout,omitempty"` +} + +func (x *ReadFromBlockStreamRequest) Reset() { + *x = ReadFromBlockStreamRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_segment_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadFromBlockStreamRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadFromBlockStreamRequest) ProtoMessage() {} + +func (x *ReadFromBlockStreamRequest) ProtoReflect() protoreflect.Message { + mi := &file_segment_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadFromBlockStreamRequest.ProtoReflect.Descriptor instead. +func (*ReadFromBlockStreamRequest) Descriptor() ([]byte, []int) { + return file_segment_proto_rawDescGZIP(), []int{18} +} + +func (x *ReadFromBlockStreamRequest) GetRequestId() uint64 { + if x != nil { + return x.RequestId + } + return 0 +} + +func (x *ReadFromBlockStreamRequest) GetBlockId() uint64 { + if x != nil { + return x.BlockId + } + return 0 +} + +func (x *ReadFromBlockStreamRequest) GetOffset() int64 { + if x != nil { + return x.Offset + } + return 0 +} + +func (x *ReadFromBlockStreamRequest) GetNumber() int64 { + if x != nil { + return x.Number + } + return 0 +} + +func (x *ReadFromBlockStreamRequest) GetPollingTimeout() uint32 { + if x != nil { + return x.PollingTimeout + } + return 0 +} + +type ReadFromBlockStreamResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ResponseId uint64 `protobuf:"varint,1,opt,name=response_id,json=responseId,proto3" json:"response_id,omitempty"` + ResponseCode ResponseCode `protobuf:"varint,2,opt,name=response_code,json=responseCode,proto3,enum=linkall.vanus.segment.ResponseCode" json:"response_code,omitempty"` + Events *v1.CloudEventBatch `protobuf:"bytes,3,opt,name=events,proto3" json:"events,omitempty"` + // Don't use this now, just used to optimize cpu overhead of SegmentServer in + // the future for backward compatibility + Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (x *ReadFromBlockStreamResponse) Reset() { + *x = ReadFromBlockStreamResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_segment_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadFromBlockStreamResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadFromBlockStreamResponse) ProtoMessage() {} + +func (x *ReadFromBlockStreamResponse) ProtoReflect() protoreflect.Message { + mi := &file_segment_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadFromBlockStreamResponse.ProtoReflect.Descriptor instead. +func (*ReadFromBlockStreamResponse) Descriptor() ([]byte, []int) { + return file_segment_proto_rawDescGZIP(), []int{19} +} + +func (x *ReadFromBlockStreamResponse) GetResponseId() uint64 { + if x != nil { + return x.ResponseId + } + return 0 +} + +func (x *ReadFromBlockStreamResponse) GetResponseCode() ResponseCode { + if x != nil { + return x.ResponseCode + } + return ResponseCode_SUCCESS +} + +func (x *ReadFromBlockStreamResponse) GetEvents() *v1.CloudEventBatch { + if x != nil { + return x.Events + } + return nil +} + +func (x *ReadFromBlockStreamResponse) GetPayload() []byte { + if x != nil { + return x.Payload + } + return nil +} + +type AppendToBlockAsyncStreamRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + BlockId uint64 `protobuf:"varint,2,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` + Events *v1.CloudEventBatch `protobuf:"bytes,3,opt,name=events,proto3" json:"events,omitempty"` +} + +func (x *AppendToBlockAsyncStreamRequest) Reset() { + *x = AppendToBlockAsyncStreamRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_segment_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AppendToBlockAsyncStreamRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AppendToBlockAsyncStreamRequest) ProtoMessage() {} + +func (x *AppendToBlockAsyncStreamRequest) ProtoReflect() protoreflect.Message { + mi := &file_segment_proto_msgTypes[20] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AppendToBlockAsyncStreamRequest.ProtoReflect.Descriptor instead. +func (*AppendToBlockAsyncStreamRequest) Descriptor() ([]byte, []int) { + return file_segment_proto_rawDescGZIP(), []int{20} +} + +func (x *AppendToBlockAsyncStreamRequest) GetRequestId() uint64 { + if x != nil { + return x.RequestId + } + return 0 +} + +func (x *AppendToBlockAsyncStreamRequest) GetBlockId() uint64 { + if x != nil { + return x.BlockId + } + return 0 +} + +func (x *AppendToBlockAsyncStreamRequest) GetEvents() *v1.CloudEventBatch { + if x != nil { + return x.Events + } + return nil +} + +type AppendToBlockAsyncStreamResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ResponseId uint64 `protobuf:"varint,1,opt,name=response_id,json=responseId,proto3" json:"response_id,omitempty"` + ResponseCode ResponseCode `protobuf:"varint,2,opt,name=response_code,json=responseCode,proto3,enum=linkall.vanus.segment.ResponseCode" json:"response_code,omitempty"` + Offsets []int64 `protobuf:"varint,3,rep,packed,name=offsets,proto3" json:"offsets,omitempty"` +} + +func (x *AppendToBlockAsyncStreamResponse) Reset() { + *x = AppendToBlockAsyncStreamResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_segment_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AppendToBlockAsyncStreamResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AppendToBlockAsyncStreamResponse) ProtoMessage() {} + +func (x *AppendToBlockAsyncStreamResponse) ProtoReflect() protoreflect.Message { + mi := &file_segment_proto_msgTypes[21] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AppendToBlockAsyncStreamResponse.ProtoReflect.Descriptor instead. +func (*AppendToBlockAsyncStreamResponse) Descriptor() ([]byte, []int) { + return file_segment_proto_rawDescGZIP(), []int{21} +} + +func (x *AppendToBlockAsyncStreamResponse) GetResponseId() uint64 { + if x != nil { + return x.ResponseId + } + return 0 +} + +func (x *AppendToBlockAsyncStreamResponse) GetResponseCode() ResponseCode { + if x != nil { + return x.ResponseCode + } + return ResponseCode_SUCCESS +} + +func (x *AppendToBlockAsyncStreamResponse) GetOffsets() []int64 { + if x != nil { + return x.Offsets + } + return nil +} + type LookupOffsetInBlockRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -980,7 +1259,7 @@ type LookupOffsetInBlockRequest struct { func (x *LookupOffsetInBlockRequest) Reset() { *x = LookupOffsetInBlockRequest{} if protoimpl.UnsafeEnabled { - mi := &file_segment_proto_msgTypes[18] + mi := &file_segment_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -993,7 +1272,7 @@ func (x *LookupOffsetInBlockRequest) String() string { func (*LookupOffsetInBlockRequest) ProtoMessage() {} func (x *LookupOffsetInBlockRequest) ProtoReflect() protoreflect.Message { - mi := &file_segment_proto_msgTypes[18] + mi := &file_segment_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1006,7 +1285,7 @@ func (x *LookupOffsetInBlockRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LookupOffsetInBlockRequest.ProtoReflect.Descriptor instead. func (*LookupOffsetInBlockRequest) Descriptor() ([]byte, []int) { - return file_segment_proto_rawDescGZIP(), []int{18} + return file_segment_proto_rawDescGZIP(), []int{22} } func (x *LookupOffsetInBlockRequest) GetBlockId() uint64 { @@ -1034,7 +1313,7 @@ type LookupOffsetInBlockResponse struct { func (x *LookupOffsetInBlockResponse) Reset() { *x = LookupOffsetInBlockResponse{} if protoimpl.UnsafeEnabled { - mi := &file_segment_proto_msgTypes[19] + mi := &file_segment_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1047,7 +1326,7 @@ func (x *LookupOffsetInBlockResponse) String() string { func (*LookupOffsetInBlockResponse) ProtoMessage() {} func (x *LookupOffsetInBlockResponse) ProtoReflect() protoreflect.Message { - mi := &file_segment_proto_msgTypes[19] + mi := &file_segment_proto_msgTypes[23] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1060,7 +1339,7 @@ func (x *LookupOffsetInBlockResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LookupOffsetInBlockResponse.ProtoReflect.Descriptor instead. func (*LookupOffsetInBlockResponse) Descriptor() ([]byte, []int) { - return file_segment_proto_rawDescGZIP(), []int{19} + return file_segment_proto_rawDescGZIP(), []int{23} } func (x *LookupOffsetInBlockResponse) GetOffset() int64 { @@ -1081,7 +1360,7 @@ type StatusResponse struct { func (x *StatusResponse) Reset() { *x = StatusResponse{} if protoimpl.UnsafeEnabled { - mi := &file_segment_proto_msgTypes[20] + mi := &file_segment_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1094,7 +1373,7 @@ func (x *StatusResponse) String() string { func (*StatusResponse) ProtoMessage() {} func (x *StatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_segment_proto_msgTypes[20] + mi := &file_segment_proto_msgTypes[24] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1107,7 +1386,7 @@ func (x *StatusResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead. func (*StatusResponse) Descriptor() ([]byte, []int) { - return file_segment_proto_rawDescGZIP(), []int{20} + return file_segment_proto_rawDescGZIP(), []int{24} } func (x *StatusResponse) GetStatus() string { @@ -1215,104 +1494,167 @@ var file_segment_proto_rawDesc = []byte{ 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x07, 0x6f, 0x66, - 0x66, 0x73, 0x65, 0x74, 0x73, 0x22, 0x4d, 0x0a, 0x1a, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4f, - 0x66, 0x66, 0x73, 0x65, 0x74, 0x49, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x14, - 0x0a, 0x05, 0x73, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x73, - 0x74, 0x69, 0x6d, 0x65, 0x22, 0x35, 0x0a, 0x1b, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4f, 0x66, - 0x66, 0x73, 0x65, 0x74, 0x49, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x22, 0x28, 0x0a, 0x0e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x39, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, - 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x01, 0x12, - 0x0f, 0x0a, 0x0b, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x02, - 0x32, 0xe7, 0x09, 0x0a, 0x0d, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x12, 0x6c, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x30, 0x2e, 0x6c, 0x69, - 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, - 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, - 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, - 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, - 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, - 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x69, 0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x2f, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, - 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, - 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, - 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, - 0x74, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0b, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x29, 0x2e, 0x6c, 0x69, 0x6e, - 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, - 0x6e, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x50, 0x0a, - 0x0b, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x29, 0x2e, 0x6c, - 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, - 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x66, 0x73, 0x65, 0x74, 0x73, 0x22, 0xaf, 0x01, 0x0a, 0x1a, 0x52, 0x65, 0x61, 0x64, 0x46, 0x72, + 0x6f, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x16, + 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, + 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x27, + 0x0a, 0x0f, 0x70, 0x6f, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, + 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x70, 0x6f, 0x6c, 0x6c, 0x69, 0x6e, 0x67, + 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0xde, 0x01, 0x0a, 0x1b, 0x52, 0x65, 0x61, 0x64, + 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x72, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x49, 0x64, 0x12, 0x48, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x23, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, + 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x43, 0x6f, 0x64, 0x65, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, + 0x64, 0x65, 0x12, 0x3a, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x69, 0x6f, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x18, + 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x97, 0x01, 0x0a, 0x1f, 0x41, 0x70, 0x70, + 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x3a, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x69, 0x6f, 0x2e, 0x63, 0x6c, 0x6f, 0x75, + 0x64, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, + 0x45, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, + 0x74, 0x73, 0x22, 0xa7, 0x01, 0x0a, 0x20, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x72, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x49, 0x64, 0x12, 0x48, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x23, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, + 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x43, 0x6f, 0x64, 0x65, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, + 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x03, 0x52, 0x07, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x73, 0x22, 0x4d, 0x0a, 0x1a, + 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x49, 0x6e, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x73, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x35, 0x0a, 0x1b, 0x4c, + 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x49, 0x6e, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, + 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, + 0x65, 0x74, 0x22, 0x28, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x39, 0x0a, 0x0c, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, + 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, + 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, + 0x74, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x02, 0x32, 0xfc, 0x0b, 0x0a, 0x0d, 0x53, 0x65, 0x67, 0x6d, + 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x6c, 0x0a, 0x05, 0x53, 0x74, 0x61, + 0x72, 0x74, 0x12, 0x30, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, + 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, + 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, + 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61, + 0x72, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x69, 0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x12, + 0x2f, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, + 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x53, 0x65, 0x67, 0x6d, + 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x30, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, + 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x53, 0x65, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x12, 0x29, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, + 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x12, 0x50, 0x0a, 0x0b, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x12, 0x29, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, + 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x6d, 0x6f, + 0x76, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x67, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2a, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, + 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x47, + 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, + 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x70, 0x0a, 0x0f, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, + 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, + 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x2e, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, + 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, + 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x5c, 0x0a, 0x11, 0x49, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x53, + 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, + 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x49, + 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, - 0x67, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, - 0x2a, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, - 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x6c, 0x69, - 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, - 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x70, 0x0a, 0x0f, 0x41, 0x63, 0x74, 0x69, - 0x76, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x6c, 0x69, - 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, - 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x6c, 0x69, 0x6e, - 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, - 0x6e, 0x74, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x11, 0x49, 0x6e, - 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, - 0x2f, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, - 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x49, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, - 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x6a, 0x0a, 0x0d, 0x41, 0x70, 0x70, 0x65, - 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x2b, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, + 0x6a, 0x0a, 0x0d, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x12, 0x2b, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, + 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, + 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, + 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, + 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6a, 0x0a, 0x0d, 0x52, + 0x65, 0x61, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x2b, 0x2e, 0x6c, + 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, - 0x74, 0x2e, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, - 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, - 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6a, 0x0a, 0x0d, 0x52, 0x65, 0x61, 0x64, 0x46, 0x72, 0x6f, 0x6d, - 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x2b, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, - 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, - 0x61, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, + 0x74, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x80, 0x01, 0x0a, 0x13, 0x41, 0x70, 0x70, 0x65, + 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, + 0x31, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, + 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, + 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x70, 0x70, 0x65, 0x6e, + 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x80, 0x01, 0x0a, 0x13, 0x52, + 0x65, 0x61, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x12, 0x31, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x46, - 0x72, 0x6f, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x80, 0x01, 0x0a, 0x13, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x31, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, - 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, - 0x2e, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x6c, 0x69, - 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, - 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, - 0x01, 0x30, 0x01, 0x12, 0x7c, 0x0a, 0x13, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4f, 0x66, 0x66, - 0x73, 0x65, 0x74, 0x49, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x31, 0x2e, 0x6c, 0x69, 0x6e, + 0x72, 0x6f, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, + 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, + 0x61, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x8f, 0x01, + 0x0a, 0x18, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, + 0x73, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x36, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, - 0x6e, 0x74, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x49, - 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e, - 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, - 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4f, 0x66, 0x66, 0x73, - 0x65, 0x74, 0x49, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x1a, 0x25, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, - 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, - 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x74, 0x2e, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x41, 0x73, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, + 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x70, 0x70, 0x65, 0x6e, + 0x64, 0x54, 0x6f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, + 0x7c, 0x0a, 0x13, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x49, + 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x31, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, + 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4c, + 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x49, 0x6e, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, + 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, + 0x74, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x49, 0x6e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, + 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, + 0x25, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2e, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2e, + 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x6c, 0x6c, 0x2d, 0x6c, 0x61, 0x62, + 0x73, 0x2f, 0x76, 0x61, 0x6e, 0x75, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x6b, + 0x67, 0x2f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -1328,71 +1670,83 @@ func file_segment_proto_rawDescGZIP() []byte { } var file_segment_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_segment_proto_msgTypes = make([]protoimpl.MessageInfo, 22) +var file_segment_proto_msgTypes = make([]protoimpl.MessageInfo, 26) var file_segment_proto_goTypes = []interface{}{ - (ResponseCode)(0), // 0: linkall.vanus.segment.ResponseCode - (*StartSegmentServerRequest)(nil), // 1: linkall.vanus.segment.StartSegmentServerRequest - (*StartSegmentServerResponse)(nil), // 2: linkall.vanus.segment.StartSegmentServerResponse - (*StopSegmentServerRequest)(nil), // 3: linkall.vanus.segment.StopSegmentServerRequest - (*StopSegmentServerResponse)(nil), // 4: linkall.vanus.segment.StopSegmentServerResponse - (*CreateBlockRequest)(nil), // 5: linkall.vanus.segment.CreateBlockRequest - (*RemoveBlockRequest)(nil), // 6: linkall.vanus.segment.RemoveBlockRequest - (*GetBlockInfoRequest)(nil), // 7: linkall.vanus.segment.GetBlockInfoRequest - (*GetBlockInfoResponse)(nil), // 8: linkall.vanus.segment.GetBlockInfoResponse - (*ActivateSegmentRequest)(nil), // 9: linkall.vanus.segment.ActivateSegmentRequest - (*ActivateSegmentResponse)(nil), // 10: linkall.vanus.segment.ActivateSegmentResponse - (*InactivateSegmentRequest)(nil), // 11: linkall.vanus.segment.InactivateSegmentRequest - (*InactivateSegmentResponse)(nil), // 12: linkall.vanus.segment.InactivateSegmentResponse - (*AppendToBlockRequest)(nil), // 13: linkall.vanus.segment.AppendToBlockRequest - (*AppendToBlockResponse)(nil), // 14: linkall.vanus.segment.AppendToBlockResponse - (*ReadFromBlockRequest)(nil), // 15: linkall.vanus.segment.ReadFromBlockRequest - (*ReadFromBlockResponse)(nil), // 16: linkall.vanus.segment.ReadFromBlockResponse - (*AppendToBlockStreamRequest)(nil), // 17: linkall.vanus.segment.AppendToBlockStreamRequest - (*AppendToBlockStreamResponse)(nil), // 18: linkall.vanus.segment.AppendToBlockStreamResponse - (*LookupOffsetInBlockRequest)(nil), // 19: linkall.vanus.segment.LookupOffsetInBlockRequest - (*LookupOffsetInBlockResponse)(nil), // 20: linkall.vanus.segment.LookupOffsetInBlockResponse - (*StatusResponse)(nil), // 21: linkall.vanus.segment.StatusResponse - nil, // 22: linkall.vanus.segment.ActivateSegmentRequest.ReplicasEntry - (*config.ServerConfig)(nil), // 23: linkall.vanus.config.ServerConfig - (*v1.CloudEventBatch)(nil), // 24: io.cloudevents.v1.CloudEventBatch - (*emptypb.Empty)(nil), // 25: google.protobuf.Empty + (ResponseCode)(0), // 0: linkall.vanus.segment.ResponseCode + (*StartSegmentServerRequest)(nil), // 1: linkall.vanus.segment.StartSegmentServerRequest + (*StartSegmentServerResponse)(nil), // 2: linkall.vanus.segment.StartSegmentServerResponse + (*StopSegmentServerRequest)(nil), // 3: linkall.vanus.segment.StopSegmentServerRequest + (*StopSegmentServerResponse)(nil), // 4: linkall.vanus.segment.StopSegmentServerResponse + (*CreateBlockRequest)(nil), // 5: linkall.vanus.segment.CreateBlockRequest + (*RemoveBlockRequest)(nil), // 6: linkall.vanus.segment.RemoveBlockRequest + (*GetBlockInfoRequest)(nil), // 7: linkall.vanus.segment.GetBlockInfoRequest + (*GetBlockInfoResponse)(nil), // 8: linkall.vanus.segment.GetBlockInfoResponse + (*ActivateSegmentRequest)(nil), // 9: linkall.vanus.segment.ActivateSegmentRequest + (*ActivateSegmentResponse)(nil), // 10: linkall.vanus.segment.ActivateSegmentResponse + (*InactivateSegmentRequest)(nil), // 11: linkall.vanus.segment.InactivateSegmentRequest + (*InactivateSegmentResponse)(nil), // 12: linkall.vanus.segment.InactivateSegmentResponse + (*AppendToBlockRequest)(nil), // 13: linkall.vanus.segment.AppendToBlockRequest + (*AppendToBlockResponse)(nil), // 14: linkall.vanus.segment.AppendToBlockResponse + (*ReadFromBlockRequest)(nil), // 15: linkall.vanus.segment.ReadFromBlockRequest + (*ReadFromBlockResponse)(nil), // 16: linkall.vanus.segment.ReadFromBlockResponse + (*AppendToBlockStreamRequest)(nil), // 17: linkall.vanus.segment.AppendToBlockStreamRequest + (*AppendToBlockStreamResponse)(nil), // 18: linkall.vanus.segment.AppendToBlockStreamResponse + (*ReadFromBlockStreamRequest)(nil), // 19: linkall.vanus.segment.ReadFromBlockStreamRequest + (*ReadFromBlockStreamResponse)(nil), // 20: linkall.vanus.segment.ReadFromBlockStreamResponse + (*AppendToBlockAsyncStreamRequest)(nil), // 21: linkall.vanus.segment.AppendToBlockAsyncStreamRequest + (*AppendToBlockAsyncStreamResponse)(nil), // 22: linkall.vanus.segment.AppendToBlockAsyncStreamResponse + (*LookupOffsetInBlockRequest)(nil), // 23: linkall.vanus.segment.LookupOffsetInBlockRequest + (*LookupOffsetInBlockResponse)(nil), // 24: linkall.vanus.segment.LookupOffsetInBlockResponse + (*StatusResponse)(nil), // 25: linkall.vanus.segment.StatusResponse + nil, // 26: linkall.vanus.segment.ActivateSegmentRequest.ReplicasEntry + (*config.ServerConfig)(nil), // 27: linkall.vanus.config.ServerConfig + (*v1.CloudEventBatch)(nil), // 28: io.cloudevents.v1.CloudEventBatch + (*emptypb.Empty)(nil), // 29: google.protobuf.Empty } var file_segment_proto_depIdxs = []int32{ - 23, // 0: linkall.vanus.segment.StartSegmentServerRequest.config:type_name -> linkall.vanus.config.ServerConfig - 22, // 1: linkall.vanus.segment.ActivateSegmentRequest.replicas:type_name -> linkall.vanus.segment.ActivateSegmentRequest.ReplicasEntry - 24, // 2: linkall.vanus.segment.AppendToBlockRequest.events:type_name -> io.cloudevents.v1.CloudEventBatch - 24, // 3: linkall.vanus.segment.ReadFromBlockResponse.events:type_name -> io.cloudevents.v1.CloudEventBatch - 24, // 4: linkall.vanus.segment.AppendToBlockStreamRequest.events:type_name -> io.cloudevents.v1.CloudEventBatch + 27, // 0: linkall.vanus.segment.StartSegmentServerRequest.config:type_name -> linkall.vanus.config.ServerConfig + 26, // 1: linkall.vanus.segment.ActivateSegmentRequest.replicas:type_name -> linkall.vanus.segment.ActivateSegmentRequest.ReplicasEntry + 28, // 2: linkall.vanus.segment.AppendToBlockRequest.events:type_name -> io.cloudevents.v1.CloudEventBatch + 28, // 3: linkall.vanus.segment.ReadFromBlockResponse.events:type_name -> io.cloudevents.v1.CloudEventBatch + 28, // 4: linkall.vanus.segment.AppendToBlockStreamRequest.events:type_name -> io.cloudevents.v1.CloudEventBatch 0, // 5: linkall.vanus.segment.AppendToBlockStreamResponse.response_code:type_name -> linkall.vanus.segment.ResponseCode - 1, // 6: linkall.vanus.segment.SegmentServer.Start:input_type -> linkall.vanus.segment.StartSegmentServerRequest - 3, // 7: linkall.vanus.segment.SegmentServer.Stop:input_type -> linkall.vanus.segment.StopSegmentServerRequest - 5, // 8: linkall.vanus.segment.SegmentServer.CreateBlock:input_type -> linkall.vanus.segment.CreateBlockRequest - 6, // 9: linkall.vanus.segment.SegmentServer.RemoveBlock:input_type -> linkall.vanus.segment.RemoveBlockRequest - 7, // 10: linkall.vanus.segment.SegmentServer.GetBlockInfo:input_type -> linkall.vanus.segment.GetBlockInfoRequest - 9, // 11: linkall.vanus.segment.SegmentServer.ActivateSegment:input_type -> linkall.vanus.segment.ActivateSegmentRequest - 11, // 12: linkall.vanus.segment.SegmentServer.InactivateSegment:input_type -> linkall.vanus.segment.InactivateSegmentRequest - 13, // 13: linkall.vanus.segment.SegmentServer.AppendToBlock:input_type -> linkall.vanus.segment.AppendToBlockRequest - 15, // 14: linkall.vanus.segment.SegmentServer.ReadFromBlock:input_type -> linkall.vanus.segment.ReadFromBlockRequest - 17, // 15: linkall.vanus.segment.SegmentServer.AppendToBlockStream:input_type -> linkall.vanus.segment.AppendToBlockStreamRequest - 19, // 16: linkall.vanus.segment.SegmentServer.LookupOffsetInBlock:input_type -> linkall.vanus.segment.LookupOffsetInBlockRequest - 25, // 17: linkall.vanus.segment.SegmentServer.Status:input_type -> google.protobuf.Empty - 2, // 18: linkall.vanus.segment.SegmentServer.Start:output_type -> linkall.vanus.segment.StartSegmentServerResponse - 4, // 19: linkall.vanus.segment.SegmentServer.Stop:output_type -> linkall.vanus.segment.StopSegmentServerResponse - 25, // 20: linkall.vanus.segment.SegmentServer.CreateBlock:output_type -> google.protobuf.Empty - 25, // 21: linkall.vanus.segment.SegmentServer.RemoveBlock:output_type -> google.protobuf.Empty - 8, // 22: linkall.vanus.segment.SegmentServer.GetBlockInfo:output_type -> linkall.vanus.segment.GetBlockInfoResponse - 10, // 23: linkall.vanus.segment.SegmentServer.ActivateSegment:output_type -> linkall.vanus.segment.ActivateSegmentResponse - 25, // 24: linkall.vanus.segment.SegmentServer.InactivateSegment:output_type -> google.protobuf.Empty - 14, // 25: linkall.vanus.segment.SegmentServer.AppendToBlock:output_type -> linkall.vanus.segment.AppendToBlockResponse - 16, // 26: linkall.vanus.segment.SegmentServer.ReadFromBlock:output_type -> linkall.vanus.segment.ReadFromBlockResponse - 18, // 27: linkall.vanus.segment.SegmentServer.AppendToBlockStream:output_type -> linkall.vanus.segment.AppendToBlockStreamResponse - 20, // 28: linkall.vanus.segment.SegmentServer.LookupOffsetInBlock:output_type -> linkall.vanus.segment.LookupOffsetInBlockResponse - 21, // 29: linkall.vanus.segment.SegmentServer.Status:output_type -> linkall.vanus.segment.StatusResponse - 18, // [18:30] is the sub-list for method output_type - 6, // [6:18] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 0, // 6: linkall.vanus.segment.ReadFromBlockStreamResponse.response_code:type_name -> linkall.vanus.segment.ResponseCode + 28, // 7: linkall.vanus.segment.ReadFromBlockStreamResponse.events:type_name -> io.cloudevents.v1.CloudEventBatch + 28, // 8: linkall.vanus.segment.AppendToBlockAsyncStreamRequest.events:type_name -> io.cloudevents.v1.CloudEventBatch + 0, // 9: linkall.vanus.segment.AppendToBlockAsyncStreamResponse.response_code:type_name -> linkall.vanus.segment.ResponseCode + 1, // 10: linkall.vanus.segment.SegmentServer.Start:input_type -> linkall.vanus.segment.StartSegmentServerRequest + 3, // 11: linkall.vanus.segment.SegmentServer.Stop:input_type -> linkall.vanus.segment.StopSegmentServerRequest + 5, // 12: linkall.vanus.segment.SegmentServer.CreateBlock:input_type -> linkall.vanus.segment.CreateBlockRequest + 6, // 13: linkall.vanus.segment.SegmentServer.RemoveBlock:input_type -> linkall.vanus.segment.RemoveBlockRequest + 7, // 14: linkall.vanus.segment.SegmentServer.GetBlockInfo:input_type -> linkall.vanus.segment.GetBlockInfoRequest + 9, // 15: linkall.vanus.segment.SegmentServer.ActivateSegment:input_type -> linkall.vanus.segment.ActivateSegmentRequest + 11, // 16: linkall.vanus.segment.SegmentServer.InactivateSegment:input_type -> linkall.vanus.segment.InactivateSegmentRequest + 13, // 17: linkall.vanus.segment.SegmentServer.AppendToBlock:input_type -> linkall.vanus.segment.AppendToBlockRequest + 15, // 18: linkall.vanus.segment.SegmentServer.ReadFromBlock:input_type -> linkall.vanus.segment.ReadFromBlockRequest + 17, // 19: linkall.vanus.segment.SegmentServer.AppendToBlockStream:input_type -> linkall.vanus.segment.AppendToBlockStreamRequest + 19, // 20: linkall.vanus.segment.SegmentServer.ReadFromBlockStream:input_type -> linkall.vanus.segment.ReadFromBlockStreamRequest + 21, // 21: linkall.vanus.segment.SegmentServer.AppendToBlockAsyncStream:input_type -> linkall.vanus.segment.AppendToBlockAsyncStreamRequest + 23, // 22: linkall.vanus.segment.SegmentServer.LookupOffsetInBlock:input_type -> linkall.vanus.segment.LookupOffsetInBlockRequest + 29, // 23: linkall.vanus.segment.SegmentServer.Status:input_type -> google.protobuf.Empty + 2, // 24: linkall.vanus.segment.SegmentServer.Start:output_type -> linkall.vanus.segment.StartSegmentServerResponse + 4, // 25: linkall.vanus.segment.SegmentServer.Stop:output_type -> linkall.vanus.segment.StopSegmentServerResponse + 29, // 26: linkall.vanus.segment.SegmentServer.CreateBlock:output_type -> google.protobuf.Empty + 29, // 27: linkall.vanus.segment.SegmentServer.RemoveBlock:output_type -> google.protobuf.Empty + 8, // 28: linkall.vanus.segment.SegmentServer.GetBlockInfo:output_type -> linkall.vanus.segment.GetBlockInfoResponse + 10, // 29: linkall.vanus.segment.SegmentServer.ActivateSegment:output_type -> linkall.vanus.segment.ActivateSegmentResponse + 29, // 30: linkall.vanus.segment.SegmentServer.InactivateSegment:output_type -> google.protobuf.Empty + 14, // 31: linkall.vanus.segment.SegmentServer.AppendToBlock:output_type -> linkall.vanus.segment.AppendToBlockResponse + 16, // 32: linkall.vanus.segment.SegmentServer.ReadFromBlock:output_type -> linkall.vanus.segment.ReadFromBlockResponse + 18, // 33: linkall.vanus.segment.SegmentServer.AppendToBlockStream:output_type -> linkall.vanus.segment.AppendToBlockStreamResponse + 20, // 34: linkall.vanus.segment.SegmentServer.ReadFromBlockStream:output_type -> linkall.vanus.segment.ReadFromBlockStreamResponse + 22, // 35: linkall.vanus.segment.SegmentServer.AppendToBlockAsyncStream:output_type -> linkall.vanus.segment.AppendToBlockAsyncStreamResponse + 24, // 36: linkall.vanus.segment.SegmentServer.LookupOffsetInBlock:output_type -> linkall.vanus.segment.LookupOffsetInBlockResponse + 25, // 37: linkall.vanus.segment.SegmentServer.Status:output_type -> linkall.vanus.segment.StatusResponse + 24, // [24:38] is the sub-list for method output_type + 10, // [10:24] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_segment_proto_init() } @@ -1618,7 +1972,7 @@ func file_segment_proto_init() { } } file_segment_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LookupOffsetInBlockRequest); i { + switch v := v.(*ReadFromBlockStreamRequest); i { case 0: return &v.state case 1: @@ -1630,7 +1984,7 @@ func file_segment_proto_init() { } } file_segment_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LookupOffsetInBlockResponse); i { + switch v := v.(*ReadFromBlockStreamResponse); i { case 0: return &v.state case 1: @@ -1642,6 +1996,54 @@ func file_segment_proto_init() { } } file_segment_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AppendToBlockAsyncStreamRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_segment_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AppendToBlockAsyncStreamResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_segment_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LookupOffsetInBlockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_segment_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LookupOffsetInBlockResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_segment_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StatusResponse); i { case 0: return &v.state @@ -1660,7 +2062,7 @@ func file_segment_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_segment_proto_rawDesc, NumEnums: 1, - NumMessages: 22, + NumMessages: 26, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/pkg/segment/segment_grpc.pb.go b/proto/pkg/segment/segment_grpc.pb.go index d0d3f178d..3bd99ddad 100644 --- a/proto/pkg/segment/segment_grpc.pb.go +++ b/proto/pkg/segment/segment_grpc.pb.go @@ -33,6 +33,8 @@ type SegmentServerClient interface { AppendToBlock(ctx context.Context, in *AppendToBlockRequest, opts ...grpc.CallOption) (*AppendToBlockResponse, error) ReadFromBlock(ctx context.Context, in *ReadFromBlockRequest, opts ...grpc.CallOption) (*ReadFromBlockResponse, error) AppendToBlockStream(ctx context.Context, opts ...grpc.CallOption) (SegmentServer_AppendToBlockStreamClient, error) + ReadFromBlockStream(ctx context.Context, opts ...grpc.CallOption) (SegmentServer_ReadFromBlockStreamClient, error) + AppendToBlockAsyncStream(ctx context.Context, opts ...grpc.CallOption) (SegmentServer_AppendToBlockAsyncStreamClient, error) LookupOffsetInBlock(ctx context.Context, in *LookupOffsetInBlockRequest, opts ...grpc.CallOption) (*LookupOffsetInBlockResponse, error) Status(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*StatusResponse, error) } @@ -157,6 +159,68 @@ func (x *segmentServerAppendToBlockStreamClient) Recv() (*AppendToBlockStreamRes return m, nil } +func (c *segmentServerClient) ReadFromBlockStream(ctx context.Context, opts ...grpc.CallOption) (SegmentServer_ReadFromBlockStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &SegmentServer_ServiceDesc.Streams[1], "/linkall.vanus.segment.SegmentServer/ReadFromBlockStream", opts...) + if err != nil { + return nil, err + } + x := &segmentServerReadFromBlockStreamClient{stream} + return x, nil +} + +type SegmentServer_ReadFromBlockStreamClient interface { + Send(*ReadFromBlockStreamRequest) error + Recv() (*ReadFromBlockStreamResponse, error) + grpc.ClientStream +} + +type segmentServerReadFromBlockStreamClient struct { + grpc.ClientStream +} + +func (x *segmentServerReadFromBlockStreamClient) Send(m *ReadFromBlockStreamRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *segmentServerReadFromBlockStreamClient) Recv() (*ReadFromBlockStreamResponse, error) { + m := new(ReadFromBlockStreamResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *segmentServerClient) AppendToBlockAsyncStream(ctx context.Context, opts ...grpc.CallOption) (SegmentServer_AppendToBlockAsyncStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &SegmentServer_ServiceDesc.Streams[2], "/linkall.vanus.segment.SegmentServer/AppendToBlockAsyncStream", opts...) + if err != nil { + return nil, err + } + x := &segmentServerAppendToBlockAsyncStreamClient{stream} + return x, nil +} + +type SegmentServer_AppendToBlockAsyncStreamClient interface { + Send(*AppendToBlockAsyncStreamRequest) error + Recv() (*AppendToBlockAsyncStreamResponse, error) + grpc.ClientStream +} + +type segmentServerAppendToBlockAsyncStreamClient struct { + grpc.ClientStream +} + +func (x *segmentServerAppendToBlockAsyncStreamClient) Send(m *AppendToBlockAsyncStreamRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *segmentServerAppendToBlockAsyncStreamClient) Recv() (*AppendToBlockAsyncStreamResponse, error) { + m := new(AppendToBlockAsyncStreamResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + func (c *segmentServerClient) LookupOffsetInBlock(ctx context.Context, in *LookupOffsetInBlockRequest, opts ...grpc.CallOption) (*LookupOffsetInBlockResponse, error) { out := new(LookupOffsetInBlockResponse) err := c.cc.Invoke(ctx, "/linkall.vanus.segment.SegmentServer/LookupOffsetInBlock", in, out, opts...) @@ -189,6 +253,8 @@ type SegmentServerServer interface { AppendToBlock(context.Context, *AppendToBlockRequest) (*AppendToBlockResponse, error) ReadFromBlock(context.Context, *ReadFromBlockRequest) (*ReadFromBlockResponse, error) AppendToBlockStream(SegmentServer_AppendToBlockStreamServer) error + ReadFromBlockStream(SegmentServer_ReadFromBlockStreamServer) error + AppendToBlockAsyncStream(SegmentServer_AppendToBlockAsyncStreamServer) error LookupOffsetInBlock(context.Context, *LookupOffsetInBlockRequest) (*LookupOffsetInBlockResponse, error) Status(context.Context, *emptypb.Empty) (*StatusResponse, error) } @@ -227,6 +293,12 @@ func (UnimplementedSegmentServerServer) ReadFromBlock(context.Context, *ReadFrom func (UnimplementedSegmentServerServer) AppendToBlockStream(SegmentServer_AppendToBlockStreamServer) error { return status.Errorf(codes.Unimplemented, "method AppendToBlockStream not implemented") } +func (UnimplementedSegmentServerServer) ReadFromBlockStream(SegmentServer_ReadFromBlockStreamServer) error { + return status.Errorf(codes.Unimplemented, "method ReadFromBlockStream not implemented") +} +func (UnimplementedSegmentServerServer) AppendToBlockAsyncStream(SegmentServer_AppendToBlockAsyncStreamServer) error { + return status.Errorf(codes.Unimplemented, "method AppendToBlockAsyncStream not implemented") +} func (UnimplementedSegmentServerServer) LookupOffsetInBlock(context.Context, *LookupOffsetInBlockRequest) (*LookupOffsetInBlockResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method LookupOffsetInBlock not implemented") } @@ -433,6 +505,58 @@ func (x *segmentServerAppendToBlockStreamServer) Recv() (*AppendToBlockStreamReq return m, nil } +func _SegmentServer_ReadFromBlockStream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(SegmentServerServer).ReadFromBlockStream(&segmentServerReadFromBlockStreamServer{stream}) +} + +type SegmentServer_ReadFromBlockStreamServer interface { + Send(*ReadFromBlockStreamResponse) error + Recv() (*ReadFromBlockStreamRequest, error) + grpc.ServerStream +} + +type segmentServerReadFromBlockStreamServer struct { + grpc.ServerStream +} + +func (x *segmentServerReadFromBlockStreamServer) Send(m *ReadFromBlockStreamResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *segmentServerReadFromBlockStreamServer) Recv() (*ReadFromBlockStreamRequest, error) { + m := new(ReadFromBlockStreamRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _SegmentServer_AppendToBlockAsyncStream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(SegmentServerServer).AppendToBlockAsyncStream(&segmentServerAppendToBlockAsyncStreamServer{stream}) +} + +type SegmentServer_AppendToBlockAsyncStreamServer interface { + Send(*AppendToBlockAsyncStreamResponse) error + Recv() (*AppendToBlockAsyncStreamRequest, error) + grpc.ServerStream +} + +type segmentServerAppendToBlockAsyncStreamServer struct { + grpc.ServerStream +} + +func (x *segmentServerAppendToBlockAsyncStreamServer) Send(m *AppendToBlockAsyncStreamResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *segmentServerAppendToBlockAsyncStreamServer) Recv() (*AppendToBlockAsyncStreamRequest, error) { + m := new(AppendToBlockAsyncStreamRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + func _SegmentServer_LookupOffsetInBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(LookupOffsetInBlockRequest) if err := dec(in); err != nil { @@ -528,6 +652,18 @@ var SegmentServer_ServiceDesc = grpc.ServiceDesc{ ServerStreams: true, ClientStreams: true, }, + { + StreamName: "ReadFromBlockStream", + Handler: _SegmentServer_ReadFromBlockStream_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "AppendToBlockAsyncStream", + Handler: _SegmentServer_AppendToBlockAsyncStream_Handler, + ServerStreams: true, + ClientStreams: true, + }, }, Metadata: "segment.proto", } diff --git a/proto/proto/segment.proto b/proto/proto/segment.proto index acb52108b..0aff6b42d 100644 --- a/proto/proto/segment.proto +++ b/proto/proto/segment.proto @@ -36,6 +36,8 @@ service SegmentServer { rpc AppendToBlock(AppendToBlockRequest) returns (AppendToBlockResponse); rpc ReadFromBlock(ReadFromBlockRequest) returns (ReadFromBlockResponse); rpc AppendToBlockStream(stream AppendToBlockStreamRequest) returns (stream AppendToBlockStreamResponse); + rpc ReadFromBlockStream(stream ReadFromBlockStreamRequest) returns (stream ReadFromBlockStreamResponse); + rpc AppendToBlockAsyncStream(stream AppendToBlockAsyncStreamRequest) returns (stream AppendToBlockAsyncStreamResponse); rpc LookupOffsetInBlock(LookupOffsetInBlockRequest) returns (LookupOffsetInBlockResponse); rpc Status(google.protobuf.Empty) returns (StatusResponse); @@ -102,6 +104,11 @@ message ReadFromBlockResponse { bytes payload = 2; } +enum ResponseCode { + SUCCESS = 0; + UNKNOWN = 1; + SegmentFull = 2; +} message AppendToBlockStreamRequest { uint64 request_id = 1; @@ -109,13 +116,37 @@ message AppendToBlockStreamRequest { io.cloudevents.v1.CloudEventBatch events = 3; } -enum ResponseCode { - SUCCESS = 0; - UNKNOWN = 1; - SegmentFull = 2; +message AppendToBlockStreamResponse { + uint64 response_id = 1; + ResponseCode response_code = 2; + repeated int64 offsets = 3; } -message AppendToBlockStreamResponse { +message ReadFromBlockStreamRequest { + uint64 request_id = 1; + uint64 block_id = 2; + int64 offset = 3; + int64 number = 4; + // polling timeout in milliseconds, 0 is disable. + uint32 polling_timeout = 5; +} + +message ReadFromBlockStreamResponse { + uint64 response_id = 1; + ResponseCode response_code = 2; + io.cloudevents.v1.CloudEventBatch events = 3; + // Don't use this now, just used to optimize cpu overhead of SegmentServer in + // the future for backward compatibility + bytes payload = 4; +} + +message AppendToBlockAsyncStreamRequest { + uint64 request_id = 1; + uint64 block_id = 2; + io.cloudevents.v1.CloudEventBatch events = 3; +} + +message AppendToBlockAsyncStreamResponse { uint64 response_id = 1; ResponseCode response_code = 2; repeated int64 offsets = 3;