@@ -53,8 +53,9 @@ func (c *Client) Sync(ctx context.Context, options plugin.SyncOptions, res chan<
5353 if options .BackendOptions == nil {
5454 c .logger .Info ().Msg ("No backend options provided, using no state backend" )
5555 stateClient = & state.NoOpClient {}
56+ c .backendConn = nil
5657 } else {
57- conn , err : = grpc .DialContext (ctx , options .BackendOptions .Connection ,
58+ c . backendConn , err = grpc .DialContext (ctx , options .BackendOptions .Connection ,
5859 grpc .WithTransportCredentials (insecure .NewCredentials ()),
5960 grpc .WithDefaultCallOptions (
6061 grpc .MaxCallRecvMsgSize (maxMsgSize ),
@@ -64,7 +65,7 @@ func (c *Client) Sync(ctx context.Context, options plugin.SyncOptions, res chan<
6465 if err != nil {
6566 return fmt .Errorf ("failed to dial grpc source plugin at %s: %w" , options .BackendOptions .Connection , err )
6667 }
67- stateClient , err = state .NewClient (ctx , conn , options .BackendOptions .TableName )
68+ stateClient , err = state .NewClient (ctx , c . backendConn , options .BackendOptions .TableName )
6869 if err != nil {
6970 return fmt .Errorf ("failed to create state client: %w" , err )
7071 }
@@ -79,16 +80,19 @@ func (c *Client) Sync(ctx context.Context, options plugin.SyncOptions, res chan<
7980 return c .scheduler .Sync (ctx , schedulerClient , tt , res , scheduler .WithSyncDeterministicCQID (options .DeterministicCQID ))
8081}
8182
82- func (c * Client ) Tables (ctx context.Context , options plugin.TableOptions ) (schema.Tables , error ) {
83+ func (c * Client ) Tables (_ context.Context , options plugin.TableOptions ) (schema.Tables , error ) {
8384 tt , err := c .tables .FilterDfs (options .Tables , options .SkipTables , options .SkipDependentTables )
8485 if err != nil {
8586 return nil , err
8687 }
8788 return tt , nil
8889}
8990
90- func (c * Client ) Close (ctx context.Context ) error {
91- return c .backendConn .Close ()
91+ func (c * Client ) Close (_ context.Context ) error {
92+ if c .backendConn != nil {
93+ return c .backendConn .Close ()
94+ }
95+ return nil
9296}
9397
9498func getTables () []* schema.Table {
@@ -106,7 +110,7 @@ func getTables() []*schema.Table {
106110 return tables
107111}
108112
109- func Configure (ctx context.Context , logger zerolog.Logger , specBytes []byte , opts plugin.NewClientOptions ) (plugin.Client , error ) {
113+ func Configure (_ context.Context , logger zerolog.Logger , specBytes []byte , opts plugin.NewClientOptions ) (plugin.Client , error ) {
110114 if opts .NoConnection {
111115 return & Client {
112116 logger : logger ,
0 commit comments