wrapper

package
v0.0.0-...-0b0e567 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallWrappers

func CallWrappers(opts ...Option) []client.CallWrapper

func ClientWrappers

func ClientWrappers(opts ...Option) []client.Wrapper

func HandlerWrappers

func HandlerWrappers(opts ...Option) []server.HandlerWrapper

func SubscriberWrappers

func SubscriberWrappers(opts ...Option) []server.SubscriberWrapper

Types

type Config

type Config struct {
	RequestId      *requestid.Config      `yaml:"requestid,omitempty"`
	Logging        *logging.Config        `yaml:"logging,omitempty"`
	Metrics        *prometheus.Options    `yaml:"metrics,omitempty"`
	Tracing        *opentelemetry.Options `yaml:"tracing,omitempty"`
	Security       *security.Config       `yaml:"security,omitempty"`
	Cors           *cors.Config           `yaml:"cors,omitempty"`
	ErrorHandler   *errorhandler.Config   `yaml:"error_handler,omitempty"`
	Timeout        *timeout.Config        `yaml:"timeout,omitempty"`
	Idempotent     *idempotent.Config     `yaml:"idempotent,omitempty"`
	CircuitBreaker *circuitbreaker.Config `yaml:"circuit_breaker,omitempty"`
	RateLimiter    *ratelimiter.Config    `yaml:"rate_limiter,omitempty"`
	Auth           *auth.Config           `yaml:"auth,omitempty"`
}

Config holds configuration for all wrapper types loaded from config center.

type Option

type Option func(*Options)

func DisableAuth

func DisableAuth() Option

DisableAuth disables the auth wrapper.

func DisableCircuitBreaker

func DisableCircuitBreaker() Option

DisableCircuitBreaker disables the circuit breaker wrapper.

func DisableCors

func DisableCors() Option

DisableCors disables the CORS wrapper.

func DisableErrorHandler

func DisableErrorHandler() Option

DisableErrorHandler disables the error handler wrapper.

func DisableIdempotent

func DisableIdempotent() Option

DisableIdempotent disables the idempotent wrapper.

func DisableLogging

func DisableLogging() Option

DisableLogging disables the logging wrapper.

func DisableMetrics

func DisableMetrics() Option

DisableMetrics disables the metrics wrapper.

func DisableRateLimiter

func DisableRateLimiter() Option

DisableRateLimiter disables the rate limiter wrapper.

func DisableRequestId

func DisableRequestId() Option

DisableRequestId disables the request ID wrapper.

func DisableSecurity

func DisableSecurity() Option

DisableSecurity disables the security wrapper.

func DisableTimeout

func DisableTimeout() Option

DisableTimeout disables the timeout wrapper.

func DisableTracing

func DisableTracing() Option

DisableTracing disables the tracing wrapper.

func EnableIdempotent

func EnableIdempotent() Option

EnableIdempotent enables the idempotent wrapper.

func WithAuthOptions

func WithAuthOptions(opts ...auth.Option) Option

WithAuthOptions enables and configures the auth wrapper.

func WithCircuitBreakerOptions

func WithCircuitBreakerOptions(opts ...circuitbreaker.Option) Option

WithCircuitBreakerOptions enables and configures the circuit breaker wrapper.

func WithConfig

func WithConfig(paths ...string) Option

WithConfig loads wrapper configuration from the config center at the specified paths.

func WithCorsOptions

func WithCorsOptions(opts ...cors.Option) Option

WithCorsOptions enables and configures the CORS wrapper.

func WithErrorHandlerOptions

func WithErrorHandlerOptions(opts ...errorhandler.Option) Option

WithErrorHandlerOptions enables and configures the error handler wrapper.

func WithIdempotentOptions

func WithIdempotentOptions(opts ...idempotent.Option) Option

WithIdempotentOptions enables and configures the idempotent wrapper.

func WithLoggingOptions

func WithLoggingOptions(opts ...logging.Option) Option

WithLoggingOptions enables and configures the logging wrapper.

func WithMetricsOptions

func WithMetricsOptions(opts ...prometheus.Option) Option

WithMetricsOptions enables and configures the metrics wrapper.

func WithRateLimiterOptions

func WithRateLimiterOptions(opts ...ratelimiter.Option) Option

WithRateLimiterOptions enables and configures the rate limiter wrapper.

func WithRequestIdOptions

func WithRequestIdOptions(opts ...requestid.Option) Option

WithRequestIdOptions enables and configures the request ID wrapper.

func WithSecurityOptions

func WithSecurityOptions(opts ...security.Option) Option

WithSecurityOptions enables and configures the security wrapper.

func WithTimeoutOptions

func WithTimeoutOptions(opts ...timeout.Option) Option

WithTimeoutOptions enables and configures the timeout wrapper.

func WithTracingOptions

func WithTracingOptions(opts ...opentelemetry.Option) Option

WithTracingOptions enables and configures the tracing wrapper.

type Options

Options holds configuration for all available wrappers.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns Options with sensible defaults. Most wrappers are enabled by default except Idempotent.

type WrapperInfo

type WrapperInfo struct {
	// Name is the unique identifier of the wrapper (e.g., "logging", "tracing").
	Name string
	// Type indicates the wrapper category: "client", "call", "handler", or "subscriber".
	Type string
	// Enabled indicates whether this wrapper is currently active.
	Enabled bool
	// Order is the execution priority (lower numbers execute first).
	Order int
}

WrapperInfo describes an active wrapper in the chain.

func ActiveWrappers

func ActiveWrappers(opts ...Option) []WrapperInfo

ActiveWrappers returns information about all configured wrappers and their status. The result is organized by wrapper type and execution order.

func ActiveWrappersByType

func ActiveWrappersByType(wrapperType string, opts ...Option) []WrapperInfo

ActiveWrappersByType returns wrapper information filtered by type. The wrapperType parameter accepts: "client", "call", "handler", or "subscriber".

func EnabledWrappers

func EnabledWrappers(opts ...Option) []WrapperInfo

EnabledWrappers returns only the enabled wrappers.

type WrapperOption

type WrapperOption[T any] struct {
	// Enabled indicates whether this wrapper is active.
	Enabled bool
	// Opts contains the configuration options for this wrapper.
	Opts []T
}

WrapperOption holds the enabled state and options for a specific wrapper type.

Source Files

  • options.go
  • wrappers.go

Directories

Path Synopsis
Package circuitbreaker provides circuit breaker middleware for go-micro services.
Package circuitbreaker provides circuit breaker middleware for go-micro services.
Package idempotent provides idempotency middleware for go-micro services.
Package idempotent provides idempotency middleware for go-micro services.
metric
prometheus
Package prometheus provides Prometheus metrics wrappers for micro services.
Package prometheus provides Prometheus metrics wrappers for micro services.
example command
Package main shows examples of how to use the rate limiter wrapper
Package main shows examples of how to use the rate limiter wrapper
Package wrapper injects a go-micro.Service into the context
Package wrapper injects a go-micro.Service into the context
Package timeout provides timeout handling for go-micro services
Package timeout provides timeout handling for go-micro services
trace

Jump to

Keyboard shortcuts

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