chainstats

package module
v0.0.0-...-46afc6a Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 2 Imported by: 0

README

ChainStats

ChainStats is a simple Go library that allows you to chain multiple grpc.StatsHandler instances.

Installation

go get github.com/inigohu/chainstats
Usage

package main

import (
 "context"
 "google.golang.org/grpc"
 "google.golang.org/grpc/stats"
 "github.com/inigohu/chainstats"
)

// Example custom stats handler
type customStatsHandler struct{}

func (h *customStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
 // Add custom logic here
 return ctx
}

func (h *customStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats) {
 // Add custom logic here
}

func (h *customStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context {
 // Add custom logic here
 return ctx
}

func (h *customStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats) {
 // Add custom logic here
}

func main() {
 customHandler1 := &customStatsHandler{}
 customHandler2 := &customStatsHandler{}

 statsHandler := chainstats.NewChainStatsHandler(customHandler1, customHandler2)

 server := grpc.NewServer(grpc.StatsHandler(statsHandler))

 // Register your gRPC services and start the server
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainStatsHandler

type ChainStatsHandler struct {
	// contains filtered or unexported fields
}

ChainStatsHandler is a composite stats.Handler that chains multiple stats.Handler instances.

func NewChainStatsHandler

func NewChainStatsHandler(handlers ...stats.Handler) *ChainStatsHandler

NewChainStatsHandler creates a new ChainStatsHandler.

func (*ChainStatsHandler) HandleConn

func (c *ChainStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats)

HandleConn calls HandleConn on all the chained stats.Handler instances.

func (*ChainStatsHandler) HandleRPC

func (c *ChainStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)

HandleRPC calls HandleRPC on all the chained stats.Handler instances.

func (*ChainStatsHandler) TagConn

TagConn calls TagConn on all the chained stats.Handler instances.

func (*ChainStatsHandler) TagRPC

TagRPC calls TagRPC on all the chained stats.Handler instances.

Jump to

Keyboard shortcuts

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