Skip to content

Commit 41acd5f

Browse files
committed
export StartPartitionSessionConfirm type
1 parent d54354d commit 41acd5f

File tree

6 files changed

+34
-32
lines changed

6 files changed

+34
-32
lines changed

examples/topic/topicreader/topicreader_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (h *TopicEventsHandler) OnReadMessages(
5555

5656
func (h *TopicEventsHandler) OnStartPartitionSessionRequest(
5757
ctx context.Context,
58-
event *topiclistener.StartPartitionSessionEvent,
58+
event *topiclistener.EventStartPartitionSession,
5959
) error {
6060
lockID, offset, err := lockPartition(ctx, event.PartitionSession.TopicPath, event.PartitionSession.PartitionID)
6161

@@ -75,7 +75,7 @@ func (h *TopicEventsHandler) OnStartPartitionSessionRequest(
7575

7676
func (h *TopicEventsHandler) OnStopPartitionSessionRequest(
7777
ctx context.Context,
78-
event *topiclistener.StopPartitionSessionEvent,
78+
event *topiclistener.EventStopPartitionSession,
7979
) error {
8080
h.m.Lock()
8181
lockID := h.locks[event.PartitionSession.PartitionSessionID]

internal/topic/topiclistenerinternal/event_handler.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type EventHandler interface {
1717
// You can set topiclistener.StartPartitionSessionConfirm for change default settings.
1818
//
1919
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
20-
OnStartPartitionSessionRequest(ctx context.Context, event *PublicStartPartitionSessionEvent) error
20+
OnStartPartitionSessionRequest(ctx context.Context, event *PublicEventStartPartitionSession) error
2121

2222
// OnReadMessages called with batch of messages. Max count of messages limited by internal buffer size
2323
//
@@ -32,7 +32,7 @@ type EventHandler interface {
3232
// It is guaranteed about the method will be called least once.
3333
//
3434
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
35-
OnStopPartitionSessionRequest(ctx context.Context, event *PublicStopPartitionSessionEvent) error
35+
OnStopPartitionSessionRequest(ctx context.Context, event *PublicEventStopPartitionSession) error
3636
}
3737

3838
// PublicReadMessages
@@ -43,10 +43,10 @@ type PublicReadMessages struct {
4343
Batch *topicreader.Batch
4444
}
4545

46-
// PublicStartPartitionSessionEvent
46+
// PublicEventStartPartitionSession
4747
//
4848
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
49-
type PublicStartPartitionSessionEvent struct {
49+
type PublicEventStartPartitionSession struct {
5050
PartitionSession topicreadercommon.PublicPartitionSession
5151
CommittedOffset int64
5252
PartitionOffsets PublicOffsetsRange
@@ -57,8 +57,8 @@ func NewPublicStartPartitionSessionEvent(
5757
session topicreadercommon.PublicPartitionSession,
5858
committedOffset int64,
5959
partitionOffsets PublicOffsetsRange,
60-
) *PublicStartPartitionSessionEvent {
61-
return &PublicStartPartitionSessionEvent{
60+
) *PublicEventStartPartitionSession {
61+
return &PublicEventStartPartitionSession{
6262
PartitionSession: session,
6363
CommittedOffset: committedOffset,
6464
PartitionOffsets: partitionOffsets,
@@ -68,11 +68,11 @@ func NewPublicStartPartitionSessionEvent(
6868
// Confirm
6969
//
7070
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
71-
func (e *PublicStartPartitionSessionEvent) Confirm() {
71+
func (e *PublicEventStartPartitionSession) Confirm() {
7272
e.ConfirmWithParams(PublicStartPartitionSessionConfirm{})
7373
}
7474

75-
func (e *PublicStartPartitionSessionEvent) ConfirmWithParams(p PublicStartPartitionSessionConfirm) {
75+
func (e *PublicEventStartPartitionSession) ConfirmWithParams(p PublicStartPartitionSessionConfirm) {
7676
e.confirm.Set(p)
7777
}
7878

@@ -110,10 +110,10 @@ type PublicOffsetsRange struct {
110110
End int64
111111
}
112112

113-
// PublicStopPartitionSessionEvent
113+
// PublicEventStopPartitionSession
114114
//
115115
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
116-
type PublicStopPartitionSessionEvent struct {
116+
type PublicEventStopPartitionSession struct {
117117
PartitionSession topicreadercommon.PublicPartitionSession
118118

119119
// Graceful mean about server is waiting for client finish work with the partition and confirm stop the work
@@ -129,8 +129,8 @@ func NewPublicStopPartitionSessionEvent(
129129
partitionSession topicreadercommon.PublicPartitionSession,
130130
graceful bool,
131131
committedOffset int64,
132-
) *PublicStopPartitionSessionEvent {
133-
return &PublicStopPartitionSessionEvent{
132+
) *PublicEventStopPartitionSession {
133+
return &PublicEventStopPartitionSession{
134134
PartitionSession: partitionSession,
135135
Graceful: graceful,
136136
CommittedOffset: committedOffset,
@@ -140,6 +140,6 @@ func NewPublicStopPartitionSessionEvent(
140140
// Confirm
141141
//
142142
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
143-
func (e *PublicStopPartitionSessionEvent) Confirm() {
143+
func (e *PublicEventStopPartitionSession) Confirm() {
144144
e.confirm.Set(empty.Struct{})
145145
}

internal/topic/topiclistenerinternal/event_handler_mock_test.go

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

internal/topic/topiclistenerinternal/stream_listener_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestStreamListener_OnReceiveServerMessage(t *testing.T) {
7979
EventHandlerMock(e).EXPECT().OnStartPartitionSessionRequest(
8080
gomock.Any(),
8181
gomock.Any(),
82-
).DoAndReturn(func(ctx context.Context, event *PublicStartPartitionSessionEvent) error {
82+
).DoAndReturn(func(ctx context.Context, event *PublicEventStartPartitionSession) error {
8383
require.Equal(t, topicreadercommon.PublicPartitionSession{
8484
PartitionSessionID: 1, // ClientPartitionSessionID
8585
TopicPath: "asd",
@@ -140,7 +140,7 @@ func TestStreamListener_OnReceiveServerMessage(t *testing.T) {
140140
EventHandlerMock(e).EXPECT().OnStopPartitionSessionRequest(
141141
PartitionSession(e).Context(),
142142
gomock.Any(),
143-
).DoAndReturn(func(ctx context.Context, event *PublicStopPartitionSessionEvent) error {
143+
).DoAndReturn(func(ctx context.Context, event *PublicEventStopPartitionSession) error {
144144
require.Equal(t, PartitionSession(e).ClientPartitionSessionID, event.PartitionSession.PartitionSessionID)
145145
require.True(t, event.Graceful)
146146
require.Equal(t, int64(5), event.CommittedOffset)
@@ -174,7 +174,7 @@ func TestStreamListener_CloseSessionsOnCloseListener(t *testing.T) {
174174
EventHandlerMock(e).EXPECT().OnStopPartitionSessionRequest(
175175
PartitionSession(e).Context(),
176176
gomock.Any(),
177-
).Do(func(ctx context.Context, event *PublicStopPartitionSessionEvent) error {
177+
).Do(func(ctx context.Context, event *PublicEventStopPartitionSession) error {
178178
require.Equal(t, PartitionSession(e).ClientPartitionSessionID, event.PartitionSession.PartitionSessionID)
179179
require.False(t, event.Graceful)
180180
require.Equal(t, PartitionSession(e).CommittedOffset().ToInt64(), event.CommittedOffset)

tests/integration/topic_listener_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ type TestTopicListener_Handler struct {
5151

5252
listener *topiclistener.TopicListener
5353
readMessages *topiclistener.ReadMessages
54-
onPartitionStart *topiclistener.StartPartitionSessionEvent
55-
onPartitionStop *topiclistener.StopPartitionSessionEvent
54+
onPartitionStart *topiclistener.EventStartPartitionSession
55+
onPartitionStop *topiclistener.EventStopPartitionSession
5656
done empty.Chan
5757
}
5858

@@ -63,7 +63,7 @@ func (h *TestTopicListener_Handler) OnReaderCreated(event *topiclistener.ReaderR
6363

6464
func (h *TestTopicListener_Handler) OnStartPartitionSessionRequest(
6565
ctx context.Context,
66-
event *topiclistener.StartPartitionSessionEvent,
66+
event *topiclistener.EventStartPartitionSession,
6767
) error {
6868
h.onPartitionStart = event
6969
event.Confirm()
@@ -72,7 +72,7 @@ func (h *TestTopicListener_Handler) OnStartPartitionSessionRequest(
7272

7373
func (h *TestTopicListener_Handler) OnStopPartitionSessionRequest(
7474
ctx context.Context,
75-
event *topiclistener.StopPartitionSessionEvent,
75+
event *topiclistener.EventStopPartitionSession,
7676
) error {
7777
h.onPartitionStop = event
7878
event.Confirm()

topic/topiclistener/event_handler.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (b BaseHandler) OnReaderCreated(event *ReaderReady) error {
4747

4848
func (b BaseHandler) OnStartPartitionSessionRequest(
4949
ctx context.Context,
50-
event *StartPartitionSessionEvent,
50+
event *EventStartPartitionSession,
5151
) error {
5252
event.Confirm()
5353

@@ -61,7 +61,7 @@ func (b BaseHandler) OnStartPartitionSessionRequest(
6161
// not
6262
func (b BaseHandler) OnStopPartitionSessionRequest(
6363
ctx context.Context,
64-
event *StopPartitionSessionEvent,
64+
event *EventStopPartitionSession,
6565
) error {
6666
event.Confirm()
6767

@@ -76,10 +76,12 @@ func (b BaseHandler) OnReadMessages(
7676
}
7777

7878
type (
79-
StartPartitionSessionEvent = topiclistenerinternal.PublicStartPartitionSessionEvent
80-
StopPartitionSessionEvent = topiclistenerinternal.PublicStopPartitionSessionEvent
79+
EventStartPartitionSession = topiclistenerinternal.PublicEventStartPartitionSession
80+
EventStopPartitionSession = topiclistenerinternal.PublicEventStopPartitionSession
8181
)
8282

8383
type PartitionSession = topicreadercommon.PublicPartitionSession
8484

8585
type OffsetsRange = topiclistenerinternal.PublicOffsetsRange
86+
87+
type StartPartitionSessionConfirm = topiclistenerinternal.PublicStartPartitionSessionConfirm

0 commit comments

Comments
 (0)