repo stringlengths 6 47 | file_url stringlengths 77 269 | file_path stringlengths 5 186 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-07 08:35:43 2026-01-07 08:55:24 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/influx/influx_test.go | metrics/influx/influx_test.go | package influx
import (
"bytes"
"fmt"
"regexp"
"strconv"
"strings"
"testing"
influxdb "github.com/influxdata/influxdb1-client/v2"
"github.com/go-kit/kit/metrics/teststat"
"github.com/go-kit/log"
)
func TestCounter(t *testing.T) {
in := New(map[string]string{"a": "b"}, influxdb.BatchPointsConfig{}, log.New... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/influx/example_test.go | metrics/influx/example_test.go | package influx
import (
"fmt"
"regexp"
influxdb "github.com/influxdata/influxdb1-client/v2"
"github.com/go-kit/log"
)
func ExampleCounter() {
in := New(map[string]string{"a": "b"}, influxdb.BatchPointsConfig{}, log.NewNopLogger())
counter := in.NewCounter("influx_counter")
counter.Add(10)
counter.With("erro... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/expvar/expvar_test.go | metrics/expvar/expvar_test.go | package expvar
import (
"strconv"
"testing"
"github.com/go-kit/kit/metrics/teststat"
)
func TestCounter(t *testing.T) {
counter := NewCounter("expvar_counter").With("label values", "not supported").(*Counter)
value := func() float64 { f, _ := strconv.ParseFloat(counter.f.String(), 64); return f }
if err := tes... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/expvar/expvar.go | metrics/expvar/expvar.go | // Package expvar provides expvar backends for metrics.
// Label values are not supported.
package expvar
import (
"expvar"
"sync"
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/generic"
)
// Counter implements the counter metric with an expvar float.
// Label values are not supported.
type Count... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/cloudwatch/cloudwatch_test.go | metrics/cloudwatch/cloudwatch_test.go | package cloudwatch
import (
"errors"
"fmt"
"strconv"
"sync"
"testing"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/cloudwatch/cloudwatchiface"
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/teststat"
"github.com/go-kit/log"
)
const metricNameToGenerateE... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/cloudwatch/cloudwatch.go | metrics/cloudwatch/cloudwatch.go | package cloudwatch
import (
"context"
"fmt"
"os"
"strconv"
"sync"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/cloudwatch/cloudwatchiface"
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/generic"
"github.com/go-kit... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/discard/discard.go | metrics/discard/discard.go | // Package discard provides a no-op metrics backend.
package discard
import "github.com/go-kit/kit/metrics"
type counter struct{}
// NewCounter returns a new no-op counter.
func NewCounter() metrics.Counter { return counter{} }
// With implements Counter.
func (c counter) With(labelValues ...string) metrics.Counter... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/generic/generic.go | metrics/generic/generic.go | // Package generic implements generic versions of each of the metric types. They
// can be embedded by other implementations, and converted to specific formats
// as necessary.
package generic
import (
"fmt"
"io"
"math"
"sync"
"sync/atomic"
"github.com/VividCortex/gohistogram"
"github.com/go-kit/kit/metrics"
... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/generic/generic_test.go | metrics/generic/generic_test.go | package generic_test
// This is package generic_test in order to get around an import cycle: this
// package imports teststat to do its testing, but package teststat imports
// generic to use its Histogram in the Quantiles helper function.
import (
"go/ast"
"go/importer"
"go/parser"
"go/token"
"go/types"
"io/io... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/teststat/buffers.go | metrics/teststat/buffers.go | package teststat
import (
"bufio"
"bytes"
"io"
"regexp"
"strconv"
"github.com/go-kit/kit/metrics/generic"
)
// SumLines expects a regex whose first capture group can be parsed as a
// float64. It will dump the WriterTo and parse each line, expecting to find a
// match. It returns the sum of all captured floats... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/teststat/populate.go | metrics/teststat/populate.go | package teststat
import (
"math"
"math/rand"
"github.com/go-kit/kit/metrics"
)
// PopulateNormalHistogram makes a series of normal random observations into the
// histogram. The number of observations is determined by Count. The randomness
// is determined by Mean, Stdev, and the seed parameter.
//
// This is a l... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/teststat/teststat.go | metrics/teststat/teststat.go | // Package teststat provides helpers for testing metrics backends.
package teststat
import (
"errors"
"fmt"
"math"
"math/rand"
"reflect"
"sort"
"strings"
"github.com/go-kit/kit/metrics"
)
// TestCounter puts some deltas through the counter, and then calls the value
// func to check that the counter has the c... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/multi/multi_test.go | metrics/multi/multi_test.go | package multi
import (
"fmt"
"testing"
"github.com/go-kit/kit/metrics"
)
func TestMultiCounter(t *testing.T) {
c1 := &mockCounter{}
c2 := &mockCounter{}
c3 := &mockCounter{}
mc := NewCounter(c1, c2, c3)
mc.Add(123)
mc.Add(456)
want := "[123 456]"
for i, m := range []fmt.Stringer{c1, c2, c3} {
if have ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/multi/multi.go | metrics/multi/multi.go | // Package multi provides adapters that send observations to multiple metrics
// simultaneously. This is useful if your service needs to emit to multiple
// instrumentation systems at the same time, for example if your organization is
// transitioning from one system to another.
package multi
import "github.com/go-kit... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/dogstatsd/dogstatsd_test.go | metrics/dogstatsd/dogstatsd_test.go | package dogstatsd
import (
"testing"
"github.com/go-kit/kit/metrics/teststat"
"github.com/go-kit/log"
)
func TestCounter(t *testing.T) {
prefix, name := "abc.", "def"
label, value := "label", "value"
regex := `^` + prefix + name + `:([0-9\.]+)\|c\|#` + label + `:` + value + `$`
d := New(prefix, log.NewNopLogg... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/dogstatsd/dogstatsd.go | metrics/dogstatsd/dogstatsd.go | // Package dogstatsd provides a DogStatsD backend for package metrics. It's very
// similar to StatsD, but supports arbitrary tags per-metric, which map to Go
// kit's label values. So, while label values are no-ops in StatsD, they are
// supported here. For more details, see the documentation at
// http://docs.datadog... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/pcp/pcp_test.go | metrics/pcp/pcp_test.go | package pcp
import (
"testing"
"github.com/performancecopilot/speed/v4"
"github.com/go-kit/kit/metrics/teststat"
)
func TestCounter(t *testing.T) {
r, err := NewReporter("test_counter")
if err != nil {
t.Fatal(err)
}
counter, err := r.NewCounter("speed_counter")
if err != nil {
t.Fatal(err)
}
counte... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/pcp/pcp.go | metrics/pcp/pcp.go | package pcp
import (
"github.com/performancecopilot/speed/v4"
"github.com/go-kit/kit/metrics"
)
// Reporter encapsulates a speed client.
type Reporter struct {
c *speed.PCPClient
}
// NewReporter creates a new Reporter instance. The first parameter is the
// application name and is used to create the speed clien... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/graphite/graphite_test.go | metrics/graphite/graphite_test.go | package graphite
import (
"bytes"
"regexp"
"strconv"
"testing"
"github.com/go-kit/kit/metrics/teststat"
"github.com/go-kit/log"
)
func TestCounter(t *testing.T) {
prefix, name := "abc.", "def"
label, value := "label", "value" // ignored for Graphite
regex := `^` + prefix + name + ` ([0-9\.]+) [0-9]+$`
g :=... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/graphite/graphite.go | metrics/graphite/graphite.go | // Package graphite provides a Graphite backend for metrics. Metrics are batched
// and emitted in the plaintext protocol. For more information, see
// http://graphite.readthedocs.io/en/latest/feeding-carbon.html#the-plaintext-protocol
//
// Graphite does not have a native understanding of metric parameterization, so
/... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/internal/ratemap/ratemap.go | metrics/internal/ratemap/ratemap.go | // Package ratemap implements a goroutine-safe map of string to float64. It can
// be embedded in implementations whose metrics support fixed sample rates, so
// that an additional parameter doesn't have to be tracked through the e.g.
// lv.Space object.
package ratemap
import "sync"
// RateMap is a simple goroutine-... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/internal/convert/convert_test.go | metrics/internal/convert/convert_test.go | package convert
import (
"testing"
"github.com/go-kit/kit/metrics/generic"
"github.com/go-kit/kit/metrics/teststat"
)
func TestCounterHistogramConversion(t *testing.T) {
name := "my_counter"
c := generic.NewCounter(name)
h := NewCounterAsHistogram(c)
top := NewHistogramAsCounter(h).With("label", "counter").(h... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/internal/convert/convert.go | metrics/internal/convert/convert.go | // Package convert provides a way to use Counters, Histograms, or Gauges
// as one of the other types
package convert
import "github.com/go-kit/kit/metrics"
type counterHistogram struct {
c metrics.Counter
}
// NewCounterAsHistogram returns a Histogram that actually writes the
// value on an underlying Counter
func... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/internal/lv/space_test.go | metrics/internal/lv/space_test.go | package lv
import (
"strings"
"testing"
)
func TestSpaceWalkAbort(t *testing.T) {
s := NewSpace()
s.Observe("a", LabelValues{"a", "b"}, 1)
s.Observe("a", LabelValues{"c", "d"}, 2)
s.Observe("a", LabelValues{"e", "f"}, 4)
s.Observe("a", LabelValues{"g", "h"}, 8)
s.Observe("b", LabelValues{"a", "b"}, 16)
s.Obs... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/internal/lv/labelvalues_test.go | metrics/internal/lv/labelvalues_test.go | package lv
import (
"strings"
"testing"
)
func TestWith(t *testing.T) {
var a LabelValues
b := a.With("a", "1")
c := a.With("b", "2", "c", "3")
if want, have := "", strings.Join(a, ""); want != have {
t.Errorf("With appears to mutate the original LabelValues: want %q, have %q", want, have)
}
if want, have ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/internal/lv/space.go | metrics/internal/lv/space.go | package lv
import "sync"
// NewSpace returns an N-dimensional vector space.
func NewSpace() *Space {
return &Space{}
}
// Space represents an N-dimensional vector space. Each name and unique label
// value pair establishes a new dimension and point within that dimension. Order
// matters, i.e. [a=1 b=2] identifies ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/internal/lv/labelvalues.go | metrics/internal/lv/labelvalues.go | package lv
// LabelValues is a type alias that provides validation on its With method.
// Metrics may include it as a member to help them satisfy With semantics and
// save some code duplication.
type LabelValues []string
// With validates the input, and returns a new aggregate labelValues.
func (lvs LabelValues) Wit... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/provider/expvar.go | metrics/provider/expvar.go | package provider
import (
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/expvar"
)
type expvarProvider struct{}
// NewExpvarProvider returns a Provider that produces expvar metrics.
func NewExpvarProvider() Provider {
return expvarProvider{}
}
// NewCounter implements Provider.
func (p expvarProv... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/provider/statsd.go | metrics/provider/statsd.go | package provider
import (
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/statsd"
)
type statsdProvider struct {
s *statsd.Statsd
stop func()
}
// NewStatsdProvider wraps the given Statsd object and stop func and returns a
// Provider that produces Statsd metrics. A typical stop function would ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/provider/prometheus.go | metrics/provider/prometheus.go | package provider
import (
stdprometheus "github.com/prometheus/client_golang/prometheus"
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/prometheus"
)
type prometheusProvider struct {
namespace string
subsystem string
}
// NewPrometheusProvider returns a Provider that produces Prometheus metrics... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/provider/influx.go | metrics/provider/influx.go | package provider
import (
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/influx"
)
type influxProvider struct {
in *influx.Influx
stop func()
}
// NewInfluxProvider takes the given Influx object and stop func, and returns
// a Provider that produces Influx metrics.
func NewInfluxProvider(in *in... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/provider/discard.go | metrics/provider/discard.go | package provider
import (
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/discard"
)
type discardProvider struct{}
// NewDiscardProvider returns a provider that produces no-op metrics via the
// discarding backend.
func NewDiscardProvider() Provider { return discardProvider{} }
// NewCounter implem... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/provider/dogstatsd.go | metrics/provider/dogstatsd.go | package provider
import (
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/dogstatsd"
)
type dogstatsdProvider struct {
d *dogstatsd.Dogstatsd
stop func()
}
// NewDogstatsdProvider wraps the given Dogstatsd object and stop func and
// returns a Provider that produces Dogstatsd metrics. A typical... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/provider/graphite.go | metrics/provider/graphite.go | package provider
import (
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/graphite"
)
type graphiteProvider struct {
g *graphite.Graphite
stop func()
}
// NewGraphiteProvider wraps the given Graphite object and stop func and returns
// a Provider that produces Graphite metrics. A typical stop f... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/provider/provider.go | metrics/provider/provider.go | // Package provider provides a factory-like abstraction for metrics backends.
// This package is provided specifically for the needs of the NY Times framework
// Gizmo. Most normal Go kit users shouldn't need to use it.
//
// Normally, if your microservice needs to support different metrics backends,
// you can simply ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/influxstatsd/influxstatsd_test.go | metrics/influxstatsd/influxstatsd_test.go | package influxstatsd
import (
"testing"
"github.com/go-kit/kit/metrics/teststat"
"github.com/go-kit/log"
)
func TestCounter(t *testing.T) {
prefix, name := "abc.", "def"
label, value := "label", "value"
regex := `^` + prefix + name + "," + label + `=` + value + `:([0-9\.]+)\|c$`
d := New(prefix, log.NewNopLog... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/influxstatsd/influxstatsd.go | metrics/influxstatsd/influxstatsd.go | // Package influxstatsd provides support for InfluxData's StatsD Telegraf plugin. It's very
// similar to StatsD, but supports arbitrary tags per-metric, which map to Go
// kit's label values. So, while label values are no-ops in StatsD, they are
// supported here. For more details, see the article at
// https://www.in... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/prometheus/prometheus.go | metrics/prometheus/prometheus.go | // Package prometheus provides Prometheus implementations for metrics.
// Individual metrics are mapped to their Prometheus counterparts, and
// (depending on the constructor used) may be automatically registered in the
// global Prometheus metrics registry.
package prometheus
import (
"github.com/prometheus/client_g... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/prometheus/prometheus_test.go | metrics/prometheus/prometheus_test.go | package prometheus
import (
"io/ioutil"
"math"
"math/rand"
"net/http"
"net/http/httptest"
"reflect"
"regexp"
"strconv"
"strings"
"testing"
"github.com/go-kit/kit/metrics/teststat"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
f... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/statsd/statsd.go | metrics/statsd/statsd.go | // Package statsd provides a StatsD backend for package metrics. StatsD has no
// concept of arbitrary key-value tagging, so label values are not supported,
// and With is a no-op on all metrics.
//
// This package batches observations and emits them on some schedule to the
// remote server. This is useful even if you ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/metrics/statsd/statsd_test.go | metrics/statsd/statsd_test.go | package statsd
import (
"testing"
"github.com/go-kit/kit/metrics/teststat"
"github.com/go-kit/log"
)
func TestCounter(t *testing.T) {
prefix, name := "abc.", "def"
label, value := "label", "value" // ignored
regex := `^` + prefix + name + `:([0-9\.]+)\|c$`
s := New(prefix, log.NewNopLogger())
counter := s.Ne... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/circuitbreaker/handy_breaker_test.go | circuitbreaker/handy_breaker_test.go | package circuitbreaker_test
import (
"testing"
handybreaker "github.com/streadway/handy/breaker"
"github.com/go-kit/kit/circuitbreaker"
)
func TestHandyBreaker(t *testing.T) {
var (
failureRatio = 0.05
breaker = circuitbreaker.HandyBreaker(handybreaker.NewBreaker(failureRatio))
primeWith ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/circuitbreaker/gobreaker_test.go | circuitbreaker/gobreaker_test.go | package circuitbreaker_test
import (
"testing"
"github.com/sony/gobreaker"
"github.com/go-kit/kit/circuitbreaker"
)
func TestGobreaker(t *testing.T) {
var (
breaker = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{}))
primeWith = 100
shouldPass = func(n int) ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/circuitbreaker/hystrix.go | circuitbreaker/hystrix.go | package circuitbreaker
import (
"context"
"github.com/afex/hystrix-go/hystrix"
"github.com/go-kit/kit/endpoint"
)
// Hystrix returns an endpoint.Middleware that implements the circuit
// breaker pattern using the afex/hystrix-go package.
//
// When using this circuit breaker, please configure your commands separ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/circuitbreaker/hystrix_test.go | circuitbreaker/hystrix_test.go | package circuitbreaker_test
import (
"io/ioutil"
stdlog "log"
"testing"
"time"
"github.com/afex/hystrix-go/hystrix"
"github.com/go-kit/kit/circuitbreaker"
)
func TestHystrix(t *testing.T) {
stdlog.SetOutput(ioutil.Discard)
const (
commandName = "my-endpoint"
errorPercent = 5
maxConcurrent = 1000
... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/circuitbreaker/gobreaker.go | circuitbreaker/gobreaker.go | package circuitbreaker
import (
"context"
"github.com/sony/gobreaker"
"github.com/go-kit/kit/endpoint"
)
// Gobreaker returns an endpoint.Middleware that implements the circuit
// breaker pattern using the sony/gobreaker package. Only errors returned by
// the wrapped endpoint count against the circuit breaker's... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/circuitbreaker/doc.go | circuitbreaker/doc.go | // Package circuitbreaker implements the circuit breaker pattern.
//
// Circuit breakers prevent thundering herds, and improve resiliency against
// intermittent errors. Every client-side endpoint should be wrapped in a
// circuit breaker.
//
// We provide several implementations in this package, but if you're looking
... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/circuitbreaker/handy_breaker.go | circuitbreaker/handy_breaker.go | package circuitbreaker
import (
"context"
"time"
"github.com/streadway/handy/breaker"
"github.com/go-kit/kit/endpoint"
)
// HandyBreaker returns an endpoint.Middleware that implements the circuit
// breaker pattern using the streadway/handy/breaker package. Only errors
// returned by the wrapped endpoint count ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/circuitbreaker/util_test.go | circuitbreaker/util_test.go | package circuitbreaker_test
import (
"context"
"errors"
"fmt"
"path/filepath"
"runtime"
"testing"
"time"
"github.com/go-kit/kit/endpoint"
)
func testFailingEndpoint(
t *testing.T,
breaker endpoint.Middleware,
primeWith int,
shouldPass func(int) bool,
requestDelay time.Duration,
openCircuitError string,... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/error_handler.go | transport/error_handler.go | package transport
import (
"context"
"github.com/go-kit/log"
)
// ErrorHandler receives a transport error to be processed for diagnostic purposes.
// Usually this means logging the error.
type ErrorHandler interface {
Handle(ctx context.Context, err error)
}
// LogErrorHandler is a transport error handler implem... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/doc.go | transport/doc.go | // Package transport contains helpers applicable to all supported transports.
package transport
| go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/error_handler_test.go | transport/error_handler_test.go | package transport_test
import (
"context"
"errors"
"testing"
"github.com/go-kit/kit/transport"
"github.com/go-kit/log"
)
func TestLogErrorHandler(t *testing.T) {
var output []interface{}
logger := log.Logger(log.LoggerFunc(func(keyvals ...interface{}) error {
output = append(output, keyvals...)
return ni... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/httprp/server_test.go | transport/httprp/server_test.go | package httprp_test
import (
"context"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"testing"
httptransport "github.com/go-kit/kit/transport/httprp"
)
func TestServerHappyPathSingleServer(t *testing.T) {
originServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/httprp/server.go | transport/httprp/server.go | package httprp
import (
"context"
"net/http"
"net/http/httputil"
"net/url"
)
// RequestFunc may take information from an HTTP request and put it into a
// request context. BeforeFuncs are executed prior to invoking the
// endpoint.
type RequestFunc func(context.Context, *http.Request) context.Context
// Server i... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/httprp/doc.go | transport/httprp/doc.go | // Package httprp provides an HTTP reverse-proxy transport. HTTP handlers that
// need to proxy requests to another HTTP service can do so with this package by
// specifying the URL to forward the request to.
package httprp
| go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/amqp/publisher_test.go | transport/amqp/publisher_test.go | package amqp_test
import (
"context"
"encoding/json"
"errors"
"testing"
"time"
amqptransport "github.com/go-kit/kit/transport/amqp"
amqp "github.com/rabbitmq/amqp091-go"
)
var (
defaultContentType = ""
defaultContentEncoding = ""
)
// TestBadEncode tests if encode errors are handled properly.
func Test... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/amqp/request_response_func.go | transport/amqp/request_response_func.go | package amqp
import (
"context"
"time"
amqp "github.com/rabbitmq/amqp091-go"
)
// RequestFunc may take information from a publisher request and put it into a
// request context. In Subscribers, RequestFuncs are executed prior to invoking
// the endpoint.
type RequestFunc func(context.Context, *amqp.Publishing, *a... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/amqp/util.go | transport/amqp/util.go | package amqp
import (
"math/rand"
)
func randomString(l int) string {
bytes := make([]byte, l)
for i := 0; i < l; i++ {
bytes[i] = byte(randInt(65, 90))
}
return string(bytes)
}
func randInt(min int, max int) int {
return min + rand.Intn(max-min)
}
| go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/amqp/subscriber.go | transport/amqp/subscriber.go | package amqp
import (
"context"
"encoding/json"
"time"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/transport"
"github.com/go-kit/log"
amqp "github.com/rabbitmq/amqp091-go"
)
// Subscriber wraps an endpoint and provides a handler for AMQP Delivery messages.
type Subscriber struct {
e ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/amqp/publisher.go | transport/amqp/publisher.go | package amqp
import (
"context"
"time"
"github.com/go-kit/kit/endpoint"
amqp "github.com/rabbitmq/amqp091-go"
)
// The golang AMQP implementation requires the []byte representation of
// correlation id strings to have a maximum length of 255 bytes.
const maxCorrelationIdLength = 255
// Publisher wraps an AMQP c... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/amqp/encode_decode.go | transport/amqp/encode_decode.go | package amqp
import (
"context"
amqp "github.com/rabbitmq/amqp091-go"
)
// DecodeRequestFunc extracts a user-domain request object from
// an AMQP Delivery object. It is designed to be used in AMQP Subscribers.
type DecodeRequestFunc func(context.Context, *amqp.Delivery) (request interface{}, err error)
// Encode... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/amqp/doc.go | transport/amqp/doc.go | // Package amqp implements an AMQP transport.
package amqp
| go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/amqp/subscriber_test.go | transport/amqp/subscriber_test.go | package amqp_test
import (
"context"
"encoding/json"
"errors"
"testing"
"time"
amqptransport "github.com/go-kit/kit/transport/amqp"
amqp "github.com/rabbitmq/amqp091-go"
)
var (
errTypeAssertion = errors.New("type assertion error")
)
// mockChannel is a mock of *amqp.Channel.
type mockChannel struct {
f ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/nats/publisher_test.go | transport/nats/publisher_test.go | package nats_test
import (
"context"
"strings"
"testing"
"time"
natstransport "github.com/go-kit/kit/transport/nats"
"github.com/nats-io/nats.go"
)
func TestPublisher(t *testing.T) {
var (
testdata = "testdata"
encode = func(context.Context, *nats.Msg, interface{}) error { return nil }
decode = func... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/nats/subscriber.go | transport/nats/subscriber.go | package nats
import (
"context"
"encoding/json"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/transport"
"github.com/go-kit/log"
"github.com/nats-io/nats.go"
)
// Subscriber wraps an endpoint and provides nats.MsgHandler.
type Subscriber struct {
e endpoint.Endpoint
dec DecodeR... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/nats/request_response_funcs.go | transport/nats/request_response_funcs.go | package nats
import (
"context"
"github.com/nats-io/nats.go"
)
// RequestFunc may take information from a publisher request and put it into a
// request context. In Subscribers, RequestFuncs are executed prior to invoking the
// endpoint.
type RequestFunc func(context.Context, *nats.Msg) context.Context
// Subscr... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/nats/publisher.go | transport/nats/publisher.go | package nats
import (
"context"
"encoding/json"
"github.com/go-kit/kit/endpoint"
"github.com/nats-io/nats.go"
"time"
)
// Publisher wraps a URL and provides a method that implements endpoint.Endpoint.
type Publisher struct {
publisher *nats.Conn
subject string
enc EncodeRequestFunc
dec DecodeRe... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/nats/encode_decode.go | transport/nats/encode_decode.go | package nats
import (
"context"
"github.com/nats-io/nats.go"
)
// DecodeRequestFunc extracts a user-domain request object from a publisher
// request object. It's designed to be used in NATS subscribers, for subscriber-side
// endpoints. One straightforward DecodeRequestFunc could be something that
// JSON decodes... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/nats/doc.go | transport/nats/doc.go | // Package nats provides a NATS transport.
package nats
| go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/nats/subscriber_test.go | transport/nats/subscriber_test.go | package nats_test
import (
"context"
"encoding/json"
"errors"
"strings"
"sync"
"testing"
"time"
"github.com/nats-io/nats-server/v2/server"
"github.com/nats-io/nats.go"
"github.com/go-kit/kit/endpoint"
natstransport "github.com/go-kit/kit/transport/nats"
)
type TestResponse struct {
String string `json:"... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/awslambda/handler_test.go | transport/awslambda/handler_test.go | package awslambda
import (
"context"
"encoding/json"
"fmt"
"testing"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/transport"
"github.com/go-kit/log"
)
type key int
const (
KeyBeforeOne key = iota
KeyBeforeTwo key = iota
KeyAfterOne key = iota
KeyEncMode key = iota
)
// Created based on git... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/awslambda/request_response_funcs.go | transport/awslambda/request_response_funcs.go | package awslambda
import (
"context"
)
// HandlerRequestFunc may take information from the received
// payload and use it to place items in the request scoped context.
// HandlerRequestFuncs are executed prior to invoking the endpoint and
// decoding of the payload.
type HandlerRequestFunc func(ctx context.Context, ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/awslambda/encode_decode.go | transport/awslambda/encode_decode.go | package awslambda
import (
"context"
)
// DecodeRequestFunc extracts a user-domain request object from an
// AWS Lambda payload.
type DecodeRequestFunc func(context.Context, []byte) (interface{}, error)
// EncodeResponseFunc encodes the passed response object into []byte,
// ready to be sent as AWS Lambda response.... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/awslambda/handler.go | transport/awslambda/handler.go | package awslambda
import (
"context"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/transport"
"github.com/go-kit/log"
)
// Handler wraps an endpoint.
type Handler struct {
e endpoint.Endpoint
dec DecodeRequestFunc
enc EncodeResponseFunc
before []HandlerRequestFunc... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/awslambda/doc.go | transport/awslambda/doc.go | // Package awslambda provides an AWS Lambda transport layer.
package awslambda
| go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/client.go | transport/grpc/client.go | package grpc
import (
"context"
"fmt"
"reflect"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"github.com/go-kit/kit/endpoint"
)
// Client wraps a gRPC connection and provides a method that implements
// endpoint.Endpoint.
type Client struct {
client *grpc.ClientConn
serviceName string
me... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/client_test.go | transport/grpc/client_test.go | package grpc_test
import (
"context"
"fmt"
"net"
"testing"
"google.golang.org/grpc"
test "github.com/go-kit/kit/transport/grpc/_grpc_test"
"github.com/go-kit/kit/transport/grpc/_grpc_test/pb"
)
const (
hostPort string = "localhost:8002"
)
func TestGRPCClient(t *testing.T) {
var (
server = grpc.NewServe... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/request_response_funcs.go | transport/grpc/request_response_funcs.go | package grpc
import (
"context"
"encoding/base64"
"strings"
"google.golang.org/grpc/metadata"
)
const (
binHdrSuffix = "-bin"
)
// ClientRequestFunc may take information from context and use it to construct
// metadata headers to be transported to the server. ClientRequestFuncs are
// executed after creating t... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/encode_decode.go | transport/grpc/encode_decode.go | package grpc
import (
"context"
)
// DecodeRequestFunc extracts a user-domain request object from a gRPC request.
// It's designed to be used in gRPC servers, for server-side endpoints. One
// straightforward DecodeRequestFunc could be something that decodes from the
// gRPC request message to the concrete request t... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/server.go | transport/grpc/server.go | package grpc
import (
"context"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/transport"
"github.com/go-kit/log"
)
// Handler which should be called from the gRPC binding of the service
// implementation. The incoming request parameter, and ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/doc.go | transport/grpc/doc.go | // Package grpc provides a gRPC binding for endpoints.
package grpc
| go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/_grpc_test/client.go | transport/grpc/_grpc_test/client.go | package test
import (
"context"
"google.golang.org/grpc"
"github.com/go-kit/kit/endpoint"
grpctransport "github.com/go-kit/kit/transport/grpc"
"github.com/go-kit/kit/transport/grpc/_grpc_test/pb"
)
type clientBinding struct {
test endpoint.Endpoint
}
func (c *clientBinding) Test(ctx context.Context, a string... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/_grpc_test/request_response.go | transport/grpc/_grpc_test/request_response.go | package test
import (
"context"
"github.com/go-kit/kit/transport/grpc/_grpc_test/pb"
)
func encodeRequest(ctx context.Context, req interface{}) (interface{}, error) {
r := req.(TestRequest)
return &pb.TestRequest{A: r.A, B: r.B}, nil
}
func decodeRequest(ctx context.Context, req interface{}) (interface{}, error... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/_grpc_test/service.go | transport/grpc/_grpc_test/service.go | package test
import "context"
type Service interface {
Test(ctx context.Context, a string, b int64) (context.Context, string, error)
}
type TestRequest struct {
A string
B int64
}
type TestResponse struct {
Ctx context.Context
V string
}
| go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/_grpc_test/server.go | transport/grpc/_grpc_test/server.go | package test
import (
"context"
"fmt"
"github.com/go-kit/kit/endpoint"
grpctransport "github.com/go-kit/kit/transport/grpc"
"github.com/go-kit/kit/transport/grpc/_grpc_test/pb"
)
type service struct{}
func (service) Test(ctx context.Context, a string, b int64) (context.Context, string, error) {
return nil, fm... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/_grpc_test/context_metadata.go | transport/grpc/_grpc_test/context_metadata.go | package test
import (
"context"
"fmt"
"google.golang.org/grpc/metadata"
)
type metaContext string
const (
correlationID metaContext = "correlation-id"
responseHDR metaContext = "my-response-header"
responseTRLR metaContext = "my-response-trailer"
correlationIDTRLR metaContext = "correlation-id... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/_grpc_test/pb/test.pb.go | transport/grpc/_grpc_test/pb/test.pb.go | // Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v3.16.0
// source: test.proto
package pb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/_grpc_test/pb/test_grpc.pb.go | transport/grpc/_grpc_test/pb/test_grpc.pb.go | // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/grpc/_grpc_test/pb/generate.go | transport/grpc/_grpc_test/pb/generate.go | package pb
//go:generate protoc test.proto --go_out=. --go-grpc_out=. --go_opt=Mtest.proto=github.com/go-kit/kit/transport/grpc/_grpc_test/pb --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go-grpc_opt=Mtest.proto=github.com/go-kit/kit/transport/grpc/_grpc_test/pb
| go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/client.go | transport/http/client.go | package http
import (
"bytes"
"context"
"encoding/json"
"encoding/xml"
"io"
"io/ioutil"
"net/http"
"net/url"
"github.com/go-kit/kit/endpoint"
)
// HTTPClient is an interface that models *http.Client.
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}
// Client wraps a URL and prov... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/request_response_funcs_test.go | transport/http/request_response_funcs_test.go | package http_test
import (
"context"
"net/http/httptest"
"testing"
httptransport "github.com/go-kit/kit/transport/http"
)
func TestSetHeader(t *testing.T) {
const (
key = "X-Foo"
val = "12345"
)
r := httptest.NewRecorder()
httptransport.SetResponseHeader(key, val)(context.Background(), r)
if want, have ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/server_test.go | transport/http/server_test.go | package http_test
import (
"context"
"errors"
"io/ioutil"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
"github.com/go-kit/kit/endpoint"
httptransport "github.com/go-kit/kit/transport/http"
)
func TestServerBadDecode(t *testing.T) {
handler := httptransport.NewServer(
func(context.Context, i... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/client_test.go | transport/http/client_test.go | package http_test
import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"time"
httptransport "github.com/go-kit/kit/transport/http"
)
type TestResponse struct {
Body io.ReadCloser
String string
}
func TestHTTPClient(t *testing.T) {
var (
te... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/request_response_funcs.go | transport/http/request_response_funcs.go | package http
import (
"context"
"net/http"
)
// RequestFunc may take information from an HTTP request and put it into a
// request context. In Servers, RequestFuncs are executed prior to invoking the
// endpoint. In Clients, RequestFuncs are executed after creating the request
// but prior to invoking the HTTP clie... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/example_test.go | transport/http/example_test.go | package http
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
)
func ExamplePopulateRequestContext() {
handler := NewServer(
func(ctx context.Context, request interface{}) (response interface{}, err error) {
fmt.Println("Method", ctx.Value(ContextKeyRequestMethod).(string))
fmt.Println("RequestPat... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/encode_decode.go | transport/http/encode_decode.go | package http
import (
"context"
"net/http"
)
// DecodeRequestFunc extracts a user-domain request object from an HTTP
// request object. It's designed to be used in HTTP servers, for server-side
// endpoints. One straightforward DecodeRequestFunc could be something that
// JSON decodes from the request body to the c... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/server.go | transport/http/server.go | package http
import (
"context"
"encoding/json"
"net/http"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/transport"
"github.com/go-kit/log"
)
// Server wraps an endpoint and implements http.Handler.
type Server struct {
e endpoint.Endpoint
dec DecodeRequestFunc
enc Enc... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/intercepting_writer_test.go | transport/http/intercepting_writer_test.go | package http
import (
"bufio"
"io"
"net"
"net/http"
"testing"
)
type versatileWriter struct {
http.ResponseWriter
closeNotifyCalled bool
hijackCalled bool
readFromCalled bool
pushCalled bool
flushCalled bool
}
func (v *versatileWriter) Flush() { v.flushCalled = true }
func (v *versati... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/intercepting_writer.go | transport/http/intercepting_writer.go | package http
import (
"io"
"net/http"
)
type interceptingWriter struct {
http.ResponseWriter
code int
written int64
}
// WriteHeader may not be explicitly called, so care must be taken to
// initialize w.code to its default value of http.StatusOK.
func (w *interceptingWriter) WriteHeader(code int) {
w.code ... | go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
go-kit/kit | https://github.com/go-kit/kit/blob/78fbbceece7bbcf073bee814a7772f4397ea756c/transport/http/doc.go | transport/http/doc.go | // Package http provides a general purpose HTTP binding for endpoints.
package http
| go | MIT | 78fbbceece7bbcf073bee814a7772f4397ea756c | 2026-01-07T08:37:16.912292Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.