Skip to content

Instantly share code, notes, and snippets.

{
"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",
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
);
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;
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;
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)
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)
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 {
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 {
input {
kafka{
codec => json
bootstrap_servers => "localhost:9092"
topics => ["elastic-test"]
}
}
filter {
mutate {
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");