Skip to content

Instantly share code, notes, and snippets.

View liemle3893's full-sized avatar

Liem Le Hoang Duc liemle3893

View GitHub Profile
@liemle3893
liemle3893 / avoid-distributed-transactions.md
Created December 3, 2022 09:28 — forked from rponte/avoid-distributed-transactions.md
THEORY: Distributed Transactions and why you should avoid them (2 Phase Commit , Saga Pattern, TCC, Idempotency etc)

Distributed Transactions and why you should avoid them

  1. Modern technologies won't support it (RabbitMQ, Kafka, etc.);
  2. This is a form of using Inter-Process Communication in a synchronized way and this reduces availability;
  3. All participants of the distributed transaction need to be avaiable for a distributed commit, again: reduces availability.

Implementing business transactions that span multiple services is not straightforward. Distributed transactions are best avoided because of the CAP theorem. Moreover, many modern (NoSQL) databases don’t support them. The best solution is to use the Saga Pattern.

[...]

@liemle3893
liemle3893 / private_fork.md
Created September 5, 2021 08:06 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@liemle3893
liemle3893 / COMMANDS.MD
Last active July 21, 2021 11:34
Ory hydra common client's commands

Hydra

Version: v1.10.2

Create

hydra clients create   \
 --endpoint http://127.0.0.1:4445     \
 --id 111111    \
 --secret 123456    \

HOWTO: Clean Up Nomad Data Directory

Issue

When attempting to remove all of the data in the Nomad data directory, several directories and files are unable to be deleted. Many messages are logged to the console like:

rm: cannot remove ‘alloc/736f61b9-d7dc-cb73-0dd1-76b1b2ba032d/nomad-ui/secrets’: Device or resource busy
rm: cannot remove ‘alloc/ddcf5a78-5497-f4a4-a101-221fc4e0180b/fabio/alloc’: Device or resource busy
rm: cannot remove ‘alloc/ddcf5a78-5497-f4a4-a101-221fc4e0180b/fabio/secrets’: Device or resource busy
[SERVICE]
Flush 1
Log_Level info
Parsers_File parsers.conf
[INPUT]
Name tail
# Log file will be placed at: /tmp/fluent-bit/logs/<app_name>/<file_name>.log
Path /tmp/fluent-bit/logs/*/*.log
Path_Key LogSource
job "minio" {
datacenters = ["dc1"]
type = "service"
group "minio1" {
ephemeral_disk {
size = 10000
sticky = true
migrate = false
}
scrape_configs:
- job_name: 'consul_sd'
consul_sd_configs:
- server: '{{ env "NOMAD_IP_http"}}:8500'
services: []
relabel_configs:
- source_labels: [__meta_consul_service_metadata_prometheus_enable]
regex: true
action: keep
- source_labels: [__meta_consul_service_metadata_prometheus_path]
@liemle3893
liemle3893 / .gitlab-ci.yml
Created April 1, 2020 12:27
Gitlab CI with Nomad
# Disable the Gradle daemon for Continuous Integration servers as correctness
# is usually a priority over speed in CI environments. Using a fresh
# runtime for each build is more reliable since the runtime is completely
# isolated from any previous builds.
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
DOCKER_TLS_CERTDIR: ""
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
service {
name = "go-demo"
port = "http"
address_mode = "driver"
tags = [
"traefik.enable=true",
"traefik.http.middlewares.strip-go-demo.stripprefix.prefixes=/go-demo",
"traefik.http.routers.go-demo.entrypoints=http",
"traefik.http.routers.go-demo.rule=PathPrefix(`/go-demo`)",
"traefik.http.routers.go-demo.middlewares=strip-go-demo"
task "demo_api" {
driver = "docker"
config {
image = "saboteurkid/go-demo:latest-debug"
}
}