Skip to content

Commit

Permalink
Rename packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyhb committed Sep 16, 2024
1 parent 0ff21ef commit 6733e11
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/inngest/dbcap/pkg/changeset"
"github.com/inngest/dbcap/pkg/eventwriter"
"github.com/inngest/dbcap/pkg/replicator/pg"
"github.com/inngest/dbcap/pkg/replicator/pgreplicator"
"github.com/jackc/pgx/v5"
)

Expand All @@ -26,7 +26,7 @@ func main() {
panic(err)
}

r, err := pg.Postgres(ctx, pg.PostgresOpts{
r, err := pgreplicator.New(ctx, pgreplicator.Opts{
Config: *config,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/test/pg_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/inngest/dbcap/pkg/replicator/pg/pgsetup"
"github.com/inngest/dbcap/pkg/replicator/pgreplicator/pgsetup"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
"github.com/stretchr/testify/require"
Expand Down
10 changes: 5 additions & 5 deletions pkg/replicator/pg/pg.go → pkg/replicator/pgreplicator/pg.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pg
package pgreplicator

import (
"context"
Expand Down Expand Up @@ -54,7 +54,7 @@ type PostgresReplicator interface {
Close(ctx context.Context) error
}

type PostgresOpts struct {
type Opts struct {
Config pgx.ConnConfig
// WatermarkSaver saves the current watermark to local storage. This should be paired with a
// WatermarkLoader to load offsets when the replicator restarts.
Expand All @@ -68,8 +68,8 @@ type PostgresOpts struct {
Log *slog.Logger
}

// Postgres returns a new postgres replicator for a single postgres database.
func Postgres(ctx context.Context, opts PostgresOpts) (PostgresReplicator, error) {
// New returns a new postgres replicator for a single postgres database.
func New(ctx context.Context, opts Opts) (PostgresReplicator, error) {
cfg := opts.Config

// Ensure that we add "replication": "database" as a to the replication
Expand Down Expand Up @@ -114,7 +114,7 @@ func Postgres(ctx context.Context, opts PostgresOpts) (PostgresReplicator, error

type pg struct {
// opts stores the initialization opts, including watermark functs
opts PostgresOpts
opts Opts
// conn is the WAL streaming connection. Once replication starts, this
// conn cannot be used for any queries.
conn *pgx.Conn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pg
package pgreplicator

import (
"context"
Expand Down Expand Up @@ -32,7 +32,7 @@ func TestReplicationSlot(t *testing.T) {
DisableCreateSlot: true,
})

r, err := Postgres(ctx, PostgresOpts{Config: cfg})
r, err := New(ctx, Opts{Config: cfg})
require.NoError(t, err)

_, err = r.ReplicationSlot(ctx)
Expand All @@ -50,7 +50,7 @@ func TestReplicationSlot(t *testing.T) {
DisableCreateSlot: true,
})

r, err := Postgres(ctx, PostgresOpts{Config: cfg})
r, err := New(ctx, Opts{Config: cfg})
require.NoError(t, err)

_, err = r.ReplicationSlot(ctx)
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestCommit(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())

c, cfg := test.StartPG(t, ctx, test.StartPGOpts{Version: v})
r, err := Postgres(ctx, PostgresOpts{Config: cfg})
r, err := New(ctx, Opts{Config: cfg})
require.NoError(t, err)

// Set up event writer which listens to changes
Expand Down Expand Up @@ -134,8 +134,8 @@ func TestInsert(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())

c, conn := test.StartPG(t, ctx, test.StartPGOpts{Version: v})
opts := PostgresOpts{Config: conn}
r, err := Postgres(ctx, opts)
opts := Opts{Config: conn}
r, err := New(ctx, opts)
require.NoError(t, err)

var (
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestUpdateMany_ReplicaIdentityFull(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())

c, connCfg := test.StartPG(t, ctx, test.StartPGOpts{Version: v})
opts := PostgresOpts{Config: connCfg}
opts := Opts{Config: connCfg}

//
// Insert accounts before starting replication watching. This lets us
Expand All @@ -234,7 +234,7 @@ func TestUpdateMany_ReplicaIdentityFull(t *testing.T) {
Interval: 1 * time.Millisecond,
})

r, err := Postgres(ctx, opts)
r, err := New(ctx, opts)
require.NoError(t, err)

var (
Expand Down Expand Up @@ -374,7 +374,7 @@ func TestUpdateMany_DisableReplicaIdentityFull(t *testing.T) {
Version: v,
DisableReplicaIdentityFull: true,
})
opts := PostgresOpts{Config: connCfg}
opts := Opts{Config: connCfg}

//
// Insert accounts before starting replication watching. This lets us
Expand All @@ -385,7 +385,7 @@ func TestUpdateMany_DisableReplicaIdentityFull(t *testing.T) {
Interval: 1 * time.Millisecond,
})

r, err := Postgres(ctx, opts)
r, err := New(ctx, opts)
require.NoError(t, err)

var (
Expand Down Expand Up @@ -492,8 +492,8 @@ func TestConnectingWithoutLogicalReplicationFails(t *testing.T) {
DisableCreateSlot: true,
})

opts := PostgresOpts{Config: conn}
r, err := Postgres(ctx, opts)
opts := Opts{Config: conn}
r, err := New(ctx, opts)
require.NoError(t, err)

err = r.Pull(ctx, nil)
Expand All @@ -513,8 +513,8 @@ func TestConnectingWithoutReplicationSlotFails(t *testing.T) {
DisableCreateSlot: true,
})

opts := PostgresOpts{Config: conn}
r, err := Postgres(ctx, opts)
opts := Opts{Config: conn}
r, err := New(ctx, opts)
require.NoError(t, err)

err = r.Pull(ctx, nil)
Expand All @@ -534,8 +534,8 @@ func TestMultipleConectionsFail(t *testing.T) {
})

// The first time we connect things should succeed.
opts := PostgresOpts{Config: conn}
r1, err := Postgres(ctx, opts)
opts := Opts{Config: conn}
r1, err := New(ctx, opts)
require.NoError(t, err)

wg := sync.WaitGroup{}
Expand All @@ -549,7 +549,7 @@ func TestMultipleConectionsFail(t *testing.T) {

<-time.After(50 * time.Millisecond)

r2, err := Postgres(ctx, opts)
r2, err := New(ctx, opts)
require.NoError(t, err)

err = r2.Pull(ctx, nil)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pg
package pgreplicator

import (
"sync/atomic"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pg
package pgreplicator

import (
"testing"
Expand Down

0 comments on commit 6733e11

Please sign in to comment.