-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package pgreplicator | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/inngest/dbcap/pkg/replicator" | ||
"github.com/inngest/dbcap/pkg/replicator/pgreplicator/pgsetup" | ||
"github.com/jackc/pgx/v5" | ||
) | ||
|
||
type InitializerOpts struct { | ||
// AdminConfig are admin credentials to verify DB config, eg. replication slots, publications, | ||
// wal mode, etc. | ||
AdminConfig pgx.ConnConfig | ||
|
||
// Password is the password to use when creating the new replication user. | ||
Password string | ||
} | ||
|
||
func NewInitializer(ctx context.Context, opts InitializerOpts) replicator.SystemInitializer { | ||
return initializer{opts: opts} | ||
} | ||
|
||
type initializer struct { | ||
opts InitializerOpts | ||
} | ||
|
||
// PerformInit perform setup for the replicator. | ||
func (i initializer) PerformInit(ctx context.Context) (replicator.ConnectionResult, error) { | ||
return pgsetup.Setup(ctx, pgsetup.SetupOpts{ | ||
AdminConfig: i.opts.AdminConfig, | ||
Password: i.opts.Password, | ||
}) | ||
} | ||
|
||
// CheckInit checks setup for the replicator. | ||
func (i initializer) CheckInit(ctx context.Context) (replicator.ConnectionResult, error) { | ||
return pgsetup.Check(ctx, pgsetup.SetupOpts{ | ||
AdminConfig: i.opts.AdminConfig, | ||
Password: i.opts.Password, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters