This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "pg_user_data-connector", | |
"config": { | |
"connector.class": "io.debezium.connector.postgresql.PostgresConnector", | |
"tasks.max": "1", | |
"database.hostname": "postgres", | |
"database.port": "5432", | |
"database.user": "postgres", | |
"database.password": "postgres", | |
"database.server.id": "184055", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create extension uuid-ossp; | |
create table user_details ( | |
id text primary key DEFAULT uuid_generate_v4(), | |
name text not null, | |
email text, | |
mobile_number text, | |
created_at timestamp not null default now(), | |
updated_at timestamp | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.spring.hibernate.entity; | |
import lombok.Data; | |
import lombok.NoArgsConstructor; | |
import org.hibernate.annotations.CreationTimestamp; | |
import org.hibernate.annotations.GenericGenerator; | |
import org.hibernate.annotations.UpdateTimestamp; | |
import org.springframework.core.annotation.Order; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.spring.hibernate.entity; | |
import lombok.Getter; | |
import lombok.Setter; | |
import org.hibernate.annotations.CreationTimestamp; | |
import org.hibernate.annotations.GenericGenerator; | |
import org.hibernate.annotations.UpdateTimestamp; | |
import javax.persistence.CascadeType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestTransferTxDeadlock(t *testing.T) { | |
store := NewStore(testDB) | |
sourceAccount := CreateRandomAccount(t) | |
targetAccount := CreateRandomAccount(t) | |
fmt.Println(">> before:", sourceAccount.Balance, targetAccount.Balance) | |
n := 10 | |
amount := int64(10) | |
errs := make(chan error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unc TestTransferTransaction(t *testing.T) { | |
store := NewStore(testDB) | |
sourceAccount := CreateRandomAccount(t) | |
targetAccount := CreateRandomAccount(t) | |
fmt.Println(">> before:", sourceAccount.Balance, targetAccount.Balance) | |
n := 5 | |
amount := int64(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (transaction *DBTransaction) transferTx(ctx context.Context, arg AccountTransferTxParams) (TransferTxResult, error) { | |
var result TransferTxResult | |
err := transaction.executeTx(ctx, func(queries *Queries) error { | |
var err error | |
result.Transfer, err = queries.CreateTransfer(ctx, CreateTransferParams{ | |
SourceAccountID: arg.SourceAccountID, | |
TargetAccountID: arg.TargetAccountID, | |
Amount: arg.Amount, | |
}) | |
if err != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (transaction *DBTransaction) executeTx(ctx context.Context, fn func(*Queries) error) error { | |
tx, err := transaction.db.BeginTx(ctx, nil) | |
if err != nil { | |
return err | |
} | |
query := New(tx) | |
err = fn(query) | |
if err != nil { | |
if rbkerr := tx.Rollback(); rbkerr != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
kafka{ | |
codec => json | |
bootstrap_servers => "localhost:9092" | |
topics => ["elastic-test"] | |
} | |
} | |
filter { | |
mutate { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Kafka, logLevel } from "kafkajs"; | |
import { IEvent, IUser } from "./model"; | |
import { v4 as uuidv4 } from "uuid"; | |
const kafka = new Kafka({ | |
clientId: "random-producer", | |
brokers: ["localhost:9092"], | |
connectionTimeout: 3000, | |
}); | |
var randomstring = require("randomstring"); |