-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use VStream() #120
Use VStream() #120
Changes from 22 commits
b1853c3
f885974
7a6e7a4
309f337
b2120e3
3f0fede
21918b2
c47c820
d77e959
06f5d6d
00a549f
772b9ae
a873826
0baf971
3c744d6
5b061ec
2238dcc
45f45d5
6c4e381
4b8c976
375dbc8
317637e
2c22667
3fffdc9
0a6aed6
2f4559e
7026de9
cbf56ba
787467c
02057d4
6689561
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,11 @@ package internal | |
import ( | ||
"context" | ||
"database/sql" | ||
psdbconnect "github.com/planetscale/airbyte-source/proto/psdbconnect/v1alpha1" | ||
"google.golang.org/grpc" | ||
"io" | ||
|
||
"google.golang.org/grpc" | ||
"vitess.io/vitess/go/vt/proto/vtgate" | ||
vtgateservice "vitess.io/vitess/go/vt/proto/vtgateservice" | ||
) | ||
|
||
type testAirbyteLogger struct { | ||
|
@@ -51,29 +53,54 @@ func (testAirbyteLogger) Error(error string) { | |
panic("implement me") | ||
} | ||
|
||
type clientConnectionMock struct { | ||
syncFn func(ctx context.Context, in *psdbconnect.SyncRequest, opts ...grpc.CallOption) (psdbconnect.Connect_SyncClient, error) | ||
syncFnInvoked bool | ||
syncFnInvokedCount int | ||
type vstreamClientMock struct { | ||
vstreamFn func(ctx context.Context, in *vtgate.VStreamRequest, opts ...grpc.CallOption) (vtgateservice.Vitess_VStreamClient, error) | ||
vstreamFnInvoked bool | ||
vstreamFnInvokedCount int | ||
} | ||
|
||
type connectSyncClientMock struct { | ||
type vtgateVStreamClientMock struct { | ||
lastResponseSent int | ||
syncResponses []*psdbconnect.SyncResponse | ||
vstreamResponses []*vtgate.VStreamResponse | ||
grpc.ClientStream | ||
} | ||
|
||
func (x *connectSyncClientMock) Recv() (*psdbconnect.SyncResponse, error) { | ||
if x.lastResponseSent >= len(x.syncResponses) { | ||
func (x *vtgateVStreamClientMock) Recv() (*vtgate.VStreamResponse, error) { | ||
if x.lastResponseSent >= len(x.vstreamResponses) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a little unclear to me what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I am pretty sure last response sent keeps track of which index of mock sync responses should be sent next! |
||
return nil, io.EOF | ||
} | ||
x.lastResponseSent += 1 | ||
return x.syncResponses[x.lastResponseSent-1], nil | ||
return x.vstreamResponses[x.lastResponseSent-1], nil | ||
} | ||
|
||
func (x *vstreamClientMock) CloseSession(context.Context, *vtgate.CloseSessionRequest, ...grpc.CallOption) (*vtgate.CloseSessionResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (x *vstreamClientMock) Execute(context.Context, *vtgate.ExecuteRequest, ...grpc.CallOption) (*vtgate.ExecuteResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (x *vstreamClientMock) ExecuteBatch(context.Context, *vtgate.ExecuteBatchRequest, ...grpc.CallOption) (*vtgate.ExecuteBatchResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (x *vstreamClientMock) Prepare(context.Context, *vtgate.PrepareRequest, ...grpc.CallOption) (*vtgate.PrepareResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (x *vstreamClientMock) ResolveTransaction(context.Context, *vtgate.ResolveTransactionRequest, ...grpc.CallOption) (*vtgate.ResolveTransactionResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (x *vstreamClientMock) StreamExecute(context.Context, *vtgate.StreamExecuteRequest, ...grpc.CallOption) (vtgateservice.Vitess_StreamExecuteClient, error) { | ||
return nil, nil | ||
} | ||
func (c *clientConnectionMock) Sync(ctx context.Context, in *psdbconnect.SyncRequest, opts ...grpc.CallOption) (psdbconnect.Connect_SyncClient, error) { | ||
c.syncFnInvoked = true | ||
c.syncFnInvokedCount += 1 | ||
return c.syncFn(ctx, in, opts...) | ||
|
||
func (c *vstreamClientMock) VStream(ctx context.Context, in *vtgate.VStreamRequest, opts ...grpc.CallOption) (vtgateservice.Vitess_VStreamClient, error) { | ||
c.vstreamFnInvoked = true | ||
c.vstreamFnInvokedCount += 1 | ||
return c.vstreamFn(ctx, in, opts...) | ||
} | ||
|
||
type mysqlAccessMock struct { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that this alias is not needed since it matches the package name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 😄