otredis

package module
v0.0.0-...-984117a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

goredis

a middleware for goredis to use opentracing

import (
	"net/http"

	"github.com/go-redis/redis/v8"

	otredis "github.com/krantideep95/goredis"
)

var redisClient *redis.Client // initialized at program startup

func handleRequest(w http.ResponseWriter, req *http.Request) {

	client := otredis.Wrap(redisClient, nil, , otredis.Config{
        Host:     host,
        Port:     uint16(port),
        Database: database,
})
	...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	redis.UniversalClient

	// ClusterClient returns the wrapped *redis.ClusterClient,
	// or nil if a non-cluster client is wrapped.
	Cluster() *redis.ClusterClient

	// Ring returns the wrapped *redis.Ring,
	// or nil if a non-ring client is wrapped.
	RingClient() *redis.Ring
}

Client is the interface returned by Wrap.

Client implements redis.UniversalClient

func Wrap

func Wrap(client redis.UniversalClient, tracer opentracing.Tracer, config Config) Client

Wrap wraps client such that executed commands are reported as spans to tracer, using the command's associated context.

type Config

type Config struct {
	Host     string
	Port     uint16
	Database int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL