Skip to content

Commit

Permalink
Move exposed libs to pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
eminano committed Aug 2, 2024
1 parent 5e532a3 commit de26ee0
Show file tree
Hide file tree
Showing 29 changed files with 41 additions and 41 deletions.
10 changes: 5 additions & 5 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"fmt"

"github.com/spf13/viper"
"github.com/xataio/pgstream/internal/backoff"
"github.com/xataio/pgstream/internal/kafka"
"github.com/xataio/pgstream/internal/tls"
"github.com/xataio/pgstream/pkg/backoff"
"github.com/xataio/pgstream/pkg/kafka"
pgschemalog "github.com/xataio/pgstream/pkg/schemalog/postgres"
"github.com/xataio/pgstream/pkg/stream"
"github.com/xataio/pgstream/pkg/tls"
kafkacheckpoint "github.com/xataio/pgstream/pkg/wal/checkpointer/kafka"
kafkalistener "github.com/xataio/pgstream/pkg/wal/listener/kafka"
kafkaprocessor "github.com/xataio/pgstream/pkg/wal/processor/kafka"
Expand Down Expand Up @@ -245,8 +245,8 @@ func parseTranslatorConfig() *translator.Config {
}
}

func parseTLSConfig(prefix string) *tls.Config {
return &tls.Config{
func parseTLSConfig(prefix string) tls.Config {
return tls.Config{
Enabled: viper.GetBool(fmt.Sprintf("%s_TLS_ENABLED", prefix)),
CaCertFile: viper.GetString(fmt.Sprintf("%s_TLS_CA_CERT_FILE", prefix)),
ClientCertFile: viper.GetString(fmt.Sprintf("%s_TLS_CLIENT_CERT_FILE", prefix)),
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package mocks

import "github.com/xataio/pgstream/internal/backoff"
import "github.com/xataio/pgstream/pkg/backoff"

type Backoff struct {
RetryNotifyFn func(backoff.Operation, backoff.Notify) error
Expand Down
4 changes: 2 additions & 2 deletions internal/kafka/config.go → pkg/kafka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

package kafka

import tlslib "github.com/xataio/pgstream/internal/tls"
import tlslib "github.com/xataio/pgstream/pkg/tls"

type ConnConfig struct {
Servers []string
Topic TopicConfig
TLS *tlslib.Config
TLS tlslib.Config
}

type TopicConfig struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/kafka/conn.go → pkg/kafka/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
"strconv"
"time"

tlslib "github.com/xataio/pgstream/internal/tls"
tlslib "github.com/xataio/pgstream/pkg/tls"

"github.com/segmentio/kafka-go"
)

// withConnection creates a connection that can be used by the kafka operation
// passed in the parameters. This ensures the cleanup of all connection resources.
func withConnection(config *ConnConfig, kafkaOperation func(conn *kafka.Conn) error) error {
dialer, err := buildDialer(config.TLS)
dialer, err := buildDialer(&config.TLS)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"time"

"github.com/xataio/pgstream/internal/kafka"
"github.com/xataio/pgstream/pkg/kafka"

"go.opentelemetry.io/otel/metric"
)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewReader(config ReaderConfig, logger loglib.Logger) (*Reader, error) {
return nil, fmt.Errorf("unsupported start offset [%s], must be one of [%s, %s]", config.ConsumerGroupStartOffset, earliestOffset, latestOffset)
}

dialer, err := buildDialer(config.Conn.TLS)
dialer, err := buildDialer(&config.Conn.TLS)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/kafka/kafka_writer.go → pkg/kafka/kafka_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"time"

"github.com/segmentio/kafka-go"
tlslib "github.com/xataio/pgstream/internal/tls"
loglib "github.com/xataio/pgstream/pkg/log"
tlslib "github.com/xataio/pgstream/pkg/tls"
)

type MessageWriter interface {
Expand Down Expand Up @@ -56,7 +56,7 @@ func NewWriter(config WriterConfig, logger loglib.Logger) (*Writer, error) {
}
}

transport, err := buildTransport(config.Conn.TLS)
transport, err := buildTransport(&config.Conn.TLS)
if err != nil {
return nil, err
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package mocks

import "github.com/xataio/pgstream/internal/kafka"
import "github.com/xataio/pgstream/pkg/kafka"

type OffsetParser struct {
ToStringFn func(o *kafka.Offset) string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package mocks
import (
"context"

"github.com/xataio/pgstream/internal/kafka"
"github.com/xataio/pgstream/pkg/kafka"
)

type Reader struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"context"
"sync/atomic"

"github.com/xataio/pgstream/internal/kafka"
"github.com/xataio/pgstream/pkg/kafka"
)

type Writer struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/stream/integration/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"testing"

"github.com/stretchr/testify/require"
kafkalib "github.com/xataio/pgstream/internal/kafka"
"github.com/xataio/pgstream/internal/log/zerolog"
pglib "github.com/xataio/pgstream/internal/postgres"
"github.com/xataio/pgstream/internal/tls"
kafkalib "github.com/xataio/pgstream/pkg/kafka"
loglib "github.com/xataio/pgstream/pkg/log"
schemalogpg "github.com/xataio/pgstream/pkg/schemalog/postgres"
"github.com/xataio/pgstream/pkg/stream"
"github.com/xataio/pgstream/pkg/tls"
"github.com/xataio/pgstream/pkg/wal"
kafkacheckpoint "github.com/xataio/pgstream/pkg/wal/checkpointer/kafka"
kafkalistener "github.com/xataio/pgstream/pkg/wal/listener/kafka"
Expand Down Expand Up @@ -174,7 +174,7 @@ func testKafkaCfg() kafkalib.ConnConfig {
Name: "integration-tests",
AutoCreate: true,
},
TLS: &tls.Config{
TLS: tls.Config{
Enabled: false,
},
}
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions pkg/wal/checkpointer/kafka/wal_kafka_checkpointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"fmt"
"time"

"github.com/xataio/pgstream/internal/backoff"
"github.com/xataio/pgstream/internal/kafka"
"github.com/xataio/pgstream/pkg/backoff"
"github.com/xataio/pgstream/pkg/kafka"
loglib "github.com/xataio/pgstream/pkg/log"
"github.com/xataio/pgstream/pkg/wal"
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/wal/checkpointer/kafka/wal_kafka_checkpointer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

"github.com/stretchr/testify/require"

"github.com/xataio/pgstream/internal/backoff"
backoffmocks "github.com/xataio/pgstream/internal/backoff/mocks"
"github.com/xataio/pgstream/internal/kafka"
kafkamocks "github.com/xataio/pgstream/internal/kafka/mocks"
"github.com/xataio/pgstream/pkg/backoff"
backoffmocks "github.com/xataio/pgstream/pkg/backoff/mocks"
"github.com/xataio/pgstream/pkg/kafka"
kafkamocks "github.com/xataio/pgstream/pkg/kafka/mocks"
loglib "github.com/xataio/pgstream/pkg/log"
"github.com/xataio/pgstream/pkg/wal"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/wal/listener/kafka/wal_kafka_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"runtime/debug"

"github.com/xataio/pgstream/internal/kafka"
"github.com/xataio/pgstream/pkg/kafka"
loglib "github.com/xataio/pgstream/pkg/log"
"github.com/xataio/pgstream/pkg/wal"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/wal/listener/kafka/wal_kafka_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"time"

"github.com/stretchr/testify/require"
"github.com/xataio/pgstream/internal/kafka"
kafkamocks "github.com/xataio/pgstream/internal/kafka/mocks"
"github.com/xataio/pgstream/pkg/kafka"
kafkamocks "github.com/xataio/pgstream/pkg/kafka/mocks"
loglib "github.com/xataio/pgstream/pkg/log"
"github.com/xataio/pgstream/pkg/wal"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/wal/processor/kafka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"errors"
"time"

"github.com/xataio/pgstream/internal/kafka"
"github.com/xataio/pgstream/pkg/kafka"
)

type Config struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/wal/processor/kafka/wal_kafka_batch_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"runtime/debug"
"time"

"github.com/xataio/pgstream/internal/kafka"
kafkainstrumentation "github.com/xataio/pgstream/internal/kafka/instrumentation"
synclib "github.com/xataio/pgstream/internal/sync"
"github.com/xataio/pgstream/pkg/kafka"
kafkainstrumentation "github.com/xataio/pgstream/pkg/kafka/instrumentation"
loglib "github.com/xataio/pgstream/pkg/log"
"github.com/xataio/pgstream/pkg/wal"
"github.com/xataio/pgstream/pkg/wal/checkpointer"
Expand Down
4 changes: 2 additions & 2 deletions pkg/wal/processor/kafka/wal_kafka_batch_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"time"

"github.com/stretchr/testify/require"
"github.com/xataio/pgstream/internal/kafka"
kafkamocks "github.com/xataio/pgstream/internal/kafka/mocks"
synclib "github.com/xataio/pgstream/internal/sync"
syncmocks "github.com/xataio/pgstream/internal/sync/mocks"
"github.com/xataio/pgstream/pkg/kafka"
kafkamocks "github.com/xataio/pgstream/pkg/kafka/mocks"
loglib "github.com/xataio/pgstream/pkg/log"
"github.com/xataio/pgstream/pkg/schemalog"
"github.com/xataio/pgstream/pkg/wal"
Expand Down
2 changes: 1 addition & 1 deletion pkg/wal/processor/kafka/wal_kafka_msg_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package kafka

import (
"github.com/xataio/pgstream/internal/kafka"
"github.com/xataio/pgstream/pkg/kafka"
"github.com/xataio/pgstream/pkg/wal"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/wal/processor/search/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package search
import (
"time"

"github.com/xataio/pgstream/internal/backoff"
"github.com/xataio/pgstream/pkg/backoff"
)

type IndexerConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/wal/processor/search/search_schema_cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"time"

"github.com/xataio/pgstream/internal/backoff"
"github.com/xataio/pgstream/pkg/backoff"
loglib "github.com/xataio/pgstream/pkg/log"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/wal/processor/search/search_schema_cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"time"

"github.com/stretchr/testify/require"
"github.com/xataio/pgstream/internal/backoff"
"github.com/xataio/pgstream/internal/backoff/mocks"
"github.com/xataio/pgstream/pkg/backoff"
"github.com/xataio/pgstream/pkg/backoff/mocks"
loglib "github.com/xataio/pgstream/pkg/log"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/wal/processor/search/search_store_retrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"time"

"github.com/xataio/pgstream/internal/backoff"
"github.com/xataio/pgstream/pkg/backoff"
loglib "github.com/xataio/pgstream/pkg/log"
"github.com/xataio/pgstream/pkg/schemalog"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/wal/processor/search/search_store_retrier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/xataio/pgstream/internal/backoff"
"github.com/xataio/pgstream/pkg/backoff"
loglib "github.com/xataio/pgstream/pkg/log"
)

Expand Down

0 comments on commit de26ee0

Please sign in to comment.