Skip to content

Commit

Permalink
Removing Google Pub/Sub - Part 2 (#1124)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored Jan 29, 2025
1 parent 672fdc6 commit 21cc3da
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Transfer is aiming to provide coverage across all OLTPs and OLAPs databases. Cur

- Message Queues
- Kafka (default)
- Google Pub/Sub

- [Destinations](https://artie.com/docs/destinations):
- BigQuery
Expand Down
2 changes: 1 addition & 1 deletion lib/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (c Config) Validate() error {
return fmt.Errorf("kafka config is nil")
}

// Username and password are not required (if it's within the same VPC or connecting locally
// Username and password may not be required if this is connecting to a private Kafka cluster.
if stringutil.Empty(c.Kafka.GroupID, c.Kafka.BootstrapServer) {
return fmt.Errorf("kafka group or bootstrap server is empty")
}
Expand Down
5 changes: 2 additions & 3 deletions lib/optimization/table_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ type TableData struct {
topicConfig kafkalib.TopicConfig
// Partition to the latest offset(s).
// For Kafka, we only need the last message to commit the offset
// However, pub/sub requires every single message to be acked
PartitionsToLastMessage map[string][]artie.Message
PartitionsToLastMessage map[string]artie.Message

// This is used for the automatic schema detection
LatestCDCTs time.Time
Expand Down Expand Up @@ -151,7 +150,7 @@ func NewTableData(inMemoryColumns *columns.Columns, mode config.Mode, primaryKey
topicConfig: topicConfig,
// temporaryTableSuffix is being set in `ResetTempTableSuffix`
temporaryTableSuffix: "",
PartitionsToLastMessage: map[string][]artie.Message{},
PartitionsToLastMessage: map[string]artie.Message{},
name: name,
}

Expand Down
2 changes: 1 addition & 1 deletion models/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (e *Event) Save(cfg config.Config, inMemDB *models.DatabaseData, tc kafkali
td.InsertRow(e.PrimaryKeyValue(), e.Data, e.Deleted)
// If the message is Kafka, then we only need the latest one
if message.Kind() == artie.Kafka {
td.PartitionsToLastMessage[message.Partition()] = []artie.Message{message}
td.PartitionsToLastMessage[message.Partition()] = message
}

td.LatestCDCTs = e.executionTime
Expand Down
16 changes: 7 additions & 9 deletions processes/consumer/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ type TopicConfigFormatter struct {
cdc.Format
}

func commitOffset(ctx context.Context, topic string, partitionsToOffset map[string][]artie.Message) error {
for _, msgs := range partitionsToOffset {
for _, msg := range msgs {
if msg.KafkaMsg != nil {
if err := topicToConsumer.Get(topic).CommitMessages(ctx, *msg.KafkaMsg); err != nil {
return err
}

slog.Info("Successfully committed Kafka offset", slog.String("topic", topic), slog.Int("partition", msg.KafkaMsg.Partition), slog.Int64("offset", msg.KafkaMsg.Offset))
func commitOffset(ctx context.Context, topic string, partitionsToOffset map[string]artie.Message) error {
for _, msg := range partitionsToOffset {
if msg.KafkaMsg != nil {
if err := topicToConsumer.Get(topic).CommitMessages(ctx, *msg.KafkaMsg); err != nil {
return err
}

slog.Info("Successfully committed Kafka offset", slog.String("topic", topic), slog.Int("partition", msg.KafkaMsg.Partition), slog.Int64("offset", msg.KafkaMsg.Offset))
}
}

Expand Down

0 comments on commit 21cc3da

Please sign in to comment.