Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Reasno's full-sized avatar

谷溪 Reasno

View GitHub Profile
@Reasno
Reasno / locks.go
Created February 17, 2022 05:55
Renewable distributed lock implementation with Redis (untested)
package core_locks
import (
"container/heap"
"context"
"errors"
"fmt"
"time"
"github.com/go-redis/redis/v8"

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
@Reasno
Reasno / kratosify.go
Last active March 11, 2021 08:54
Converts a Go-Kit middleware to Kratos middleware
package util
import (
"github.com/go-kit/kit/endpoint"
"github.com/go-kratos/kratos/v2/middleware"
)
// Kratosify Converts a Go-Kit middleware to Kratos middleware
func Kratosify(kitmw endpoint.Middleware) middleware.Middleware {
return func(handler middleware.Handler) middleware.Handler {
@Reasno
Reasno / commitlint.sh
Created July 17, 2020 04:38
lint commit using bash. Modified from https://github.com/craicoverflow/sailr
#!/bin/sh
# set values from config file to variables
function set_config_values() {
revert=false
types=(build ci docs feat fix perf refactor style chore test)
min_length=5
max_length=52
}
@Reasno
Reasno / set-cookie.php
Created April 24, 2020 09:07
神奇的set-cookie
helm list --short | grep prefix | xargs -L1 helm delete --purge
@Reasno
Reasno / downgradeRetryPolicy.js
Created August 13, 2019 02:26 — forked from harigist/downgradeRetryPolicy.js
Downgrade Retry policies in Cassandra using nodejs
/**
* DowngradeRetryPolicy - This module is used to retry the READ / WRITE operation
* by downgrading the value of consistency to minimum value.
* @constructor
*/
function DowngradeRetryPolicy() {
}
// Inherit the retry policy
util.inherits(DowngradeRetryPolicy, RetryPolicy);
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
KUBE_VERSION=v1.10.0
KUBE_PAUSE_VERSION=3.0
ETCD_VERSION=3.2.13
DNS_VERSION=1.14.8
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
KUBE_VERSION=v1.10.0
KUBE_PAUSE_VERSION=3.0
ETCD_VERSION=3.2.13
DNS_VERSION=1.14.8
@Reasno
Reasno / ComposeMinxins.php
Created January 18, 2018 09:15
ComposeMinxins for functional programing.
function composeMixins(callable ...$mixins)
{
return function(
$x = [],
callable $mix = null
) use ($mixins){
$mix = $mix ?? function(callable ...$fns) use ($x){
return array_reduce($fns, function($acc, $fn){
return call_user_func($fn, $acc);
}, $x);