Skip to content

Commit

Permalink
Checkpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Jun 26, 2024
1 parent aee91c0 commit 99abb0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions config/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
)

type MongoDB struct {
Host string `yaml:"host"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Database string `yaml:"database"`

Host string `yaml:"host"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Database string `yaml:"database"`
Collections []Collection `yaml:"collections"`
Streaming bool `yaml:"streaming,omitempty"`
}

type Collection struct {
Expand Down
11 changes: 6 additions & 5 deletions sources/mongo/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"fmt"
"github.com/artie-labs/reader/sources"
"log/slog"
"time"

Expand All @@ -15,12 +16,12 @@ import (
"github.com/artie-labs/reader/writers"
)

type Source struct {
type SnapshotStore struct {
cfg config.MongoDB
db *mongo.Database
}

func Load(cfg config.MongoDB) (*Source, error) {
func Load(cfg config.MongoDB) (sources.Source, error) {
creds := options.Credential{
Username: cfg.Username,
Password: cfg.Password,
Expand All @@ -38,18 +39,18 @@ func Load(cfg config.MongoDB) (*Source, error) {
}

db := client.Database(cfg.Database)
return &Source{
return &SnapshotStore{
cfg: cfg,
db: db,
}, nil
}

func (s *Source) Close() error {
func (s *SnapshotStore) Close() error {
// MongoDB doesn't need to be closed.
return nil
}

func (s *Source) Run(ctx context.Context, writer writers.Writer) error {
func (s *SnapshotStore) Run(ctx context.Context, writer writers.Writer) error {
for _, collection := range s.cfg.Collections {
snapshotStartTime := time.Now()

Expand Down

0 comments on commit 99abb0b

Please sign in to comment.