Skip to content

Commit

Permalink
remove logrus dependency, go mod tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Dec 8, 2023
1 parent ddf50c4 commit bf7cc1b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 31 deletions.
13 changes: 6 additions & 7 deletions flow/connectors/utils/cdc_records/cdc_records_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"encoding/gob"
"errors"
"fmt"
"log/slog"
"math/big"
"os"
"time"

"github.com/PeerDB-io/peer-flow/model"
util "github.com/PeerDB-io/peer-flow/utils"
"github.com/cockroachdb/pebble"
"github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -84,9 +84,8 @@ func (c *cdcRecordsStore) Set(key model.TableWithPkey, rec model.Record) error {
c.inMemoryRecords[key] = rec
} else {
if c.pebbleDB == nil {
logrus.WithFields(logrus.Fields{
"flowName": c.flowJobName,
}).Infof("more than %d primary keys read, spilling to disk", c.numRecordsSwitchThreshold)
slog.Info("more than %d primary keys read, spilling to disk", c.numRecordsSwitchThreshold,
slog.String("flowName", c.flowJobName))
err := c.initPebbleDB()
if err != nil {
return err
Expand Down Expand Up @@ -136,9 +135,9 @@ func (c *cdcRecordsStore) Get(key model.TableWithPkey) (model.Record, bool, erro
defer func() {
err := closer.Close()
if err != nil {
logrus.WithFields(logrus.Fields{
"flowName": c.flowJobName,
}).Warnf("failed to close database: %v", err)
slog.Warn("failed to close database",
slog.Any("error", err),
slog.String("flowName", c.flowJobName))
}
}()

Expand Down
4 changes: 2 additions & 2 deletions flow/e2e/congen.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package e2e
import (
"context"
"fmt"
"log/slog"

"github.com/PeerDB-io/peer-flow/connectors/utils"
"github.com/PeerDB-io/peer-flow/generated/protos"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -103,7 +103,7 @@ func SetupPostgres(suffix string) (*pgxpool.Pool, error) {
defer func() {
deferErr := setupTx.Rollback(context.Background())
if deferErr != pgx.ErrTxClosed && deferErr != nil {
logrus.Errorf("error rolling back setup transaction: %v", err)
slog.Error("error rolling back setup transaction", slog.Any("error", err))
}
}()

Expand Down
6 changes: 2 additions & 4 deletions flow/e2e/postgres/qrep_flow_pg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package e2e_postgres
import (
"context"
"fmt"
"log/slog"
"strings"
"testing"

Expand All @@ -11,7 +12,6 @@ import (
"github.com/PeerDB-io/peer-flow/generated/protos"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/joho/godotenv"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/suite"
"go.temporal.io/sdk/testsuite"
)
Expand All @@ -37,11 +37,9 @@ func (s *PeerFlowE2ETestSuitePG) SetupSuite() {
if err != nil {
// it's okay if the .env file is not present
// we will use the default values
log.Infof("Unable to load .env file, using default values from env")
slog.Info("Unable to load .env file, using default values from env")
}

log.SetReportCaller(true)

pool, err := e2e.SetupPostgres(postgresSuffix)
if err != nil || pool == nil {
s.Fail("failed to setup postgres", err)
Expand Down
6 changes: 2 additions & 4 deletions flow/e2e/s3/qrep_flow_s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package e2e_s3
import (
"context"
"fmt"
"log/slog"
"testing"
"time"

"github.com/PeerDB-io/peer-flow/e2e"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/joho/godotenv"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.temporal.io/sdk/testsuite"
Expand Down Expand Up @@ -55,11 +55,9 @@ func (s *PeerFlowE2ETestSuiteS3) SetupSuite() {
if err != nil {
// it's okay if the .env file is not present
// we will use the default values
log.Infof("Unable to load .env file, using default values from env")
slog.Info("Unable to load .env file, using default values from env")
}

log.SetReportCaller(true)

pool, err := e2e.SetupPostgres(s3Suffix)
if err != nil || pool == nil {
s.Fail("failed to setup postgres", err)
Expand Down
10 changes: 5 additions & 5 deletions flow/e2e/s3/s3_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"log/slog"
"os"
"time"

Expand All @@ -12,7 +13,6 @@ import (
"github.com/PeerDB-io/peer-flow/generated/protos"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/s3"
log "github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -98,10 +98,10 @@ func (h *S3TestHelper) ListAllFiles(
Prefix: &Prefix,
})
if err != nil {
log.Errorf("failed to list bucket files: %v", err)
slog.Error("failed to list bucket files", slog.Any("error", err))
return nil, err
}
log.Infof("Files in ListAllFiles in S3 test: %v", files)
slog.Info(fmt.Sprintf("Files in ListAllFiles in S3 test: %v", files))
return files.Contents, nil
}

Expand All @@ -114,7 +114,7 @@ func (h *S3TestHelper) CleanUp() error {
Prefix: &Prefix,
})
if err != nil {
log.Errorf("failed to list bucket files: %v", err)
slog.Error("failed to list bucket files", slog.Any("error", err))
return err
}

Expand All @@ -131,6 +131,6 @@ func (h *S3TestHelper) CleanUp() error {
}
}

log.Infof("Deletion completed.")
slog.Info("Deletion completed.")
return nil
}
9 changes: 4 additions & 5 deletions flow/e2e/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
peerflow "github.com/PeerDB-io/peer-flow/workflows"
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgxpool"
log "github.com/sirupsen/logrus"
"go.temporal.io/sdk/testsuite"
)

Expand Down Expand Up @@ -70,15 +69,15 @@ func SetupCDCFlowStatusQuery(env *testsuite.TestWorkflowEnvironment,
var state peerflow.CDCFlowWorkflowState
err = response.Get(&state)
if err != nil {
log.Errorln(err)
slog.Error(err.Error())
}

if state.SnapshotComplete {
break
}
} else {
// log the error for informational purposes
log.Errorln(err)
slog.Error(err.Error())
}
time.Sleep(1 * time.Second)
}
Expand All @@ -99,7 +98,7 @@ func NormalizeFlowCountQuery(env *testsuite.TestWorkflowEnvironment,
var state peerflow.CDCFlowWorkflowState
err = response.Get(&state)
if err != nil {
log.Errorln(err)
slog.Error(err.Error())
}

if len(state.NormalizeFlowStatuses) >= minCount {
Expand All @@ -108,7 +107,7 @@ func NormalizeFlowCountQuery(env *testsuite.TestWorkflowEnvironment,
}
} else {
// log the error for informational purposes
log.Errorln(err)
slog.Error(err.Error())
}
time.Sleep(1 * time.Second)
}
Expand Down
4 changes: 2 additions & 2 deletions flow/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub v1.2.0
github.com/aws/aws-sdk-go v1.47.9
github.com/cenkalti/backoff/v4 v4.2.1
github.com/cockroachdb/pebble v0.0.0-20231130180345-51fca96df08f
github.com/google/uuid v1.4.0
github.com/grafana/pyroscope-go v1.0.4
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1
Expand All @@ -24,7 +25,6 @@ require (
github.com/linkedin/goavro/v2 v2.12.0
github.com/microsoft/go-mssqldb v1.6.0
github.com/orcaman/concurrent-map/v2 v2.0.1
github.com/sirupsen/logrus v1.9.3
github.com/snowflakedb/gosnowflake v1.6.25
github.com/stretchr/testify v1.8.4
github.com/twpayne/go-geos v0.14.0
Expand All @@ -47,7 +47,6 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20231130180345-51fca96df08f // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
Expand All @@ -60,6 +59,7 @@ require (
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
)

require (
Expand Down
13 changes: 11 additions & 2 deletions flow/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,14 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4=
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8=
github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs=
github.com/cockroachdb/metamorphic v0.0.0-20231108215700-4ba948b56895 h1:XANOgPYtvELQ/h4IrmPAohXqe2pWA8Bwhejr3VQoZsA=
github.com/cockroachdb/metamorphic v0.0.0-20231108215700-4ba948b56895/go.mod h1:aPd7gM9ov9M8v32Yy5NJrDyOcD8z642dqs+F0CeNXfA=
github.com/cockroachdb/pebble v0.0.0-20231130180345-51fca96df08f h1:XkkAFIUJ3t1Wt/z9wXqZaebwiZteIzmQfAkN4IHQKLY=
github.com/cockroachdb/pebble v0.0.0-20231130180345-51fca96df08f/go.mod h1:BHuaMa/lK7fUe75BlsteiiTu8ptIG+qSAuDtGMArP18=
github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30=
Expand Down Expand Up @@ -193,6 +197,8 @@ github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcP
github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0=
github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down Expand Up @@ -276,6 +282,7 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw=
Expand Down Expand Up @@ -409,6 +416,8 @@ github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ=
github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down Expand Up @@ -455,8 +464,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/snowflakedb/gosnowflake v1.6.25 h1:o5zUmxTOo0Eo9AdkEj8blCeiMuILrQJ+rjUMAeZhcRE=
github.com/snowflakedb/gosnowflake v1.6.25/go.mod h1:KfO4F7bk+aXPUIvBqYxvPhxLlu2/w4TtSC8Rw/yr5Mg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down

0 comments on commit bf7cc1b

Please sign in to comment.