Skip to content

Instantly share code, notes, and snippets.

View bwplotka's full-sized avatar
💪
Coding.. Building.. Deploying!

Bartlomiej Plotka bwplotka

💪
Coding.. Building.. Deploying!
View GitHub Profile
@bwplotka
bwplotka / backend.proto
Created January 24, 2018 11:23
Kedge's backend proto that specifies "how" to proxy to the backend.
/// Backend data will be used to set up a pool of HTTP connection to the specified endpoint that will be kept open.
message Backend {
/// name is the string identifying the backend in all other configs.
string name = 1;
/// balancer decides which load balancing policy to use.
Balancer balancer = 2;
/// security controls the TLS connection details for the backend (HTTPS). If not present, insecure HTTP mode is used.
Security security = 3;
@bwplotka
bwplotka / ttest.go
Created January 7, 2019 14:38
Table test initial boilerplate
for _, tcase := range []struct{
}{
{
},
}{
if ok := t.Run("", func(t *testing.T) {
}); !ok {
return
package store
import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"
@bwplotka
bwplotka / demo-lib.sh
Last active January 28, 2019 21:25
Shell script helper for interactive demos.
#!/usr/bin/env bash
# Script inspired by https://github.com/paxtonhare/demo-magic
# (https://github.com/paxtonhare/demo-magic/issues/15)
#
# Example usage in script:
# #!/usr/bin/env bash
#
# . demo-lib.sh
#
@bwplotka
bwplotka / keybase.md
Created August 13, 2019 18:59
Keybase.io

Keybase proof

I hereby claim:

  • I am bwplotka on github.
  • I am bwplotka (https://keybase.io/bwplotka) on keybase.
  • I have a public key ASBF3WaAmnBy4NO6giWMh5EvF0VTevLiRedpJYGZzb4fawo

To claim this, I am signing this object:

@bwplotka
bwplotka / defer_benchmark.go
Last active February 20, 2020 11:53
Showcase of Go "1.14beta1" vs "1.13.1" `defer` performance improvement.
package main
import (
"testing"
)
var sink1 = 0
func BenchmarkNotDefered(b *testing.B) {
for n := 0; n < b.N; n++ {
@bwplotka
bwplotka / replayable.go
Last active May 14, 2020 17:17
Go Replayable io.Reader: Useful when you want to share slice of bytes across many io.Reader sequential consumers). E.g the same reqest.Body in HTTP server used by multiple RoundTrippers (!).
package replayable
import (
"bytes"
"io"
)
type Reader struct {
wrapped io.Reader
@bwplotka
bwplotka / bench.sh
Last active November 17, 2020 19:21
Bartek's YOLO Go benchmarking scripts.
#!/usr/bin/env bash
set -e
# Copyright (c) Bartłomiej Płotka @bwplotka
# Licensed under the Apache License 2.0.
# Yolo script allowing nice benchmark framework for iterative work on Go performance.
# Requirements:
# * Prepare worktree if you want to benchmark in background: git worktree add ../thanos_b yolo
@bwplotka
bwplotka / bucket_test.go
Last active December 19, 2020 09:52
Thanos Go Benchmarks Real Block Queries
// Copyright (c) The Thanos Authors.
// Licensed under the Apache License 2.0.
package manual
import (
"context"
"io/ioutil"
"os"
"testing"
@bwplotka
bwplotka / e2e_store_and_querier.test
Created December 8, 2020 16:09
e2e benchmarking Thanos run up.
// Copyright (c) The Thanos Authors.
// Licensed under the Apache License 2.0.
package e2e_test
import (
"context"
"fmt"
"net"
"net/http"