Skip to content

Instantly share code, notes, and snippets.

View DennisFederico's full-sized avatar

Dennis Federico DennisFederico

View GitHub Profile

Event Deduplication in Kafka Stream processing using ksqlDB (SIMPLIFIED)

Introduction

Event deduplication emiting the very first message and filtering the rest of the duplicates within a tumbling window or a session window, using ksqlDB.

The ID to deduplicate is the eventId field inside the record payload, thus the first step is to re-key the stream by this field.

The deduplication is done by counting the number of times the eventId appears in the stream within a window, and only emitting the first event that has a count of 1.

@DennisFederico
DennisFederico / CreateSelectionBoxColliderSystem.cs
Created January 17, 2024 22:40
Trigger base selection with a Box collider
using Selection.Components;
using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Physics.Systems;
using Unity.Transforms;
using UnityEngine;
using BoxCollider = Unity.Physics.BoxCollider;
@DennisFederico
DennisFederico / CustomCertsUsingOpenSSL.md
Last active June 21, 2023 10:00
Creating Custom Certificates Using OpenSSL

Using Openssl

Certificate Authority

CA Key

Install Prometheus-Grafana pack

https://www.confluent.io/blog/monitor-kafka-clusters-with-prometheus-grafana-and-confluent/

Note on Ansible Playbooks and Binaries

This document is prepared to set up the monitoring stack using Ansible as much as possible, Prometheus and Grafana have been tested to work on an Air-Gap (no internet access) environment providing the binaries from the official site, using the playbooks from GitHub user (0x0I)[https://github.com/O1ahmad]. Prometheus Node exporter playbook, provided by (Clud Alchemy)[https://github.com/cloudalchemy] has not bee tested on an Air-Gap environment, it doesn't mean it couldn't work.

---
all:
vars:
## ANSIBLE CONNECTIVITY PARAMS AND FLAGS
ansible_connection: ssh
ansible_user: dfederico
ansible_become: true
ansible_ssh_private_key_file: ~/.ssh/id_rsa
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
@DennisFederico
DennisFederico / CustomCertsForConfluent.md
Created May 31, 2023 15:12
Collection of commands to create custom certs for Confluent Platform

Self-signed Certificates

This were prepared using cfssl (Cloud Flare SSL) tools, a wrapper over openssl to simplify its usage, thus opensslmust be installed too.

Prepare CA - Certificate Authority

Create CA Key

$ openssl genrsa -out generated/CAkey.pem 2048
@DennisFederico
DennisFederico / ksqldb-tutorial.md
Created August 4, 2022 17:06
KSQLDB Simple Tutorial with Confluent Cloud
tags: #ksqldb/tutorial

Provisioning ksqlDB Cluster

Cluster Data

environment=env-0x3135
@DennisFederico
DennisFederico / ksqldb-explode-json-array.sql
Created August 4, 2022 15:20
Explode JSON Array of Structs using ksqldb
CREATE TYPE BALANCE_TYPE AS STRUCT<account_id STRING, balance DOUBLE>;
CREATE STREAM CUSTOMER_STATS (
CUSTOMER_ID STRING KEY,
CUSTOMER_NAME STRING,
BALANCES ARRAY<BALANCE_TYPE>
) WITH (
KAFKA_TOPIC='CUSTOMER_STATS',
PARTITIONS=1,
VALUE_FORMAT='JSON_SR');
@DennisFederico
DennisFederico / env_variables
Created August 4, 2022 14:15
Environment variables needed to sources before firing docker-compose.yml
export BOOTSTRAP_SERVERS=<CONFLUENT_CLOUD_CLUSTER_BOOTSTRAP:9092>
export SASL_JAAS_CONFIG="org.apache.kafka.common.security.plain.PlainLoginModule required username='<API-KEY>' password='<API_SECRET>';"
export SCHEMA_REGISTRY_URL=<CONFLUENT_CLOUD_SCHEMA_REGISTRY_URL:443>
export BASIC_AUTH_CREDENTIALS_SOURCE=USER_INFO
export SCHEMA_REGISTRY_BASIC_AUTH_USER_INFO=<SR_API_KEY>:<SR_API_SECRET>
@DennisFederico
DennisFederico / docker-compose.yml
Created August 4, 2022 13:55
Control Center, Connect and KSQLDB using Kafka and SR in Confluent Cloud
---
version: '2'
services:
connect_1:
image: confluentinc/cp-server-connect:7.2.1
hostname: connect-1
container_name: connect-1
ports:
- "8083:8083"