Skip to content

Instantly share code, notes, and snippets.

View ganny26's full-sized avatar

Selvaganesh ganny26

View GitHub Profile
const config = {
name: 'appCounter',
slidingWindowSize: 6, // Failure Rate Calculation is done on the last 6 iterations
minimumNumberOfCalls: 3, // 3 iterations are needed to start calculating the failure rate, and see if circuit should be opened or not
failureRateThreshold: 60, // If half of the iterations or more are failing, the circuit is switched to Opened state.
slowCallDurationThreshold: 500, // An iteration is considered as being slow if the iteration lasts more than 1s
slowCallRateThreshold: 50, // If at least 80% of the iterations are considered as being slow, the circuit is switched to Opened state.
permittedNumberOfCallsInHalfOpenState: 2, // When the circuit is in Half Opened state, the circuit accepts 2 iterations in this state.
openStateDelay: 10000, // The circuit stays in Opened state for 10s
halfOpenStateMaxDelay: 30000,
@ganny26
ganny26 / microservice.js
Created January 16, 2022 14:22
service.js
const { init } = require('./tracer')
const api = require('@opentelemetry/api')
init('demo-node-service', 'development')
const express = require('express')
const axios = require('axios')
const app = express()
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
@ganny26
ganny26 / tracer.js
Last active February 6, 2022 03:20
tracer
'use strict'
const {
BasicTracerProvider,
ConsoleSpanExporter,
SimpleSpanProcessor,
BatchSpanProcessor,
} = require('@opentelemetry/tracing')
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector')
const { Resource } = require('@opentelemetry/resources')
@ganny26
ganny26 / main1.py
Created May 29, 2021 16:05
main.py
from impala.dbapi import connect
import logging
import os
from utils.kerberos import *
import atexit
from scheduler import (
register_kerberos_scheduler,
krb_scheduler,
remove_shutdown_scheduler,
@ganny26
ganny26 / kerberos-scheduler.py
Created May 29, 2021 14:16
kerberos-scheduler
import time
from apscheduler.schedulers.background import BackgroundScheduler
from utils.kerberos import *
import logging
import subprocess
krb_scheduler = BackgroundScheduler()
def register_kerberos_scheduler(kerberos_username, keytab_path):
@ganny26
ganny26 / query.py
Created May 29, 2021 11:49
query.py
query = """select name,address,city where pincode = '{}' and date = '{}'""".format(pincode, date)
logging.info("executing query %s", query)
cursor.execute(query)
results = cursor.fetchall()
response = []
for item in results:
response.append(
{
"name": item[0],
"address": item[1],
@ganny26
ganny26 / kerberos.py
Created May 29, 2021 10:11
kerberos.py
import os
import logging
import datetime
class Kerberos:
def __init__(self, username, keytabpath):
self.username = username
self.keytabpath = keytabpath
@ganny26
ganny26 / example.js
Created March 22, 2021 02:20 — forked from millermedeiros/example.js
execute multiple shell commands in series on node.js
// USAGE ------
// ============
var shell = require('./shellHelper');
// execute a single shell command
shell.exec('npm test --coverage', function(err){
console.log('executed test');
}});
@ganny26
ganny26 / kafka.md
Last active December 8, 2020 09:32
Kafka

run zookeeper

./windows/zookeeper-server-start.bat ../config/zookeeper.properties

run kafka

./kafka-server-start.bat ../../config/server.properties

run confluent kafka rest proxy

sh ./kafka-rest-start ../etc/kafka-rest/kafka-rest.properties

create a topic

@ganny26
ganny26 / Closures.md
Last active December 8, 2020 09:32
Closures.md

To know more bout execution context and lexical environment read here

Used in higher order functions read here

Closure

Example 1