rpc

package
v0.0.0-...-8d637a2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 54 Imported by: 0

Documentation

Overview

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a lightweight RPC server and client over HTTP for gofly services. It supports service registration, method and streaming handlers, governance (rate limiting, circuit breaking, concurrency limiting), metadata propagation, and TLS.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Package rpc provides a gRPC-compatible RPC server and client with governance, discovery, load balancing and streaming support.

Index

Examples

Constants

View Source
const (
	ConnPoolModePool  = "pool"
	ConnPoolModeLong  = "long"
	ConnPoolModeShort = "short"
)
View Source
const (
	CodeOK                 = coreerrors.CodeOK
	CodeCanceled           = coreerrors.CodeCanceled
	CodeUnknown            = coreerrors.CodeUnknown
	CodeInvalidArgument    = coreerrors.CodeInvalidArgument
	CodeDeadlineExceeded   = coreerrors.CodeDeadlineExceeded
	CodeNotFound           = coreerrors.CodeNotFound
	CodeAlreadyExists      = coreerrors.CodeAlreadyExists
	CodePermissionDenied   = coreerrors.CodePermissionDenied
	CodeResourceExhausted  = coreerrors.CodeResourceExhausted
	CodeFailedPrecondition = coreerrors.CodeFailedPrecondition
	CodeAborted            = coreerrors.CodeAborted
	CodeOutOfRange         = coreerrors.CodeOutOfRange
	CodeUnimplemented      = coreerrors.CodeUnimplemented
	CodeInternal           = coreerrors.CodeInternal
	CodeUnavailable        = coreerrors.CodeUnavailable
	CodeDataLoss           = coreerrors.CodeDataLoss
	CodeUnauthenticated    = coreerrors.CodeUnauthenticated
)
View Source
const (
	RPCMuxDiagnosisSinkIsolationInProcess       = "in_process"
	RPCMuxDiagnosisSinkIsolationIsolatedProcess = "isolated_process"
	RPCMuxDiagnosisSinkIsolationWASM            = "wasm"
)
View Source
const (
	RPCMuxDiagnosisOperatorPauseSink   = "pause_sink"
	RPCMuxDiagnosisOperatorResumeSink  = "resume_sink"
	RPCMuxDiagnosisOperatorForceProbe  = "force_probe"
	RPCMuxDiagnosisOperatorDebugReplay = "debug_replay"

	// RPCMuxDiagnosisOperatorHistorySourcePrimary selects the active JSONL file.
	RPCMuxDiagnosisOperatorHistorySourcePrimary = "primary"
	// RPCMuxDiagnosisOperatorHistorySourceBackup selects the rotated .bak file.
	RPCMuxDiagnosisOperatorHistorySourceBackup = "backup"
)
View Source
const (
	RPCMuxSubprocessPolicyErrorCommandDenied     = "command_denied"
	RPCMuxSubprocessPolicyErrorWorkDirEscaped    = "workdir_escaped"
	RPCMuxSubprocessPolicyErrorEnvNotWhitelisted = "env_not_whitelisted"
)
View Source
const (
	RPCBalancerRoundRobin         = "round_robin"
	RPCBalancerWeightedRoundRobin = "weighted_round_robin"
	RPCBalancerP2C                = "p2c"
	RPCBalancerConsistentHash     = "consistent_hash"
	RPCBalancerHealth             = "health"
)
View Source
const DefaultMaxFrameBytes int64 = 4 << 20

Variables

View Source
var (
	// ErrConnPoolClosed is returned when operating on a closed pool.
	ErrConnPoolClosed = errors.New("rpc connection pool is closed")
	// ErrConnPoolExhausted is returned when the pool has no available slots.
	ErrConnPoolExhausted = errors.New("rpc connection pool is exhausted")
)
View Source
var (
	ErrExperimentalMuxTransportClosed = errors.New("rpc experimental mux transport is closed")
	ErrExperimentalMuxStreamClosed    = errors.New("rpc experimental mux stream is closed")
)
View Source
var ErrFrameTooLarge = errors.New("rpc frame exceeds maximum size")
View Source
var ErrStreamClosed = errors.New("rpc stream closed")

Functions

func AdaptiveBreakerMiddleware

func AdaptiveBreakerMiddleware(brk *breaker.AdaptiveBreaker) endpoint.Middleware

func AdaptiveLimitMiddleware

func AdaptiveLimitMiddleware(limiter *limit.AdaptiveLimiter) endpoint.Middleware

func AnnotateMuxDiagnosisSpan

func AnnotateMuxDiagnosisSpan(ctx context.Context, probe RPCDiagnosisProbe)

AnnotateMuxDiagnosisSpan attaches mux diagnosis attributes to the current OTel span.

func ClientBearerTokenMiddleware

func ClientBearerTokenMiddleware(token string) endpoint.Middleware

func ContextWithHashKey

func ContextWithHashKey(ctx context.Context, key string) context.Context

func DecodeJSONPayload

func DecodeJSONPayload[T any](payload json.RawMessage) (T, error)

func DecodeRPCMuxOTelLogProfile

func DecodeRPCMuxOTelLogProfile(profile string, target any) error

DecodeRPCMuxOTelLogProfile decodes one JSON object into a sink-owned typed profile. Unknown fields and trailing values are rejected.

func EncodeJSONPayload

func EncodeJSONPayload(v any) (json.RawMessage, error)

func HashKeyFromContext

func HashKeyFromContext(ctx context.Context) string

func IsZeroTransportConfig

func IsZeroTransportConfig(conf TransportConfig) bool

func LoggingMiddleware

func LoggingMiddleware(name string) endpoint.Middleware

func LoggingMiddlewareWithSampler

func LoggingMiddlewareWithSampler(name string, sampler trace.Sampler) endpoint.Middleware

func MaxConcurrencyMiddleware

func MaxConcurrencyMiddleware(max int) endpoint.Middleware

func MethodPath

func MethodPath(service string, method string) (string, error)

func MetricsMiddleware

func MetricsMiddleware(name string, reg *metrics.Registry) endpoint.Middleware

func MuxTraceAttributes

func MuxTraceAttributes(probe RPCDiagnosisProbe) []attribute.KeyValue

MuxTraceAttributes returns OTel span attributes for a filtered mux diagnosis. connection_id is intentionally trace-only and must not be used as a metric label because it is high-cardinality.

func NewHTTPClient

func NewHTTPClient(conf TransportConfig) *http.Client

func NormalizeRPCMuxFlowControlEvent

func NormalizeRPCMuxFlowControlEvent(event string) string

func RPCMuxDiagnosisOperatorAuditRecordValid

func RPCMuxDiagnosisOperatorAuditRecordValid(action RPCMuxDiagnosisOperatorAction) error

RPCMuxDiagnosisOperatorAuditRecordValid resolves a recorded action's schema and validates its details against that schema. It returns an error when the record has no recognized schema marker or its details violate the contract.

func RPCMuxDiagnosisOperatorAuditSchemas

func RPCMuxDiagnosisOperatorAuditSchemas() map[string]RPCMuxDiagnosisOperatorAuditSchema

RPCMuxDiagnosisOperatorAuditSchemas publishes the stable audit detail schemas for operator actions so external audit systems can parse and structurally validate action details without guessing field names. Each entry pins a schema version, its ordered field list, and a JSON Schema; the sink action schema covers pause_sink, resume_sink, and force_probe, which share the same detail fields.

func RPCMuxOTelLogSinkRegistered

func RPCMuxOTelLogSinkRegistered(name string) bool

RPCMuxOTelLogSinkRegistered reports whether a configured sink is available. Empty names resolve to the built-in slog sink.

func RecoverMiddleware

func RecoverMiddleware() endpoint.Middleware

func RegisterRPCMuxOTelLogSink

func RegisterRPCMuxOTelLogSink(name string, factory RPCMuxOTelLogSinkFactory) func()

RegisterRPCMuxOTelLogSink registers or replaces an OTel-compatible mux event sink factory. The returned cleanup function restores the previous binding, which keeps tests and embedders isolated.

func RegisterRPCMuxOTelLogSinkProvider

func RegisterRPCMuxOTelLogSinkProvider(name string, provider RPCMuxOTelLogSinkProvider) func()

RegisterRPCMuxOTelLogSinkProvider registers or replaces a provider that owns both exporter construction and profile validation. The returned cleanup function restores the previous binding.

func RequestIDMiddleware

func RequestIDMiddleware() endpoint.Middleware

func ServeExperimentalMuxCandidateListener

func ServeExperimentalMuxCandidateListener(ctx context.Context, listener net.Listener, configure ExperimentalMuxServerConfigurer, cfg ExperimentalMuxCandidateConfig) error

func ServeExperimentalMuxListener

func ServeExperimentalMuxListener(ctx context.Context, listener net.Listener, configure ExperimentalMuxServerConfigurer, opts ...ExperimentalMuxTransportOption) error

func ServeFramed

func ServeFramed(ctx context.Context, transport *FramedTransport, handler MessageHandler, mws ...MessageMiddleware) error

func ServerAuthMiddleware

func ServerAuthMiddleware(validator auth.Validator) endpoint.Middleware

func TimeoutMiddleware

func TimeoutMiddleware(timeout time.Duration) endpoint.Middleware

func TraceMiddleware

func TraceMiddleware(service string) endpoint.Middleware

func TraceMiddlewareWithSampler

func TraceMiddlewareWithSampler(service string, sampler trace.Sampler) endpoint.Middleware

func ValidateRPCMuxDiagnosisSinkSetConfig

func ValidateRPCMuxDiagnosisSinkSetConfig(config RPCMuxDiagnosisSinkSetConfig) error

ValidateRPCMuxDiagnosisSinkSetConfig validates one generation without constructing exporters or starting delivery workers.

func ValidateRPCMuxOTelLogSinkProfile

func ValidateRPCMuxOTelLogSinkProfile(name string, profile string) error

ValidateRPCMuxOTelLogSinkProfile validates a configured sink and its sink-specific profile before runtime construction.

Types

type Balancer

type Balancer interface {
	Pick(ctx context.Context, endpoints []string) (string, error)
}

type BasicSuite

type BasicSuite struct {
	Server []ServerOption
	Client []ClientOption
}

func (BasicSuite) ClientOptions

func (s BasicSuite) ClientOptions() []ClientOption

func (BasicSuite) ServerOptions

func (s BasicSuite) ServerOptions() []ServerOption

type BinaryFrameCodec

type BinaryFrameCodec struct{}

func (BinaryFrameCodec) Marshal

func (BinaryFrameCodec) Marshal(msg Message) ([]byte, error)

func (BinaryFrameCodec) Name

func (BinaryFrameCodec) Name() string

func (BinaryFrameCodec) Unmarshal

func (BinaryFrameCodec) Unmarshal(data []byte) (Message, error)

type CachedResolver

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

func NewCachedResolver

func NewCachedResolver(ctx context.Context, source WatchResolver) (*CachedResolver, error)

func (*CachedResolver) Resolve

func (r *CachedResolver) Resolve(ctx context.Context) ([]string, error)

func (*CachedResolver) Snapshot

func (r *CachedResolver) Snapshot() ResolverSnapshot

func (*CachedResolver) Watch

func (r *CachedResolver) Watch(ctx context.Context) (<-chan []string, error)

type Client

type Client interface {
	Call(ctx context.Context, method string, request any, response any) error
}

Client is the basic RPC client interface.

type ClientOption

type ClientOption func(*clientOptions)

func WithAdaptiveBreaker

func WithAdaptiveBreaker(brk *breaker.AdaptiveBreaker) ClientOption

func WithBalancer

func WithBalancer(balancer Balancer) ClientOption

func WithBreaker

func WithBreaker(brk *breaker.Breaker) ClientOption

func WithClientAdaptiveLimiter

func WithClientAdaptiveLimiter(limiter *limit.AdaptiveLimiter) ClientOption

func WithClientGovernanceManager

func WithClientGovernanceManager(manager *governance.Manager) ClientOption

func WithClientGovernanceRuleSet

func WithClientGovernanceRuleSet(rules *governance.RuleSet) ClientOption

func WithClientGovernanceSuite

func WithClientGovernanceSuite(suite *governance.Suite) ClientOption

func WithClientGovernanceTags

func WithClientGovernanceTags(tags map[string]string) ClientOption

func WithClientMaxConcurrency

func WithClientMaxConcurrency(max int) ClientOption

func WithClientMiddleware

func WithClientMiddleware(mw endpoint.Middleware) ClientOption

func WithClientRuleSet

func WithClientRuleSet(rules *governance.RuleSet) ClientOption

func WithClientSingleflight

func WithClientSingleflight() ClientOption

func WithClientSingleflightKey

func WithClientSingleflightKey(fn SingleflightKeyFunc) ClientOption

func WithClientStreamIdleTimeout

func WithClientStreamIdleTimeout(timeout time.Duration) ClientOption

WithClientStreamIdleTimeout closes streams that have no read or write activity for the configured duration. It is disabled by default because some production streams are intentionally long-lived and quiet.

func WithClientStreamMiddleware

func WithClientStreamMiddleware(mw ClientStreamMiddleware) ClientOption

func WithClientStreamTimeout

func WithClientStreamTimeout(timeout time.Duration) ClientOption

WithClientStreamTimeout configures per-operation read/write deadlines for streams created by HTTPClient.Stream. It is intentionally separate from the unary request timeout so long-lived streams are not capped by default.

func WithClientSuite

func WithClientSuite(suite Suite) ClientOption

func WithClientTLS

func WithClientTLS(cfg security.TLSConfig) ClientOption

WithClientTLS configures TLS or mutual TLS for the self-developed RPC client. Provide CAFile to verify the server and CertFile/KeyFile to present a client identity (mTLS). The target must use the https:// scheme for TLS to take effect.

func WithClientWarmup

func WithClientWarmup(conf RPCWarmupConfig) ClientOption

func WithCodec

func WithCodec(codec Codec) ClientOption

func WithConnPool

func WithConnPool(dial EndpointConnDialer, conf ConnPoolConfig) ClientOption

func WithConnPoolManager

func WithConnPoolManager(manager *ConnPoolManager) ClientOption

func WithDynamicRPCPolicy

func WithDynamicRPCPolicy(provider RPCPolicyProvider) ClientOption

func WithExperimentalMuxClientAdapter

func WithExperimentalMuxClientAdapter(adapter *ExperimentalMuxClientAdapter) ClientOption

WithExperimentalMuxClientAdapter opts the client into the experimental mux stream adapter. It does not replace the default HTTP upgrade Stream path; callers must use HTTPClient.MuxStream explicitly.

func WithExperimentalMuxConnectionManager

func WithExperimentalMuxConnectionManager(manager *ExperimentalMuxConnectionManager) ClientOption

WithExperimentalMuxConnectionManager opts the client into resolver/balancer backed experimental mux streams. It does not replace the default HTTP upgrade Stream path; callers must use HTTPClient.MuxStream explicitly.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

func WithKitexClientInterceptors

func WithKitexClientInterceptors(interceptors ...KitexInterceptor) ClientOption

func WithLongConnection

func WithLongConnection(dial EndpointConnDialer) ClientOption

func WithMuxDiagnosisEventExporter

func WithMuxDiagnosisEventExporter(exporter RPCMuxDiagnosisEventExporter, filter RPCMuxDiagnosisFilter) ClientOption

WithMuxDiagnosisEventExporter enables HTTPClient.MuxStream to export a structured event stream derived from RPCMuxDiagnosisEvent. The filter may include endpoint or connection IDs for troubleshooting; exporters must keep those fields out of metric labels.

func WithMuxDiagnosisEventExporterDelivery

func WithMuxDiagnosisEventExporterDelivery(exporter RPCMuxDiagnosisEventExporter, filter RPCMuxDiagnosisFilter, config RPCMuxDiagnosisExporterDeliveryConfig) ClientOption

WithMuxDiagnosisEventExporterDelivery enables bounded asynchronous delivery for a client-side mux diagnosis exporter.

func WithMuxDiagnosisEventLogging

func WithMuxDiagnosisEventLogging(logger *slog.Logger, filter RPCMuxDiagnosisFilter) ClientOption

WithMuxDiagnosisEventLogging exports mux diagnosis events through slog. When slog is backed by an OTel bridge this becomes the mux event log bridge without coupling the rpc package to a concrete OTel logging SDK.

func WithMuxDiagnosisLogging

func WithMuxDiagnosisLogging(logger *slog.Logger) ClientOption

WithMuxDiagnosisLogging enables HTTPClient.MuxStream to emit structured mux diagnosis logs. Logs may include high-cardinality connection IDs and pool slots for troubleshooting, so callers should keep this opt-in and avoid mirroring these fields as metric labels.

func WithMuxTraceAnnotation

func WithMuxTraceAnnotation() ClientOption

WithMuxTraceAnnotation enables HTTPClient.MuxStream to annotate the current OTel span with mux transport diagnosis from the actual open path. The attributes may include high-cardinality connection IDs, so this is trace-only and must not be mirrored as metric labels.

func WithRPCPolicy

func WithRPCPolicy(policy RPCPolicy) ClientOption

func WithResolver

func WithResolver(resolver Resolver) ClientOption

func WithRetry

func WithRetry(attempts int) ClientOption

func WithRetryPolicy

func WithRetryPolicy(policy retry.Policy) ClientOption

func WithShortConnection

func WithShortConnection(dial EndpointConnDialer) ClientOption

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

func WithTransportConfig

func WithTransportConfig(conf TransportConfig) ClientOption

type ClientStreamHandler

type ClientStreamHandler func(ctx context.Context, method string) (*Stream, error)

ClientStreamHandler opens a client-side RPC stream.

type ClientStreamMiddleware

type ClientStreamMiddleware func(ClientStreamHandler) ClientStreamHandler

ClientStreamMiddleware wraps client-side stream creation with cross-cutting behavior.

func ClientStreamAdaptiveBreakerMiddleware

func ClientStreamAdaptiveBreakerMiddleware(brk *breaker.AdaptiveBreaker) ClientStreamMiddleware

func ClientStreamAdaptiveLimitMiddleware

func ClientStreamAdaptiveLimitMiddleware(limiter *limit.AdaptiveLimiter) ClientStreamMiddleware

func ClientStreamBearerTokenMiddleware

func ClientStreamBearerTokenMiddleware(token string) ClientStreamMiddleware

func ClientStreamBreakerMiddleware

func ClientStreamBreakerMiddleware(brk *breaker.Breaker) ClientStreamMiddleware

func ClientStreamLoggingMiddleware

func ClientStreamLoggingMiddleware(name string) ClientStreamMiddleware

func ClientStreamLoggingMiddlewareWithSampler

func ClientStreamLoggingMiddlewareWithSampler(name string, sampler trace.Sampler) ClientStreamMiddleware

func ClientStreamMaxConcurrencyMiddleware

func ClientStreamMaxConcurrencyMiddleware(max int) ClientStreamMiddleware

func ClientStreamMetricsMiddleware

func ClientStreamMetricsMiddleware(name string, reg *metrics.Registry) ClientStreamMiddleware

func ClientStreamRequestIDMiddleware

func ClientStreamRequestIDMiddleware() ClientStreamMiddleware

func ClientStreamTraceMiddleware

func ClientStreamTraceMiddleware(service string) ClientStreamMiddleware

func ClientStreamTraceMiddlewareWithSampler

func ClientStreamTraceMiddlewareWithSampler(service string, sampler trace.Sampler) ClientStreamMiddleware

type Code

type Code = coreerrors.Code

func CodeOf

func CodeOf(err error) Code

type Codec

type Codec interface {
	Name() string
	Marshal(v any) ([]byte, error)
	Unmarshal(data []byte, v any) error
}

Codec marshals and unmarshals RPC payloads.

type ConnDialer

type ConnDialer func(context.Context) (net.Conn, error)

type ConnPool

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

func NewConnPool

func NewConnPool(network, address string, conf ConnPoolConfig) *ConnPool

func NewConnPoolWithDialer

func NewConnPoolWithDialer(dial ConnDialer, conf ConnPoolConfig) *ConnPool

func (*ConnPool) Close

func (p *ConnPool) Close() error

func (*ConnPool) Discard

func (p *ConnPool) Discard(conn *PooledConn) error

func (*ConnPool) Get

func (p *ConnPool) Get(ctx context.Context) (*PooledConn, error)

func (*ConnPool) Put

func (p *ConnPool) Put(conn *PooledConn) error

func (*ConnPool) Snapshot

func (p *ConnPool) Snapshot() ConnPoolStats

type ConnPoolConfig

type ConnPoolConfig struct {
	MaxIdle      int
	MaxActive    int
	IdleTimeout  time.Duration
	MaxLifetime  time.Duration
	DialTimeout  time.Duration
	WaitInterval time.Duration
	Mode         string
	OnClose      func(endpoint string, reason string, stats ConnPoolStats)
}

ConnPoolConfig controls connection pool sizing and timeouts.

func DefaultConnPoolConfig

func DefaultConnPoolConfig() ConnPoolConfig

DefaultConnPoolConfig returns sensible defaults.

type ConnPoolManager

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

func NewConnPoolManager

func NewConnPoolManager(dial EndpointConnDialer, conf ConnPoolConfig) *ConnPoolManager

func (*ConnPoolManager) Close

func (m *ConnPoolManager) Close() error

func (*ConnPoolManager) Get

func (m *ConnPoolManager) Get(ctx context.Context, endpoint string) (*PooledConn, error)

func (*ConnPoolManager) RemoveEndpoint

func (m *ConnPoolManager) RemoveEndpoint(endpoint string) error

func (*ConnPoolManager) Snapshot

type ConnPoolManagerSnapshot

type ConnPoolManagerSnapshot struct {
	Mode      string          `json:"mode,omitempty"`
	Endpoints []ConnPoolStats `json:"endpoints,omitempty"`
	Closed    bool            `json:"closed"`
}

type ConnPoolStats

type ConnPoolStats struct {
	Endpoint         string        `json:"endpoint,omitempty"`
	Mode             string        `json:"mode,omitempty"`
	Idle             int           `json:"idle"`
	Active           int           `json:"active"`
	Created          int64         `json:"created"`
	Reused           int64         `json:"reused"`
	Closed           int64         `json:"closed"`
	Waits            int64         `json:"waits"`
	IdleTimeout      time.Duration `json:"idleTimeout,omitempty"`
	MaxLifetime      time.Duration `json:"maxLifetime,omitempty"`
	LastClosedReason string        `json:"lastClosedReason,omitempty"`
}

ConnPoolStats reports the current pool state.

type ConsistentHashBalancer

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

func NewConsistentHashBalancer

func NewConsistentHashBalancer(opts ...ConsistentHashOption) *ConsistentHashBalancer

func (*ConsistentHashBalancer) Pick

func (b *ConsistentHashBalancer) Pick(ctx context.Context, endpoints []string) (string, error)

type ConsistentHashOption

type ConsistentHashOption func(*ConsistentHashBalancer)

func WithConsistentHashKey

func WithConsistentHashKey(key string) ConsistentHashOption

func WithConsistentHashReplicas

func WithConsistentHashReplicas(replicas int) ConsistentHashOption

type DNSResolver

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

func NewDNSResolver

func NewDNSResolver(conf DNSResolverConfig) (*DNSResolver, error)

func (*DNSResolver) Resolve

func (r *DNSResolver) Resolve(ctx context.Context) ([]string, error)

func (*DNSResolver) Snapshot

func (r *DNSResolver) Snapshot() ResolverSnapshot

func (*DNSResolver) Watch

func (r *DNSResolver) Watch(ctx context.Context) (<-chan []string, error)

type DNSResolverConfig

type DNSResolverConfig struct {
	Host          string
	Port          int
	Scheme        string
	LookupIP      func(context.Context, string) ([]net.IP, error)
	WatchInterval time.Duration
}

type Descriptor

type Descriptor struct {
	Name     string             `json:"name"`
	Version  string             `json:"version,omitempty"`
	Metadata map[string]string  `json:"metadata,omitempty"`
	Methods  []MethodDescriptor `json:"methods,omitempty"`
	Streams  []StreamDescriptor `json:"streams,omitempty"`
}

Descriptor is a JSON-friendly service descriptor.

func (Descriptor) Validate

func (d Descriptor) Validate() error

type DescriptorChange

type DescriptorChange struct {
	Category    DescriptorChangeCategory `json:"category"`
	Severity    DescriptorChangeSeverity `json:"severity"`
	Subject     string                   `json:"subject"`
	Description string                   `json:"description"`
}

type DescriptorChangeCategory

type DescriptorChangeCategory string
const (
	DescriptorChangeService   DescriptorChangeCategory = "service"
	DescriptorChangeMethod    DescriptorChangeCategory = "method"
	DescriptorChangeStream    DescriptorChangeCategory = "stream"
	DescriptorChangeType      DescriptorChangeCategory = "type"
	DescriptorChangeField     DescriptorChangeCategory = "field"
	DescriptorChangeEnum      DescriptorChangeCategory = "enum"
	DescriptorChangeSignature DescriptorChangeCategory = "signature"
	DescriptorChangeVersion   DescriptorChangeCategory = "version"
	DescriptorChangeTimeout   DescriptorChangeCategory = "timeout"
	DescriptorChangeCodec     DescriptorChangeCategory = "codec"
	DescriptorChangeBinding   DescriptorChangeCategory = "binding"
)

type DescriptorChangeSeverity

type DescriptorChangeSeverity string
const (
	DescriptorChangeBreaking DescriptorChangeSeverity = "breaking"
	DescriptorChangeWarning  DescriptorChangeSeverity = "warning"
	DescriptorChangeInfo     DescriptorChangeSeverity = "info"
)

type DescriptorCompatibilityReport

type DescriptorCompatibilityReport struct {
	Changes  []DescriptorChange `json:"changes"`
	Breaking int                `json:"breaking"`
	Warnings int                `json:"warnings"`
}

func CompareDescriptors

func CompareDescriptors(base, target Descriptor) DescriptorCompatibilityReport

func (DescriptorCompatibilityReport) HasBreaking

func (r DescriptorCompatibilityReport) HasBreaking() bool

func (DescriptorCompatibilityReport) IsCompatible

func (r DescriptorCompatibilityReport) IsCompatible() bool

type DiscoveryEventResolver

type DiscoveryEventResolver interface {
	Resolver
	WatchEvents(ctx context.Context) (<-chan discovery.Event, error)
}

type DiscoveryRegistrar

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

DiscoveryRegistrar registers service endpoints via the discovery package.

func NewDiscoveryRegistrar

func NewDiscoveryRegistrar(registrar discovery.Registrar, opts ...discovery.RegisterOption) *DiscoveryRegistrar

func (*DiscoveryRegistrar) DeregisterService

func (r *DiscoveryRegistrar) DeregisterService(ctx context.Context, service string, endpoint string) error

func (*DiscoveryRegistrar) RegisterService

func (r *DiscoveryRegistrar) RegisterService(ctx context.Context, service string, endpoint string) error

type DiscoveryResolver

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

DiscoveryResolver resolves service endpoints via the discovery package.

func NewDiscoveryResolver

func NewDiscoveryResolver(resolver discovery.Resolver, service string, opts ...discovery.ResolveOption) *DiscoveryResolver

NewDiscoveryResolver creates a resolver for the given service.

func (*DiscoveryResolver) Resolve

func (r *DiscoveryResolver) Resolve(ctx context.Context) ([]string, error)

func (*DiscoveryResolver) ResolveInstances

func (r *DiscoveryResolver) ResolveInstances(ctx context.Context) ([]ServiceInstance, error)

func (*DiscoveryResolver) Watch

func (r *DiscoveryResolver) Watch(ctx context.Context) (<-chan []string, error)

func (*DiscoveryResolver) WatchEvents

func (r *DiscoveryResolver) WatchEvents(ctx context.Context) (<-chan discovery.Event, error)

type EndpointConnDialer

type EndpointConnDialer func(context.Context, string) (net.Conn, error)

type EndpointReporter

type EndpointReporter interface {
	Report(ctx context.Context, endpoint string, err error)
}

EndpointReporter receives per-endpoint result reports.

type Error

type Error = coreerrors.Error

func Errorf

func Errorf(code Code, format string, args ...any) *Error

func NewError

func NewError(code Code, text string) *Error

type EtcdRegistry

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

func NewEtcdRegistry

func NewEtcdRegistry(baseURL string, prefix string, client *http.Client) (*EtcdRegistry, error)

func (*EtcdRegistry) Deregister

func (r *EtcdRegistry) Deregister(ctx context.Context, instance discovery.Instance) error

func (*EtcdRegistry) DeregisterService

func (r *EtcdRegistry) DeregisterService(ctx context.Context, service string, endpoint string) error

func (*EtcdRegistry) Register

func (r *EtcdRegistry) Register(ctx context.Context, instance discovery.Instance, opts ...discovery.RegisterOption) (discovery.Lease, error)

func (*EtcdRegistry) RegisterInstance

func (r *EtcdRegistry) RegisterInstance(ctx context.Context, service string, instance ServiceInstance) error

func (*EtcdRegistry) RegisterService

func (r *EtcdRegistry) RegisterService(ctx context.Context, service string, endpoint string) error

func (*EtcdRegistry) Resolve

func (r *EtcdRegistry) Resolve(ctx context.Context, service string, opts ...discovery.ResolveOption) ([]discovery.Instance, error)

func (*EtcdRegistry) ResolveInstances

func (r *EtcdRegistry) ResolveInstances(ctx context.Context, service string) ([]ServiceInstance, error)

func (*EtcdRegistry) Resolver

func (r *EtcdRegistry) Resolver(service string) Resolver

func (*EtcdRegistry) Watch

func (r *EtcdRegistry) Watch(ctx context.Context, service string, opts ...discovery.ResolveOption) (<-chan discovery.Event, error)

type ExperimentalMuxAdapterSnapshot

type ExperimentalMuxAdapterSnapshot struct {
	Role            string                           `json:"role,omitempty"`
	AcceptedStreams int64                            `json:"acceptedStreams,omitempty"`
	RejectedStreams int64                            `json:"rejectedStreams,omitempty"`
	HandlerErrors   int64                            `json:"handlerErrors,omitempty"`
	LastMethod      string                           `json:"lastMethod,omitempty"`
	LastError       string                           `json:"lastError,omitempty"`
	LastHandledAt   time.Time                        `json:"lastHandledAt,omitempty"`
	Candidate       ExperimentalMuxCandidateSnapshot `json:"candidate,omitempty"`
	Transport       ExperimentalMuxTransportSnapshot `json:"transport"`
}

ExperimentalMuxAdapterSnapshot reports opt-in mux adapter state.

type ExperimentalMuxCandidateConfig

type ExperimentalMuxCandidateConfig struct {
	Protocol                             string             `json:"protocol,omitempty"`
	TLS                                  security.TLSConfig `json:"tls,omitempty"`
	DialTimeout                          time.Duration      `json:"dialTimeout,omitempty"`
	KeepAlive                            time.Duration      `json:"keepAlive,omitempty"`
	HandshakeTimeout                     time.Duration      `json:"handshakeTimeout,omitempty"`
	KeepaliveInterval                    time.Duration      `json:"keepaliveInterval,omitempty"`
	KeepaliveIdle                        time.Duration      `json:"keepaliveIdle,omitempty"`
	WriteTimeout                         time.Duration      `json:"writeTimeout,omitempty"`
	CreditWaitTimeout                    time.Duration      `json:"creditWaitTimeout,omitempty"`
	MaxFrameBytes                        int64              `json:"maxFrameBytes,omitempty"`
	MaxMessageBytes                      int64              `json:"maxMessageBytes,omitempty"`
	MaxConcurrentStreams                 int                `json:"maxConcurrentStreams,omitempty"`
	ReceiveQueueSize                     int                `json:"receiveQueueSize,omitempty"`
	ConnectionWindow                     int                `json:"connectionWindow,omitempty"`
	FragmentStreamWindowUpdatePolicy     string             `json:"fragmentStreamWindowUpdatePolicy,omitempty"`
	FragmentConnectionWindowUpdatePolicy string             `json:"fragmentConnectionWindowUpdatePolicy,omitempty"`
	FragmentStreamWindowRefillRatio      float64            `json:"fragmentStreamWindowRefillRatio,omitempty"`
	FragmentConnectionWindowRefillRatio  float64            `json:"fragmentConnectionWindowRefillRatio,omitempty"`
	FragmentMaxDeferredFragments         int                `json:"fragmentMaxDeferredFragments,omitempty"`
	FragmentWindowPolicyRiskMode         string             `json:"fragmentWindowPolicyRiskMode,omitempty"`
	PayloadCodec                         string             `json:"payloadCodec,omitempty"`
	FrameCodec                           string             `json:"frameCodec,omitempty"`
	DrainGrace                           time.Duration      `json:"drainGrace,omitempty"`
	AllowLegacyDowngrade                 bool               `json:"allowLegacyDowngrade,omitempty"`
}

ExperimentalMuxCandidateConfig describes the opt-in production-candidate adapter surface for the experimental mux transport. It keeps the default HTTP RPC transport untouched while making the mux path configurable enough for real TCP/TLS smoke and diagnosis.

func (ExperimentalMuxCandidateConfig) Validate

Validate checks candidate mux transport policies that can be rejected before opening a network connection.

type ExperimentalMuxCandidateFailure

type ExperimentalMuxCandidateFailure struct {
	Phase        string
	PeerProtocol string
	Err          error
}

func (*ExperimentalMuxCandidateFailure) Error

func (*ExperimentalMuxCandidateFailure) Unwrap

type ExperimentalMuxCandidateSnapshot

type ExperimentalMuxCandidateSnapshot struct {
	Enabled                              bool             `json:"enabled"`
	Protocol                             string           `json:"protocol,omitempty"`
	PeerProtocol                         string           `json:"peerProtocol,omitempty"`
	NegotiatedProtocol                   string           `json:"negotiatedProtocol,omitempty"`
	TLS                                  bool             `json:"tls"`
	MutualTLS                            bool             `json:"mutualTLS"`
	NegotiationFailures                  int64            `json:"negotiationFailures,omitempty"`
	NegotiationFailureEvents             map[string]int64 `json:"negotiationFailureEvents,omitempty"`
	LastNegotiationError                 string           `json:"lastNegotiationError,omitempty"`
	LastNegotiationPhase                 string           `json:"lastNegotiationPhase,omitempty"`
	DowngradeAllowed                     bool             `json:"downgradeAllowed,omitempty"`
	Downgrades                           int64            `json:"downgrades,omitempty"`
	Downgraded                           bool             `json:"downgraded,omitempty"`
	DowngradeReason                      string           `json:"downgradeReason,omitempty"`
	DialTimeout                          time.Duration    `json:"dialTimeout,omitempty"`
	KeepAlive                            time.Duration    `json:"keepAlive,omitempty"`
	HandshakeTimeout                     time.Duration    `json:"handshakeTimeout,omitempty"`
	KeepaliveInterval                    time.Duration    `json:"keepaliveInterval,omitempty"`
	KeepaliveIdle                        time.Duration    `json:"keepaliveIdle,omitempty"`
	WriteTimeout                         time.Duration    `json:"writeTimeout,omitempty"`
	CreditWaitTimeout                    time.Duration    `json:"creditWaitTimeout,omitempty"`
	MaxFrameBytes                        int64            `json:"maxFrameBytes,omitempty"`
	MaxMessageBytes                      int64            `json:"maxMessageBytes,omitempty"`
	MaxConcurrentStreams                 int              `json:"maxConcurrentStreams,omitempty"`
	ReceiveQueueSize                     int              `json:"receiveQueueSize,omitempty"`
	ConnectionWindow                     int              `json:"connectionWindow,omitempty"`
	FragmentStreamWindowUpdatePolicy     string           `json:"fragmentStreamWindowUpdatePolicy,omitempty"`
	FragmentConnectionWindowUpdatePolicy string           `json:"fragmentConnectionWindowUpdatePolicy,omitempty"`
	FragmentStreamWindowRefillRatio      float64          `json:"fragmentStreamWindowRefillRatio,omitempty"`
	FragmentConnectionWindowRefillRatio  float64          `json:"fragmentConnectionWindowRefillRatio,omitempty"`
	FragmentMaxDeferredFragments         int              `json:"fragmentMaxDeferredFragments,omitempty"`
	FragmentWindowPolicyRisk             bool             `json:"fragmentWindowPolicyRisk,omitempty"`
	FragmentWindowPolicyRiskReason       string           `json:"fragmentWindowPolicyRiskReason,omitempty"`
	FragmentWindowPolicyRiskMode         string           `json:"fragmentWindowPolicyRiskMode,omitempty"`
	FragmentWindowPolicyRiskWarning      bool             `json:"fragmentWindowPolicyRiskWarning,omitempty"`
	FragmentWindowPolicyRiskRejected     bool             `json:"fragmentWindowPolicyRiskRejected,omitempty"`
	FragmentEstimatedMaxFragments        int              `json:"fragmentEstimatedMaxFragments,omitempty"`
	PayloadCodec                         string           `json:"payloadCodec,omitempty"`
	FrameCodec                           string           `json:"frameCodec,omitempty"`
	DrainGrace                           time.Duration    `json:"drainGrace,omitempty"`
}

ExperimentalMuxCandidateSnapshot is intentionally path-free so runtime diagnosis can report the active transport policy without leaking cert paths.

type ExperimentalMuxClientAdapter

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

ExperimentalMuxClientAdapter opens streams over an explicit mux transport.

func DialExperimentalMuxCandidateClientAdapter

func DialExperimentalMuxCandidateClientAdapter(ctx context.Context, network string, address string, cfg ExperimentalMuxCandidateConfig) (*ExperimentalMuxClientAdapter, error)

func DialExperimentalMuxClientAdapter

func DialExperimentalMuxClientAdapter(ctx context.Context, network string, address string, opts ...ExperimentalMuxTransportOption) (*ExperimentalMuxClientAdapter, error)

func NewExperimentalMuxClientAdapter

func NewExperimentalMuxClientAdapter(conn net.Conn, opts ...ExperimentalMuxTransportOption) *ExperimentalMuxClientAdapter

NewExperimentalMuxClientAdapter creates an opt-in mux client over conn.

func (*ExperimentalMuxClientAdapter) Close

Close closes the underlying mux transport.

func (*ExperimentalMuxClientAdapter) DiagnosisSnapshot

DiagnosisSnapshot returns client-side mux transport diagnosis.

func (*ExperimentalMuxClientAdapter) Drain

func (*ExperimentalMuxClientAdapter) OpenStream

OpenStream opens a mux stream and sends an adapter routing frame before user messages.

func (*ExperimentalMuxClientAdapter) RuntimeComponentSnapshot

RuntimeComponentSnapshot returns an AI-readable runtime component snapshot.

func (*ExperimentalMuxClientAdapter) Snapshot

Snapshot returns client-side mux adapter transport state.

type ExperimentalMuxConnectionManager

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

func (*ExperimentalMuxConnectionManager) Close

func (*ExperimentalMuxConnectionManager) CloseIdle

func (*ExperimentalMuxConnectionManager) DiagnosisSnapshot

func (*ExperimentalMuxConnectionManager) Drain

func (*ExperimentalMuxConnectionManager) OpenStream

func (*ExperimentalMuxConnectionManager) Snapshot

func (*ExperimentalMuxConnectionManager) SyncResolver

func (*ExperimentalMuxConnectionManager) Watch

type ExperimentalMuxConnectionManagerOption

type ExperimentalMuxConnectionManagerOption func(*ExperimentalMuxConnectionManager)

func WithExperimentalMuxConnectionManagerBalancer

func WithExperimentalMuxConnectionManagerBalancer(balancer Balancer) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerHealthBackoffMultiplier

func WithExperimentalMuxConnectionManagerHealthBackoffMultiplier(multiplier int) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerHealthEjectionDuration

func WithExperimentalMuxConnectionManagerHealthEjectionDuration(duration time.Duration) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerHealthFailureThreshold

func WithExperimentalMuxConnectionManagerHealthFailureThreshold(threshold int) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerHealthMaxCooldown

func WithExperimentalMuxConnectionManagerHealthMaxCooldown(max time.Duration) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerIdleTimeout

func WithExperimentalMuxConnectionManagerIdleTimeout(timeout time.Duration) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerJanitorInterval

func WithExperimentalMuxConnectionManagerJanitorInterval(interval time.Duration) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerMaxConnsPerEndpoint

func WithExperimentalMuxConnectionManagerMaxConnsPerEndpoint(max int) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerMaxIdleConnsPerEndpoint

func WithExperimentalMuxConnectionManagerMaxIdleConnsPerEndpoint(max int) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerMaxOpenRetries

func WithExperimentalMuxConnectionManagerMaxOpenRetries(max int) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerMaxStreamsPerConn

func WithExperimentalMuxConnectionManagerMaxStreamsPerConn(max int) ExperimentalMuxConnectionManagerOption

func WithExperimentalMuxConnectionManagerOpenRetryReasons

func WithExperimentalMuxConnectionManagerOpenRetryReasons(reasons ...string) ExperimentalMuxConnectionManagerOption

type ExperimentalMuxConnectionManagerSnapshot

type ExperimentalMuxConnectionManagerSnapshot struct {
	Closed                  bool                                    `json:"closed"`
	IdleTimeout             time.Duration                           `json:"idleTimeout,omitempty"`
	MaxStreamsPerConn       int                                     `json:"maxStreamsPerConn,omitempty"`
	MaxConnsPerEndpoint     int                                     `json:"maxConnsPerEndpoint,omitempty"`
	MaxIdleConnsPerEndpoint int                                     `json:"maxIdleConnsPerEndpoint,omitempty"`
	HealthFailureThreshold  int                                     `json:"healthFailureThreshold,omitempty"`
	HealthEjectionDuration  time.Duration                           `json:"healthEjectionDuration,omitempty"`
	HealthBackoffMultiplier int                                     `json:"healthBackoffMultiplier,omitempty"`
	HealthMaxCooldown       time.Duration                           `json:"healthMaxCooldown,omitempty"`
	MaxOpenRetries          int                                     `json:"maxOpenRetries,omitempty"`
	OpenRetryReasons        []string                                `json:"openRetryReasons,omitempty"`
	JanitorInterval         time.Duration                           `json:"janitorInterval,omitempty"`
	Candidate               ExperimentalMuxCandidateSnapshot        `json:"candidate,omitempty"`
	Endpoints               []ExperimentalMuxEndpointSnapshot       `json:"endpoints,omitempty"`
	Health                  []ExperimentalMuxEndpointHealthSnapshot `json:"health,omitempty"`
	RetiredAdapters         int                                     `json:"retiredAdapters,omitempty"`
	WatchUpdates            int64                                   `json:"watchUpdates,omitempty"`
	Removed                 []string                                `json:"removed,omitempty"`
	ClosedAdapters          int64                                   `json:"closedAdapters,omitempty"`
	UnhealthyAdapters       int64                                   `json:"unhealthyAdapters,omitempty"`
	PoolExhaustions         int64                                   `json:"poolExhaustions,omitempty"`
	DialFailures            int64                                   `json:"dialFailures,omitempty"`
	EndpointEjections       int64                                   `json:"endpointEjections,omitempty"`
	EndpointRecoveries      int64                                   `json:"endpointRecoveries,omitempty"`
	OpenRetries             int64                                   `json:"openRetries,omitempty"`
	LastRetriedFrom         string                                  `json:"lastRetriedFrom,omitempty"`
	LastRetriedTo           string                                  `json:"lastRetriedTo,omitempty"`
	RetryReasons            map[string]int64                        `json:"retryReasons,omitempty"`
	JanitorRuns             int64                                   `json:"janitorRuns,omitempty"`
	CloseReasons            map[string]int64                        `json:"closeReasons,omitempty"`
	DrainReasons            map[string]int64                        `json:"drainReasons,omitempty"`
	LastUpdated             time.Time                               `json:"lastUpdated,omitempty"`
}

type ExperimentalMuxEndpointHealthSnapshot

type ExperimentalMuxEndpointHealthSnapshot struct {
	Endpoint      string        `json:"endpoint"`
	Failures      int           `json:"failures,omitempty"`
	Ejected       bool          `json:"ejected,omitempty"`
	EjectedAt     time.Time     `json:"ejectedAt,omitempty"`
	Cooldown      time.Duration `json:"cooldown,omitempty"`
	CooldownUntil time.Time     `json:"cooldownUntil,omitempty"`
	Reason        string        `json:"reason,omitempty"`
	LastError     string        `json:"lastError,omitempty"`
}

type ExperimentalMuxEndpointSnapshot

type ExperimentalMuxEndpointSnapshot struct {
	Endpoint     string                         `json:"endpoint"`
	ConnectionID string                         `json:"connectionId,omitempty"`
	PoolSlot     int                            `json:"poolSlot,omitempty"`
	LastUsed     time.Time                      `json:"lastUsed,omitempty"`
	Retired      bool                           `json:"retired,omitempty"`
	Adapter      ExperimentalMuxAdapterSnapshot `json:"adapter"`
}

type ExperimentalMuxServer

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

func (*ExperimentalMuxServer) Addr

func (s *ExperimentalMuxServer) Addr() string

func (*ExperimentalMuxServer) DiagnosisSnapshot

func (s *ExperimentalMuxServer) DiagnosisSnapshot() RPCMuxTransportDiagnosis

func (*ExperimentalMuxServer) RuntimeComponentSnapshot

func (s *ExperimentalMuxServer) RuntimeComponentSnapshot(ctx context.Context) coreruntime.ComponentSnapshot

func (*ExperimentalMuxServer) Shutdown

func (s *ExperimentalMuxServer) Shutdown(ctx context.Context) error

func (*ExperimentalMuxServer) Start

func (s *ExperimentalMuxServer) Start() error

type ExperimentalMuxServerAdapter

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

ExperimentalMuxServerAdapter dispatches opt-in mux streams by method.

func NewExperimentalMuxServerAdapter

func NewExperimentalMuxServerAdapter(conn net.Conn, opts ...ExperimentalMuxTransportOption) *ExperimentalMuxServerAdapter

NewExperimentalMuxServerAdapter creates an opt-in mux server over conn.

func (*ExperimentalMuxServerAdapter) Close

Close closes the underlying mux transport.

func (*ExperimentalMuxServerAdapter) DiagnosisSnapshot

DiagnosisSnapshot returns server-side mux transport diagnosis.

func (*ExperimentalMuxServerAdapter) Drain

func (*ExperimentalMuxServerAdapter) RegisterStream

func (a *ExperimentalMuxServerAdapter) RegisterStream(method string, handler ExperimentalMuxStreamHandler) error

RegisterStream registers an opt-in mux stream handler.

func (*ExperimentalMuxServerAdapter) RuntimeComponentSnapshot

RuntimeComponentSnapshot returns an AI-readable runtime component snapshot.

func (*ExperimentalMuxServerAdapter) Serve

Serve accepts mux streams until ctx is canceled or the underlying transport closes.

func (*ExperimentalMuxServerAdapter) Snapshot

Snapshot returns server-side mux adapter state.

type ExperimentalMuxServerConfigurer

type ExperimentalMuxServerConfigurer func(*ExperimentalMuxServerAdapter) error

type ExperimentalMuxServerDiagnosisSource

type ExperimentalMuxServerDiagnosisSource interface {
	DiagnosisSnapshot() RPCMuxTransportDiagnosis
	RuntimeComponentSnapshot(context.Context) coreruntime.ComponentSnapshot
}

type ExperimentalMuxStream

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

ExperimentalMuxStream is a logical stream carried by ExperimentalMuxTransport.

func (*ExperimentalMuxStream) Cancel

func (s *ExperimentalMuxStream) Cancel(ctx context.Context, reason string) error

Cancel sends a cancel frame for the logical stream.

func (*ExperimentalMuxStream) Close

func (s *ExperimentalMuxStream) Close(ctx context.Context, reason string) error

Close sends a normal close frame for the logical stream.

func (*ExperimentalMuxStream) CloseSend

func (s *ExperimentalMuxStream) CloseSend(ctx context.Context, reason string) error

CloseSend half-closes the local sending direction while keeping receive open.

func (*ExperimentalMuxStream) CloseWithCode

func (s *ExperimentalMuxStream) CloseWithCode(ctx context.Context, code Code, reason string) error

CloseWithCode sends a terminal frame for the logical stream.

func (*ExperimentalMuxStream) ID

func (s *ExperimentalMuxStream) ID() uint64

ID returns the stream ID assigned by the mux transport.

func (*ExperimentalMuxStream) Receive

func (s *ExperimentalMuxStream) Receive(ctx context.Context) (Message, error)

Receive receives the next data message or terminal event for the stream.

func (*ExperimentalMuxStream) Send

Send sends a data message on the logical stream.

type ExperimentalMuxStreamHandler

type ExperimentalMuxStreamHandler func(context.Context, *ExperimentalMuxStream) error

ExperimentalMuxStreamHandler handles a stream accepted by the opt-in mux adapter.

type ExperimentalMuxTransport

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

ExperimentalMuxTransport is an isolated spike for stream multiplexing over a single net.Conn. It is not wired into the HTTP upgrade stream path.

func NewExperimentalMuxTransport

func NewExperimentalMuxTransport(conn net.Conn, opts ...ExperimentalMuxTransportOption) *ExperimentalMuxTransport

NewExperimentalMuxTransport creates an experimental mux transport over conn.

func (*ExperimentalMuxTransport) AcceptStream

AcceptStream waits for a peer-opened logical stream.

func (*ExperimentalMuxTransport) Close

func (t *ExperimentalMuxTransport) Close() error

Close closes the underlying transport and all active logical streams.

func (*ExperimentalMuxTransport) Drain

func (t *ExperimentalMuxTransport) Drain(ctx context.Context, reason string) error

Drain sends a GOAWAY-like control frame and rejects new streams while allowing active streams to finish.

func (*ExperimentalMuxTransport) OpenStream

OpenStream opens a local logical stream and announces it to the peer.

func (*ExperimentalMuxTransport) Snapshot

Snapshot returns a point-in-time mux transport state.

type ExperimentalMuxTransportOption

type ExperimentalMuxTransportOption func(*ExperimentalMuxTransport)

ExperimentalMuxTransportOption customizes ExperimentalMuxTransport.

func WithExperimentalMuxConnectionWindow

func WithExperimentalMuxConnectionWindow(size int) ExperimentalMuxTransportOption

WithExperimentalMuxConnectionWindow limits unconsumed data frames across the connection.

func WithExperimentalMuxCreditWaitTimeout

func WithExperimentalMuxCreditWaitTimeout(timeout time.Duration) ExperimentalMuxTransportOption

func WithExperimentalMuxFragmentWindowPolicyRiskMode

func WithExperimentalMuxFragmentWindowPolicyRiskMode(mode string) ExperimentalMuxTransportOption

func WithExperimentalMuxFragmentWindowRefillPolicy

func WithExperimentalMuxFragmentWindowRefillPolicy(streamRatio float64, connectionRatio float64, maxDeferredFragments int) ExperimentalMuxTransportOption

func WithExperimentalMuxFragmentWindowUpdatePolicy

func WithExperimentalMuxFragmentWindowUpdatePolicy(streamPolicy string, connectionPolicy string) ExperimentalMuxTransportOption

func WithExperimentalMuxFrameCodec

func WithExperimentalMuxFrameCodec(codec FrameCodec) ExperimentalMuxTransportOption

WithExperimentalMuxFrameCodec sets the message codec for data frames.

func WithExperimentalMuxKeepalive

func WithExperimentalMuxKeepalive(interval, idle time.Duration) ExperimentalMuxTransportOption

WithExperimentalMuxKeepalive enables connection-level ping/pong liveness.

func WithExperimentalMuxMaxConcurrentStreams

func WithExperimentalMuxMaxConcurrentStreams(max int) ExperimentalMuxTransportOption

WithExperimentalMuxMaxConcurrentStreams limits active logical streams per connection.

func WithExperimentalMuxMaxFrameBytes

func WithExperimentalMuxMaxFrameBytes(max int64) ExperimentalMuxTransportOption

WithExperimentalMuxMaxFrameBytes sets the maximum encoded mux frame size.

func WithExperimentalMuxMaxMessageBytes

func WithExperimentalMuxMaxMessageBytes(max int64) ExperimentalMuxTransportOption

WithExperimentalMuxMaxMessageBytes caps reassembled logical messages.

func WithExperimentalMuxPayloadCodec

func WithExperimentalMuxPayloadCodec(codec PayloadCodec) ExperimentalMuxTransportOption

WithExperimentalMuxPayloadCodec sets the payload codec for data frames.

func WithExperimentalMuxReceiveQueueSize

func WithExperimentalMuxReceiveQueueSize(size int) ExperimentalMuxTransportOption

WithExperimentalMuxReceiveQueueSize sets the per-stream inbound queue size.

func WithExperimentalMuxServerRole

func WithExperimentalMuxServerRole() ExperimentalMuxTransportOption

WithExperimentalMuxServerRole makes locally opened stream IDs even.

func WithExperimentalMuxWriteTimeout

func WithExperimentalMuxWriteTimeout(timeout time.Duration) ExperimentalMuxTransportOption

type ExperimentalMuxTransportSnapshot

type ExperimentalMuxTransportSnapshot struct {
	Role                                    string        `json:"role,omitempty"`
	ActiveStreams                           int           `json:"activeStreams"`
	OpenedStreams                           int64         `json:"openedStreams,omitempty"`
	AcceptedStreams                         int64         `json:"acceptedStreams,omitempty"`
	ClosedStreams                           int64         `json:"closedStreams,omitempty"`
	CanceledStreams                         int64         `json:"canceledStreams,omitempty"`
	FramesIn                                int64         `json:"framesIn,omitempty"`
	FramesOut                               int64         `json:"framesOut,omitempty"`
	DataFramesIn                            int64         `json:"dataFramesIn,omitempty"`
	DataFramesOut                           int64         `json:"dataFramesOut,omitempty"`
	OpenFramesIn                            int64         `json:"openFramesIn,omitempty"`
	OpenFramesOut                           int64         `json:"openFramesOut,omitempty"`
	CloseFramesIn                           int64         `json:"closeFramesIn,omitempty"`
	CloseFramesOut                          int64         `json:"closeFramesOut,omitempty"`
	CancelFramesIn                          int64         `json:"cancelFramesIn,omitempty"`
	CancelFramesOut                         int64         `json:"cancelFramesOut,omitempty"`
	WindowFramesIn                          int64         `json:"windowFramesIn,omitempty"`
	WindowFramesOut                         int64         `json:"windowFramesOut,omitempty"`
	ConnectionWindowFramesIn                int64         `json:"connectionWindowFramesIn,omitempty"`
	ConnectionWindowFramesOut               int64         `json:"connectionWindowFramesOut,omitempty"`
	FinFramesIn                             int64         `json:"finFramesIn,omitempty"`
	FinFramesOut                            int64         `json:"finFramesOut,omitempty"`
	PingFramesIn                            int64         `json:"pingFramesIn,omitempty"`
	PingFramesOut                           int64         `json:"pingFramesOut,omitempty"`
	PongFramesIn                            int64         `json:"pongFramesIn,omitempty"`
	PongFramesOut                           int64         `json:"pongFramesOut,omitempty"`
	GoAwayFramesIn                          int64         `json:"goAwayFramesIn,omitempty"`
	GoAwayFramesOut                         int64         `json:"goAwayFramesOut,omitempty"`
	BytesIn                                 int64         `json:"bytesIn,omitempty"`
	BytesOut                                int64         `json:"bytesOut,omitempty"`
	FragmentFramesIn                        int64         `json:"fragmentFramesIn,omitempty"`
	FragmentFramesOut                       int64         `json:"fragmentFramesOut,omitempty"`
	HalfClosedStreams                       int64         `json:"halfClosedStreams,omitempty"`
	BackpressureEvents                      int64         `json:"backpressureEvents,omitempty"`
	CreditWaits                             int64         `json:"creditWaits,omitempty"`
	ConnectionCreditWaits                   int64         `json:"connectionCreditWaits,omitempty"`
	CreditWaitTimeouts                      int64         `json:"creditWaitTimeouts,omitempty"`
	WriteTimeouts                           int64         `json:"writeTimeouts,omitempty"`
	ConnectionWindowExhausted               int64         `json:"connectionWindowExhausted,omitempty"`
	FragmentStreamWindowUpdatePolicy        string        `json:"fragmentStreamWindowUpdatePolicy,omitempty"`
	FragmentConnectionWindowUpdatePolicy    string        `json:"fragmentConnectionWindowUpdatePolicy,omitempty"`
	FragmentStreamWindowRefillRatio         float64       `json:"fragmentStreamWindowRefillRatio,omitempty"`
	FragmentConnectionWindowRefillRatio     float64       `json:"fragmentConnectionWindowRefillRatio,omitempty"`
	FragmentMaxDeferredFragments            int           `json:"fragmentMaxDeferredFragments,omitempty"`
	FragmentWindowRefills                   int64         `json:"fragmentWindowRefills,omitempty"`
	FragmentWindowRefillLatencyTotal        time.Duration `json:"fragmentWindowRefillLatencyTotal,omitempty"`
	FragmentWindowRefillLatencyMax          time.Duration `json:"fragmentWindowRefillLatencyMax,omitempty"`
	FragmentWindowRefillLatencyAvg          time.Duration `json:"fragmentWindowRefillLatencyAvg,omitempty"`
	FragmentDeferredStreamWindowUpdates     int64         `json:"fragmentDeferredStreamWindowUpdates,omitempty"`
	FragmentDeferredConnectionWindowUpdates int64         `json:"fragmentDeferredConnectionWindowUpdates,omitempty"`
	FragmentWindowPolicyRisk                bool          `json:"fragmentWindowPolicyRisk,omitempty"`
	FragmentWindowPolicyRiskReason          string        `json:"fragmentWindowPolicyRiskReason,omitempty"`
	FragmentWindowPolicyRiskMode            string        `json:"fragmentWindowPolicyRiskMode,omitempty"`
	FragmentEstimatedMaxFragments           int           `json:"fragmentEstimatedMaxFragments,omitempty"`
	LastFlowControlEvent                    string        `json:"lastFlowControlEvent,omitempty"`
	LastFlowControlEventAt                  time.Time     `json:"lastFlowControlEventAt,omitempty"`
	LastBackpressureEvent                   string        `json:"lastBackpressureEvent,omitempty"`
	LastBackpressureEventAt                 time.Time     `json:"lastBackpressureEventAt,omitempty"`
	IdleTimeouts                            int64         `json:"idleTimeouts,omitempty"`
	LocalRejects                            int64         `json:"localRejects,omitempty"`
	RemoteRejects                           int64         `json:"remoteRejects,omitempty"`
	DrainRejects                            int64         `json:"drainRejects,omitempty"`
	ReceiveQueueSize                        int           `json:"receiveQueueSize,omitempty"`
	ConnectionWindow                        int           `json:"connectionWindow,omitempty"`
	MaxFrameBytes                           int64         `json:"maxFrameBytes,omitempty"`
	MaxMessageBytes                         int64         `json:"maxMessageBytes,omitempty"`
	MaxStreams                              int           `json:"maxStreams,omitempty"`
	KeepaliveInterval                       time.Duration `json:"keepaliveInterval,omitempty"`
	KeepaliveIdle                           time.Duration `json:"keepaliveIdle,omitempty"`
	WriteTimeout                            time.Duration `json:"writeTimeout,omitempty"`
	CreditWaitTimeout                       time.Duration `json:"creditWaitTimeout,omitempty"`
	LastFrameReadAt                         time.Time     `json:"lastFrameReadAt,omitempty"`
	LastFrameWrittenAt                      time.Time     `json:"lastFrameWrittenAt,omitempty"`
	LastPingAt                              time.Time     `json:"lastPingAt,omitempty"`
	LastPongAt                              time.Time     `json:"lastPongAt,omitempty"`
	Liveness                                string        `json:"liveness,omitempty"`
	Draining                                bool          `json:"draining,omitempty"`
	RemoteDraining                          bool          `json:"remoteDraining,omitempty"`
	DrainReason                             string        `json:"drainReason,omitempty"`
	RemoteDrainReason                       string        `json:"remoteDrainReason,omitempty"`
	LastStreamID                            uint64        `json:"lastStreamID,omitempty"`
	LastCloseCode                           Code          `json:"lastCloseCode,omitempty"`
	LastCloseReason                         string        `json:"lastCloseReason,omitempty"`
	Closed                                  bool          `json:"closed"`
}

ExperimentalMuxTransportSnapshot reports observable mux transport state.

type FailoverResolver

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

FailoverResolver wraps another resolver and serves the last successful endpoint set while the source registry is temporarily unavailable.

func NewFailoverResolver

func NewFailoverResolver(source Resolver, seed ...string) (*FailoverResolver, error)

func (*FailoverResolver) Resolve

func (r *FailoverResolver) Resolve(ctx context.Context) ([]string, error)

func (*FailoverResolver) Snapshot

func (r *FailoverResolver) Snapshot() ResolverSnapshot

func (*FailoverResolver) Watch

func (r *FailoverResolver) Watch(ctx context.Context) (<-chan []string, error)

type FrameCodec

type FrameCodec interface {
	Name() string
	Marshal(Message) ([]byte, error)
	Unmarshal([]byte) (Message, error)
}

type FramedTransport

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

func DialFramed

func DialFramed(ctx context.Context, network, address string, timeout time.Duration, opts ...FramedTransportOption) (*FramedTransport, error)

func NewFramedTransport

func NewFramedTransport(conn net.Conn, opts ...FramedTransportOption) *FramedTransport

func (*FramedTransport) Close

func (t *FramedTransport) Close() error

func (*FramedTransport) Receive

func (t *FramedTransport) Receive(ctx context.Context) (Message, error)

func (*FramedTransport) Send

func (t *FramedTransport) Send(ctx context.Context, msg Message) error

func (*FramedTransport) Snapshot

func (t *FramedTransport) Snapshot() TransportStats

type FramedTransportOption

type FramedTransportOption func(*FramedTransport)

func WithBinaryFrames

func WithBinaryFrames() FramedTransportOption

func WithFrameCodec

func WithFrameCodec(codec FrameCodec) FramedTransportOption

func WithMaxFrameBytes

func WithMaxFrameBytes(max int64) FramedTransportOption

func WithPayloadCodec

func WithPayloadCodec(codec PayloadCodec) FramedTransportOption

type GenericClient

type GenericClient interface {
	CallRaw(ctx context.Context, method string, request any) (json.RawMessage, metadata.MD, error)
}

GenericClient is a Client that returns raw JSON responses.

type GenericHandler

type GenericHandler func(context.Context, json.RawMessage) (any, error)

type GenericInvoker

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

func NewGenericInvoker

func NewGenericInvoker(client GenericClient) (*GenericInvoker, error)

func (*GenericInvoker) Invoke

func (g *GenericInvoker) Invoke(ctx context.Context, service string, method string, request any) (GenericResponse, error)

func (*GenericInvoker) InvokeMethod

func (g *GenericInvoker) InvokeMethod(ctx context.Context, desc ServiceDesc, method string, request any) (GenericResponse, error)

type GenericResponse

type GenericResponse struct {
	Payload  json.RawMessage `json:"payload,omitempty"`
	Metadata metadata.MD     `json:"metadata,omitempty"`
}

type GovernanceConfig

type GovernanceConfig struct {
	Recover        bool
	RequestID      bool
	Trace          bool
	Log            bool
	Metrics        bool
	Timeout        time.Duration
	TimeoutConfig  RPCTimeoutConfig
	Breaker        bool
	MaxConcurrency int
	AdaptiveLimit  bool
	ServerAdaptive *limit.AdaptiveLimiter
	ClientAdaptive *limit.AdaptiveLimiter
	ServerBreaker  *breaker.AdaptiveBreaker
	ClientBreaker  *breaker.AdaptiveBreaker
	TraceSampler   trace.Sampler
	LogSampler     trace.Sampler
	ServerAuth     auth.Validator
	ClientToken    string
}

func DefaultGovernanceConfig

func DefaultGovernanceConfig(timeout time.Duration) GovernanceConfig

type GovernanceSnapshot

type GovernanceSnapshot struct {
	Components []governance.ComponentSnapshot `json:"components"`
}

type GzipPayloadCodec

type GzipPayloadCodec struct{}

func (GzipPayloadCodec) Decode

func (GzipPayloadCodec) Decode(data []byte) ([]byte, error)

func (GzipPayloadCodec) Encode

func (GzipPayloadCodec) Encode(data []byte) ([]byte, error)

func (GzipPayloadCodec) Name

func (GzipPayloadCodec) Name() string

type HTTPBinding

type HTTPBinding struct {
	Method       string `json:"method,omitempty"`
	Path         string `json:"path,omitempty"`
	Body         string `json:"body,omitempty"`
	ResponseBody string `json:"responseBody,omitempty"`
}

func (HTTPBinding) Empty

func (b HTTPBinding) Empty() bool

type HTTPClient

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

func NewClient

func NewClient(target string, opts ...ClientOption) (*HTTPClient, error)

func (*HTTPClient) Call

func (c *HTTPClient) Call(ctx context.Context, method string, request any, response any) error

func (*HTTPClient) CallRaw

func (c *HTTPClient) CallRaw(ctx context.Context, method string, request any) (json.RawMessage, metadata.MD, error)

func (*HTTPClient) CallWithMetadata

func (c *HTTPClient) CallWithMetadata(ctx context.Context, method string, request any, response any) (metadata.MD, error)

func (*HTTPClient) Close

func (c *HTTPClient) Close() error

Close releases background resolver watches and idle HTTP transport resources.

func (*HTTPClient) DiagnosisHandler

func (c *HTTPClient) DiagnosisHandler() http.Handler

func (*HTTPClient) DiagnosisProbe

func (c *HTTPClient) DiagnosisProbe(ctx context.Context, service string, method string, endpoint string) RPCDiagnosisProbe

func (*HTTPClient) DiagnosisProbeWithOptions

func (c *HTTPClient) DiagnosisProbeWithOptions(ctx context.Context, opts RPCDiagnosisProbeOptions) RPCDiagnosisProbe

func (*HTTPClient) EffectivePolicySnapshot

func (c *HTTPClient) EffectivePolicySnapshot(ctx context.Context, method string) RPCEffectivePolicySnapshot

func (*HTTPClient) MuxStream

func (c *HTTPClient) MuxStream(ctx context.Context, method string) (*ExperimentalMuxStream, error)

MuxStream opens an experimental multiplexed stream when the client was explicitly configured with WithExperimentalMuxClientAdapter.

func (*HTTPClient) ObserveMuxDiagnosis

func (c *HTTPClient) ObserveMuxDiagnosis(ctx context.Context, probe RPCDiagnosisProbe)

ObserveMuxDiagnosis applies the client's configured mux trace, log, and event-export hooks to an already captured diagnosis probe. It is useful for admin or generated-project smoke paths that query /rpc/diagnosis after a stream operation and want the same opt-in observability contract as MuxStream.

func (*HTTPClient) PolicyRuntimeSnapshot

func (c *HTTPClient) PolicyRuntimeSnapshot() RPCPolicyRuntimeSnapshot

func (*HTTPClient) RuntimeComponentSnapshot

func (c *HTTPClient) RuntimeComponentSnapshot(ctx context.Context) coreruntime.ComponentSnapshot

func (*HTTPClient) RuntimeSnapshot

func (c *HTTPClient) RuntimeSnapshot() RPCRuntimeSnapshot

func (*HTTPClient) ServeDiagnosis

func (c *HTTPClient) ServeDiagnosis(w http.ResponseWriter, r *http.Request)

func (*HTTPClient) Stream

func (c *HTTPClient) Stream(ctx context.Context, method string) (*Stream, error)

func (*HTTPClient) UpdateMuxDiagnosisEventExporter

func (c *HTTPClient) UpdateMuxDiagnosisEventExporter(exporter RPCMuxDiagnosisEventExporter, filter RPCMuxDiagnosisFilter)

UpdateMuxDiagnosisEventExporter swaps the client-side mux diagnosis exporter and filter for config hot-reload paths. The caller owns the exporter lifecycle, so this method does not close the previous exporter.

type HTTPServer

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

HTTPServer is an HTTP-based RPC server with governance and service registration.

func NewServer

func NewServer(opts ...ServerOption) *HTTPServer

NewServer creates an HTTPServer with the given options.

Example

ExampleNewServer demonstrates creating an RPC server, registering a service, and inspecting the registered method descriptors.

package main

import (
	"context"
	"fmt"

	"github.com/imajinyun/gofly/rpc"
)

func main() {
	greetHandler := rpc.Handler(func(ctx context.Context, req any) (any, error) {
		return map[string]string{"reply": "hello " + req.(string)}, nil
	})

	desc := rpc.ServiceDesc{
		Name:    "Greeter",
		Version: "1.0.0",
		Methods: []rpc.MethodDesc{
			{
				Name:    "SayHello",
				Handler: greetHandler,
				NewRequest: func() any {
					return ""
				},
				Request: "string",
			},
		},
	}

	srv := rpc.NewServer(rpc.WithAddress(":9090"))
	if err := srv.RegisterService(desc, nil); err != nil {
		fmt.Println("register error:", err)
		return
	}

	infos := srv.GetServiceInfos()
	for name := range infos {
		fmt.Println(name)
	}
}
Output:
Greeter

func (*HTTPServer) DiagnosisProbe

func (s *HTTPServer) DiagnosisProbe(service string, method string) ServerDiagnosisSnapshot

func (*HTTPServer) DiagnosisProbeWithOptions

func (s *HTTPServer) DiagnosisProbeWithOptions(opts RPCDiagnosisProbeOptions) ServerDiagnosisSnapshot

func (*HTTPServer) DiagnosisSnapshot

func (s *HTTPServer) DiagnosisSnapshot() ServerDiagnosisSnapshot

func (*HTTPServer) GetServiceDescriptor

func (s *HTTPServer) GetServiceDescriptor(name string) (Descriptor, bool)

GetServiceDescriptor returns the descriptor for a named service.

func (*HTTPServer) GetServiceDescriptors

func (s *HTTPServer) GetServiceDescriptors() map[string]Descriptor

GetServiceDescriptors returns descriptors for all registered services.

func (*HTTPServer) GetServiceInfos

func (s *HTTPServer) GetServiceInfos() map[string]ServiceDesc

GetServiceInfos returns a snapshot of registered service descriptors.

func (*HTTPServer) Governance

func (s *HTTPServer) Governance() GovernanceSnapshot

func (*HTTPServer) MuxDiagnosisOperatorActionHistory

func (s *HTTPServer) MuxDiagnosisOperatorActionHistory(limit int) []RPCMuxDiagnosisOperatorAction

MuxDiagnosisOperatorActionHistory returns approved mux sink operator actions from the bounded in-memory history.

func (*HTTPServer) MuxDiagnosisOperatorActionHistorySnapshot

func (s *HTTPServer) MuxDiagnosisOperatorActionHistorySnapshot(limit int) RPCMuxDiagnosisOperatorHistorySnapshot

func (*HTTPServer) MuxDiagnosisOperatorActions

func (s *HTTPServer) MuxDiagnosisOperatorActions(ctx context.Context) []RPCMuxDiagnosisOperatorAction

MuxDiagnosisOperatorActions returns dry-run mux sink operator actions for admin and control-plane views.

func (*HTTPServer) MuxDiagnosisOperatorHistoryIntegritySnapshot

func (s *HTTPServer) MuxDiagnosisOperatorHistoryIntegritySnapshot(ctx context.Context) (RPCMuxDiagnosisOperatorHistoryIntegritySnapshot, error)

MuxDiagnosisOperatorHistoryIntegritySnapshot returns redacted, read-only operator history integrity evidence from the active mux exporter.

func (*HTTPServer) ObserveMuxDiagnosis

func (s *HTTPServer) ObserveMuxDiagnosis(ctx context.Context, snapshot ServerDiagnosisSnapshot)

ObserveMuxDiagnosis exports a captured server diagnosis snapshot through the configured server-side mux diagnosis exporter.

func (*HTTPServer) RegisterService

func (s *HTTPServer) RegisterService(desc ServiceDesc, impl any) error

RegisterService registers a service descriptor and its implementation.

func (*HTTPServer) Run

func (s *HTTPServer) Run() error

Run listens on the configured address and serves RPC over HTTP.

func (*HTTPServer) RuntimeCacheSnapshot

func (s *HTTPServer) RuntimeCacheSnapshot() RPCPolicyRuntimeCacheSnapshot

func (*HTTPServer) RuntimeSnapshot

func (s *HTTPServer) RuntimeSnapshot(ctx context.Context) coreruntime.Snapshot

func (*HTTPServer) ServeHTTP

func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler and dispatches RPC, stream, and admin requests.

func (*HTTPServer) ServiceSnapshots

func (s *HTTPServer) ServiceSnapshots() []ServiceSnapshot

func (*HTTPServer) Shutdown

func (s *HTTPServer) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server. It is an alias for Stop.

func (*HTTPServer) Start

func (s *HTTPServer) Start() error

Start begins serving RPC requests. It is an alias for Run.

func (*HTTPServer) State

func (s *HTTPServer) State() StateSnapshot

func (*HTTPServer) Stop

func (s *HTTPServer) Stop(ctx context.Context) error

Stop shuts down the server gracefully.

func (*HTTPServer) UpdateMuxDiagnosisEventExporter

func (s *HTTPServer) UpdateMuxDiagnosisEventExporter(exporter RPCMuxDiagnosisEventExporter, filter RPCMuxDiagnosisFilter)

UpdateMuxDiagnosisEventExporter swaps the server-side mux diagnosis exporter and filter for config hot-reload paths. The caller owns the exporter lifecycle, so this method does not close the previous exporter.

type Handler

type Handler func(ctx context.Context, req any) (any, error)

Handler is an RPC method handler.

type HealthBalancer

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

HealthBalancer tracks endpoint health and ejects unhealthy endpoints.

func NewHealthBalancer

func NewHealthBalancer(opts ...HealthBalancerOption) *HealthBalancer

func (*HealthBalancer) Pick

func (b *HealthBalancer) Pick(ctx context.Context, endpoints []string) (string, error)

func (*HealthBalancer) Report

func (b *HealthBalancer) Report(ctx context.Context, endpoint string, err error)

type HealthBalancerOption

type HealthBalancerOption func(*HealthBalancer)

HealthBalancerOption customises HealthBalancer.

func WithHealthEjectionDuration

func WithHealthEjectionDuration(d time.Duration) HealthBalancerOption

func WithHealthFailureThreshold

func WithHealthFailureThreshold(n int) HealthBalancerOption

type HealthSnapshot

type HealthSnapshot struct {
	Status   string            `json:"status"`
	State    StateSnapshot     `json:"state"`
	Services []ServiceSnapshot `json:"services"`
}

type InstanceResolver

type InstanceResolver interface {
	ResolveInstances(ctx context.Context) ([]ServiceInstance, error)
}

type JSONCodec

type JSONCodec struct{}

JSONCodec marshals values as JSON.

func (JSONCodec) Marshal

func (JSONCodec) Marshal(v any) ([]byte, error)

Marshal encodes v as JSON.

func (JSONCodec) Name

func (JSONCodec) Name() string

Name returns "json".

func (JSONCodec) Unmarshal

func (JSONCodec) Unmarshal(data []byte, v any) error

Unmarshal decodes JSON into v.

type JSONFrameCodec

type JSONFrameCodec struct{}

func (JSONFrameCodec) Marshal

func (JSONFrameCodec) Marshal(msg Message) ([]byte, error)

func (JSONFrameCodec) Name

func (JSONFrameCodec) Name() string

func (JSONFrameCodec) Unmarshal

func (JSONFrameCodec) Unmarshal(data []byte) (Message, error)

type KitexEndpoint

type KitexEndpoint = endpoint.Endpoint

type KitexInterceptor

type KitexInterceptor func(context.Context, any, KitexEndpoint) (any, error)

func KitexObservabilityInterceptor

func KitexObservabilityInterceptor(name string, reg *metrics.Registry, logger *slog.Logger) KitexInterceptor

type KitexMiddleware

type KitexMiddleware = endpoint.Middleware

func KitexEndpointChain

func KitexEndpointChain(middlewares ...KitexMiddleware) KitexMiddleware

func KitexInterceptorMiddleware

func KitexInterceptorMiddleware(interceptors ...KitexInterceptor) KitexMiddleware

type KubernetesResolver

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

func NewKubernetesResolver

func NewKubernetesResolver(conf KubernetesResolverConfig) (*KubernetesResolver, error)

func (*KubernetesResolver) Resolve

func (r *KubernetesResolver) Resolve(ctx context.Context) ([]string, error)

func (*KubernetesResolver) ResolveInstances

func (r *KubernetesResolver) ResolveInstances(ctx context.Context) ([]ServiceInstance, error)

func (*KubernetesResolver) Watch

func (r *KubernetesResolver) Watch(ctx context.Context) (<-chan []string, error)

Watch polls the Kubernetes API at WatchInterval and emits the current endpoint set whenever it changes. It satisfies WatchResolver so it can back a CachedResolver.

type KubernetesResolverConfig

type KubernetesResolverConfig struct {
	BaseURL   string
	Namespace string
	Service   string
	Scheme    string
	Port      int
	// PortName selects a named endpoint port when set, taking precedence over
	// Port. Useful when a service exposes multiple ports (e.g. "grpc", "http").
	PortName string
	Token    string
	Client   *http.Client
	// IncludeNotReady includes addresses from the endpoints' notReadyAddresses
	// list. By default only ready addresses are returned.
	IncludeNotReady bool
	// WatchInterval is the polling interval used by Watch. Defaults to 5s.
	WatchInterval time.Duration
}

type Message

type Message struct {
	Service string      `json:"service,omitempty"`
	Method  string      `json:"method,omitempty"`
	Codec   string      `json:"codec,omitempty"`
	Payload []byte      `json:"payload,omitempty"`
	Meta    metadata.MD `json:"metadata,omitempty"`
	Code    Code        `json:"code,omitempty"`
	Error   string      `json:"error,omitempty"`
}

type MessageHandler

type MessageHandler func(context.Context, Message) (Message, error)

type MessageMiddleware

type MessageMiddleware func(MessageHandler) MessageHandler

func ChainMessageMiddleware

func ChainMessageMiddleware(mws ...MessageMiddleware) MessageMiddleware

type MetadataClient

type MetadataClient interface {
	Client
	CallWithMetadata(ctx context.Context, method string, request any, response any) (metadata.MD, error)
}

MetadataClient is a Client that also returns response metadata.

type MethodDesc

type MethodDesc struct {
	Name        string
	Handler     Handler
	NewRequest  func() any
	Request     string
	Response    string
	Codec       string
	HTTP        HTTPBinding
	Timeout     time.Duration
	Metadata    map[string]string
	Middlewares []endpoint.Middleware
}

MethodDesc describes a single RPC method.

func GenericMethod

func GenericMethod(name string, handler GenericHandler) MethodDesc

type MethodDescriptor

type MethodDescriptor struct {
	Name     string            `json:"name"`
	Timeout  time.Duration     `json:"timeout,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
	Request  string            `json:"request,omitempty"`
	Response string            `json:"response,omitempty"`
	Codec    string            `json:"codec,omitempty"`
	HTTP     *HTTPBinding      `json:"http,omitempty"`
}

MethodDescriptor is a JSON-friendly method descriptor.

type MethodSnapshot

type MethodSnapshot struct {
	Name        string            `json:"name"`
	Request     string            `json:"request,omitempty"`
	Response    string            `json:"response,omitempty"`
	Timeout     string            `json:"timeout,omitempty"`
	Metadata    map[string]string `json:"metadata,omitempty"`
	Middlewares int               `json:"middlewares,omitempty"`
}

MethodSnapshot captures the metadata for a single RPC method.

type NoopPayloadCodec

type NoopPayloadCodec struct{}

func (NoopPayloadCodec) Decode

func (NoopPayloadCodec) Decode(data []byte) ([]byte, error)

func (NoopPayloadCodec) Encode

func (NoopPayloadCodec) Encode(data []byte) ([]byte, error)

func (NoopPayloadCodec) Name

func (NoopPayloadCodec) Name() string

type P2CBalancer

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

func NewP2CBalancer

func NewP2CBalancer() *P2CBalancer

func (*P2CBalancer) Pick

func (b *P2CBalancer) Pick(ctx context.Context, endpoints []string) (string, error)

func (*P2CBalancer) Report

func (b *P2CBalancer) Report(ctx context.Context, endpoint string, err error)

type P2CEWMABalancer

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

P2CEWMABalancer implements "Power of Two Choices" load balancing with an EWMA (exponentially weighted moving average) of per-endpoint latency. For each pick it samples two random endpoints and routes to the one with the lower load, where load combines decayed average latency with the number of in-flight requests:

load = ewmaLatency * (inflight + 1)

This steers traffic away from slow or saturated nodes far more responsively than round-robin or active-count-only P2C.

func NewP2CEWMABalancer

func NewP2CEWMABalancer(opts ...P2CEWMAOption) *P2CEWMABalancer

NewP2CEWMABalancer creates a P2C balancer with EWMA latency scoring.

func (*P2CEWMABalancer) Pick

func (b *P2CEWMABalancer) Pick(ctx context.Context, endpoints []string) (string, error)

Pick selects an endpoint using the power-of-two-choices rule scored by EWMA latency and in-flight load.

func (*P2CEWMABalancer) Report

func (b *P2CEWMABalancer) Report(ctx context.Context, endpoint string, err error)

Report records the outcome of a request to endpoint, updating its EWMA latency from the time elapsed since the matching Pick and decrementing the in-flight counter. It satisfies EndpointReporter.

type P2CEWMAOption

type P2CEWMAOption func(*P2CEWMABalancer)

P2CEWMAOption configures a P2CEWMABalancer.

func WithEWMADecay

func WithEWMADecay(d time.Duration) P2CEWMAOption

WithEWMADecay sets the decay constant (tau) controlling how quickly old latency samples lose weight. Larger values smooth more; smaller values react faster. Defaults to 600ms.

type PayloadCodec

type PayloadCodec interface {
	Name() string
	Encode([]byte) ([]byte, error)
	Decode([]byte) ([]byte, error)
}

type PooledConn

type PooledConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func (*PooledConn) Close

func (c *PooledConn) Close() error

func (*PooledConn) Discard

func (c *PooledConn) Discard() error

func (*PooledConn) Transport

func (c *PooledConn) Transport(opts ...FramedTransportOption) *FramedTransport

type ProtoCodec

type ProtoCodec struct{}

ProtoCodec marshals values as Protocol Buffers.

func (ProtoCodec) Marshal

func (ProtoCodec) Marshal(v any) ([]byte, error)

Marshal encodes v as protobuf.

func (ProtoCodec) Name

func (ProtoCodec) Name() string

Name returns "proto".

func (ProtoCodec) Unmarshal

func (ProtoCodec) Unmarshal(data []byte, v any) error

Unmarshal decodes protobuf into v.

type RPCBalancerDiagnosisSnapshot

type RPCBalancerDiagnosisSnapshot struct {
	Name string `json:"name,omitempty"`
}

type RPCBalancerPolicy

type RPCBalancerPolicy struct {
	Name    string         `json:"name,omitempty"`
	Weights map[string]int `json:"weights,omitempty"`
	Key     string         `json:"key,omitempty"`
}

type RPCDiagnosisProbe

type RPCDiagnosisProbe struct {
	Target       string                      `json:"target,omitempty"`
	Service      string                      `json:"service,omitempty"`
	Method       string                      `json:"method,omitempty"`
	Endpoint     string                      `json:"endpoint,omitempty"`
	ConnectionID string                      `json:"connectionId,omitempty"`
	PoolSlot     int                         `json:"poolSlot,omitempty"`
	FlowControl  string                      `json:"flowControl,omitempty"`
	EventFamily  string                      `json:"eventFamily,omitempty"`
	Event        string                      `json:"event,omitempty"`
	Matched      bool                        `json:"matched"`
	Diagnosis    RPCDiagnosisSnapshot        `json:"diagnosis"`
	Policy       RPCEffectivePolicySnapshot  `json:"policy,omitempty"`
	Discovery    RPCDiscoveryRuntimeSnapshot `json:"discovery,omitempty"`
	GeneratedAt  time.Time                   `json:"generatedAt"`
}

type RPCDiagnosisProbeOptions

type RPCDiagnosisProbeOptions struct {
	Service          string
	Method           string
	Endpoint         string
	ConnectionID     string
	PoolSlot         int
	FlowControlEvent string
	EventFamily      string
	Event            string
}

type RPCDiagnosisSnapshot

type RPCDiagnosisSnapshot struct {
	Transport RPCHTTPTransportSnapshot     `json:"transport,omitempty"`
	Mux       RPCMuxTransportDiagnosis     `json:"mux,omitempty"`
	ConnPool  ConnPoolManagerSnapshot      `json:"connPool,omitempty"`
	Retry     RPCRetryDiagnosisSnapshot    `json:"retry,omitempty"`
	Resolver  RPCResolverRuntimeSnapshot   `json:"resolver,omitempty"`
	Balancer  RPCBalancerDiagnosisSnapshot `json:"balancer,omitempty"`
}

type RPCDiscoveryRuntimeSnapshot

type RPCDiscoveryRuntimeSnapshot struct {
	WatchEnabled   bool      `json:"watchEnabled"`
	Updates        int64     `json:"updates,omitempty"`
	LastUpdated    time.Time `json:"lastUpdated,omitempty"`
	Endpoints      []string  `json:"endpoints,omitempty"`
	Added          []string  `json:"added,omitempty"`
	Removed        []string  `json:"removed,omitempty"`
	Updated        []string  `json:"updated,omitempty"`
	CloseIdleCalls int64     `json:"closeIdleCalls,omitempty"`
	WatchError     string    `json:"watchError,omitempty"`
}

type RPCEffectivePolicySnapshot

type RPCEffectivePolicySnapshot struct {
	Method         string                `json:"method,omitempty"`
	MethodKey      string                `json:"methodKey,omitempty"`
	Policy         RPCPolicy             `json:"policy"`
	State          RPCPolicyRuntimeState `json:"state"`
	Priority       []string              `json:"priority,omitempty"`
	GovernanceRule string                `json:"governanceRule,omitempty"`
}

type RPCEndpointChainSnapshot

type RPCEndpointChainSnapshot struct {
	Unary  int `json:"unary,omitempty"`
	Stream int `json:"stream,omitempty"`
}

type RPCFallbackPolicy

type RPCFallbackPolicy struct {
	Enabled bool   `json:"enabled,omitempty"`
	Target  string `json:"target,omitempty"`
	Method  string `json:"method,omitempty"`
}

type RPCHTTPTransportSnapshot

type RPCHTTPTransportSnapshot struct {
	Timeout             time.Duration               `json:"timeout,omitempty"`
	DialTimeout         time.Duration               `json:"dialTimeout,omitempty"`
	KeepAlive           time.Duration               `json:"keepAlive,omitempty"`
	IdleConnTimeout     time.Duration               `json:"idleConnTimeout,omitempty"`
	StreamIdleTimeout   time.Duration               `json:"streamIdleTimeout,omitempty"`
	StreamConnPolicy    RPCStreamConnPolicySnapshot `json:"streamConnPolicy,omitempty"`
	CloseIdleOnEndpoint bool                        `json:"closeIdleOnEndpointChange"`
	Stream              RPCStreamTransportSnapshot  `json:"stream,omitempty"`
}

type RPCHedgePolicy

type RPCHedgePolicy struct {
	Enabled  bool          `json:"enabled,omitempty"`
	Delay    time.Duration `json:"delay,omitempty"`
	Attempts int           `json:"attempts,omitempty"`
}

type RPCLoadShedderPolicy

type RPCLoadShedderPolicy struct {
	Enabled        bool          `json:"enabled,omitempty"`
	MaxConcurrency int           `json:"maxConcurrency,omitempty"`
	MaxInflight    int           `json:"maxInflight,omitempty"`
	MinWindow      time.Duration `json:"minWindow,omitempty"`
}

type RPCMuxConnectionManagerDiagnosis

type RPCMuxConnectionManagerDiagnosis struct {
	Enabled                 bool                                    `json:"enabled"`
	Mode                    string                                  `json:"mode,omitempty"`
	Candidate               ExperimentalMuxCandidateSnapshot        `json:"candidate,omitempty"`
	FlowControl             RPCMuxFlowControlDiagnosis              `json:"flowControl,omitempty"`
	RefillProfile           RPCMuxRefillProfile                     `json:"refillProfile,omitempty"`
	RefillProfiles          []RPCMuxRefillProfile                   `json:"refillProfiles,omitempty"`
	IdleTimeout             time.Duration                           `json:"idleTimeout,omitempty"`
	MaxStreamsPerConn       int                                     `json:"maxStreamsPerConn,omitempty"`
	MaxConnsPerEndpoint     int                                     `json:"maxConnsPerEndpoint,omitempty"`
	MaxIdleConnsPerEndpoint int                                     `json:"maxIdleConnsPerEndpoint,omitempty"`
	HealthFailureThreshold  int                                     `json:"healthFailureThreshold,omitempty"`
	HealthEjectionDuration  time.Duration                           `json:"healthEjectionDuration,omitempty"`
	HealthBackoffMultiplier int                                     `json:"healthBackoffMultiplier,omitempty"`
	HealthMaxCooldown       time.Duration                           `json:"healthMaxCooldown,omitempty"`
	MaxOpenRetries          int                                     `json:"maxOpenRetries,omitempty"`
	OpenRetryReasons        []string                                `json:"openRetryReasons,omitempty"`
	JanitorInterval         time.Duration                           `json:"janitorInterval,omitempty"`
	Endpoints               []ExperimentalMuxEndpointSnapshot       `json:"endpoints,omitempty"`
	Health                  []ExperimentalMuxEndpointHealthSnapshot `json:"health,omitempty"`
	RetiredAdapters         int                                     `json:"retiredAdapters,omitempty"`
	WatchUpdates            int64                                   `json:"watchUpdates,omitempty"`
	Removed                 []string                                `json:"removed,omitempty"`
	ClosedAdapters          int64                                   `json:"closedAdapters,omitempty"`
	UnhealthyAdapters       int64                                   `json:"unhealthyAdapters,omitempty"`
	PoolExhaustions         int64                                   `json:"poolExhaustions,omitempty"`
	DialFailures            int64                                   `json:"dialFailures,omitempty"`
	EndpointEjections       int64                                   `json:"endpointEjections,omitempty"`
	EndpointRecoveries      int64                                   `json:"endpointRecoveries,omitempty"`
	OpenRetries             int64                                   `json:"openRetries,omitempty"`
	LastRetriedFrom         string                                  `json:"lastRetriedFrom,omitempty"`
	LastRetriedTo           string                                  `json:"lastRetriedTo,omitempty"`
	RetryReasons            map[string]int64                        `json:"retryReasons,omitempty"`
	JanitorRuns             int64                                   `json:"janitorRuns,omitempty"`
	CloseReasons            map[string]int64                        `json:"closeReasons,omitempty"`
	DrainReasons            map[string]int64                        `json:"drainReasons,omitempty"`
	LastUpdated             time.Time                               `json:"lastUpdated,omitempty"`
}

type RPCMuxDiagnosisEvent

type RPCMuxDiagnosisEvent struct {
	Family       string        `json:"family"`
	Event        string        `json:"event"`
	Count        int64         `json:"count,omitempty"`
	Endpoint     string        `json:"endpoint,omitempty"`
	ConnectionID string        `json:"connectionId,omitempty"`
	PoolSlot     int           `json:"poolSlot,omitempty"`
	PeerProtocol string        `json:"peerProtocol,omitempty"`
	Reason       string        `json:"reason,omitempty"`
	From         string        `json:"from,omitempty"`
	To           string        `json:"to,omitempty"`
	Cooldown     time.Duration `json:"cooldown,omitempty"`
	Direction    string        `json:"direction,omitempty"`
}

func RPCMuxDiagnosisEvents

func RPCMuxDiagnosisEvents(diagnosis RPCMuxTransportDiagnosis) []RPCMuxDiagnosisEvent

type RPCMuxDiagnosisEventExporter

type RPCMuxDiagnosisEventExporter interface {
	ExportRPCMuxDiagnosisEvent(context.Context, RPCMuxDiagnosisEventRecord)
}

RPCMuxDiagnosisEventExporter receives filtered mux diagnosis events. It is deliberately transport-neutral so callers can bridge to slog, OTel logs, or another structured sink without adding labels to metrics.

func NewGovernedRPCMuxDiagnosisEventExporter

func NewGovernedRPCMuxDiagnosisEventExporter(exporter RPCMuxDiagnosisEventExporter, config RPCMuxDiagnosisExporterDeliveryConfig) RPCMuxDiagnosisEventExporter

NewGovernedRPCMuxDiagnosisEventExporter wraps an exporter with a bounded queue, per-export timeout, panic isolation, and delivery counters.

func NewRPCMuxOTelLogDiagnosisEventExporter

func NewRPCMuxOTelLogDiagnosisEventExporter(exporter RPCMuxOTelLogExporter) RPCMuxDiagnosisEventExporter

NewRPCMuxOTelLogDiagnosisEventExporter bridges mux diagnosis events into an OTel-log-compatible record contract. connection_id and pool_slot are kept as log attributes only; they must not be mirrored into metric labels.

func NewRPCMuxOTelLogSinkExporter

func NewRPCMuxOTelLogSinkExporter(name string, profile string) RPCMuxDiagnosisEventExporter

NewRPCMuxOTelLogSinkExporter returns an OTel-compatible event exporter for a registered sink. Unknown sinks return nil so callers can fail fast during configuration validation.

func NewRPCMuxSubprocessDiagnosisEventExporter

func NewRPCMuxSubprocessDiagnosisEventExporter(config RPCMuxSubprocessExporterConfig) (RPCMuxDiagnosisEventExporter, error)

NewRPCMuxSubprocessDiagnosisEventExporter creates a local subprocess exporter that writes one JSON event envelope to stdin per export call.

func NewSlogRPCMuxDiagnosisEventExporter

func NewSlogRPCMuxDiagnosisEventExporter(logger *slog.Logger) RPCMuxDiagnosisEventExporter

NewSlogRPCMuxDiagnosisEventExporter exports mux runtime events as structured slog records. Use it with an OTel slog handler to forward the same contract to an OTel log exporter.

type RPCMuxDiagnosisEventExporterFunc

type RPCMuxDiagnosisEventExporterFunc func(context.Context, RPCMuxDiagnosisEventRecord)

RPCMuxDiagnosisEventExporterFunc adapts a function to RPCMuxDiagnosisEventExporter.

func (RPCMuxDiagnosisEventExporterFunc) ExportRPCMuxDiagnosisEvent

func (f RPCMuxDiagnosisEventExporterFunc) ExportRPCMuxDiagnosisEvent(ctx context.Context, record RPCMuxDiagnosisEventRecord)

type RPCMuxDiagnosisEventOTelLogRecord

type RPCMuxDiagnosisEventOTelLogRecord struct {
	Name       string               `json:"name"`
	Severity   string               `json:"severity"`
	Body       string               `json:"body"`
	Attributes []attribute.KeyValue `json:"attributes,omitempty"`
	Timestamp  time.Time            `json:"timestamp"`
	Event      RPCMuxDiagnosisEvent `json:"event"`
}

RPCMuxDiagnosisEventOTelLogRecord is a small OTel-log-compatible envelope for mux diagnosis events. It uses OTel attributes without depending on the OTel logs SDK so applications can bridge it to their preferred log pipeline while keeping high-cardinality fields out of metrics.

func MuxDiagnosisEventOTelLogRecord

func MuxDiagnosisEventOTelLogRecord(record RPCMuxDiagnosisEventRecord) RPCMuxDiagnosisEventOTelLogRecord

MuxDiagnosisEventOTelLogRecord converts a mux diagnosis event into a stable OTel-log-compatible record. The attribute keys intentionally use the rpc.mux namespace shared by trace attributes while preserving high-cardinality values only in log records.

type RPCMuxDiagnosisEventRecord

type RPCMuxDiagnosisEventRecord struct {
	Target       string               `json:"target,omitempty"`
	Method       string               `json:"method,omitempty"`
	Endpoint     string               `json:"endpoint,omitempty"`
	ConnectionID string               `json:"connectionId,omitempty"`
	PoolSlot     int                  `json:"poolSlot,omitempty"`
	Event        RPCMuxDiagnosisEvent `json:"event"`
	Probe        RPCDiagnosisProbe    `json:"probe,omitempty"`
	ExportedAt   time.Time            `json:"exportedAt"`
}

RPCMuxDiagnosisEventRecord is the structured export envelope for one mux diagnosis event observed on a concrete runtime operation.

type RPCMuxDiagnosisExporterDeliveryConfig

type RPCMuxDiagnosisExporterDeliveryConfig struct {
	QueueSize               int                                      `json:"queueSize,omitempty"`
	Timeout                 time.Duration                            `json:"timeout,omitempty"`
	MaxHungCalls            int                                      `json:"maxHungCalls,omitempty"`
	BreakerFailureThreshold int                                      `json:"breakerFailureThreshold,omitempty"`
	BreakerCooldown         time.Duration                            `json:"breakerCooldown,omitempty"`
	ErrorBudget             RPCMuxDiagnosisExporterErrorBudgetConfig `json:"errorBudget,omitempty"`
	Isolation               RPCMuxDiagnosisSinkIsolationConfig       `json:"isolation,omitempty"`
}

RPCMuxDiagnosisExporterDeliveryConfig controls asynchronous bounded delivery to an application-owned diagnosis exporter.

type RPCMuxDiagnosisExporterDeliverySnapshot

type RPCMuxDiagnosisExporterDeliverySnapshot struct {
	Sink                string                             `json:"sink"`
	QueueSize           int                                `json:"queueSize"`
	QueueDepth          int                                `json:"queueDepth"`
	Timeout             int64                              `json:"timeoutNanos"`
	Accepted            int64                              `json:"accepted"`
	Exported            int64                              `json:"exported"`
	Dropped             int64                              `json:"dropped"`
	Backpressure        int64                              `json:"backpressure"`
	TimedOut            int64                              `json:"timedOut"`
	Panics              int64                              `json:"panics"`
	BreakerRejected     int64                              `json:"breakerRejected"`
	ConsecutiveFailures int64                              `json:"consecutiveFailures"`
	MaxHungCalls        int                                `json:"maxHungCalls"`
	ActiveCalls         int64                              `json:"activeCalls"`
	HungCalls           int64                              `json:"hungCalls"`
	BurnRate            float64                            `json:"burnRate"`
	ErrorBudgetPaused   bool                               `json:"errorBudgetPaused"`
	OperatorAction      string                             `json:"operatorAction,omitempty"`
	OperatorPaused      bool                               `json:"operatorPaused,omitempty"`
	OperatorPauseReason string                             `json:"operatorPauseReason,omitempty"`
	Isolation           RPCMuxDiagnosisSinkIsolationConfig `json:"isolation"`
	Subprocess          *RPCMuxSubprocessExporterSnapshot  `json:"subprocess,omitempty"`
	Health              string                             `json:"health"`
	BreakerState        string                             `json:"breakerState"`
	LastSuccessAt       time.Time                          `json:"lastSuccessAt,omitempty"`
	LastErrorAt         time.Time                          `json:"lastErrorAt,omitempty"`
	LastError           string                             `json:"lastError,omitempty"`
	LastLatencyNanos    int64                              `json:"lastLatencyNanos,omitempty"`
	MaxLatencyNanos     int64                              `json:"maxLatencyNanos,omitempty"`
	AverageLatencyNanos int64                              `json:"averageLatencyNanos,omitempty"`
	Closed              bool                               `json:"closed"`
}

RPCMuxDiagnosisExporterDeliverySnapshot exposes low-cardinality delivery health without including event payloads or sink profile values.

type RPCMuxDiagnosisExporterDeliverySnapshotter

type RPCMuxDiagnosisExporterDeliverySnapshotter interface {
	RPCMuxDiagnosisExporterDeliverySnapshot() RPCMuxDiagnosisExporterDeliverySnapshot
}

RPCMuxDiagnosisExporterDeliverySnapshotter is implemented by governed exporters that expose bounded-delivery health.

type RPCMuxDiagnosisExporterErrorBudgetConfig

type RPCMuxDiagnosisExporterErrorBudgetConfig struct {
	Enabled                   bool          `json:"enabled,omitempty"`
	MinSamples                int64         `json:"minSamples,omitempty"`
	BurnRateThreshold         float64       `json:"burnRateThreshold,omitempty"`
	RecoveryBurnRateThreshold float64       `json:"recoveryBurnRateThreshold,omitempty"`
	PauseDuration             time.Duration `json:"pauseDuration,omitempty"`
}

RPCMuxDiagnosisExporterErrorBudgetConfig controls optional burn-rate based delivery automation for one diagnosis exporter sink.

type RPCMuxDiagnosisFilter

type RPCMuxDiagnosisFilter struct {
	Endpoint         string
	ConnectionID     string
	PoolSlot         int
	FlowControlEvent string
	EventFamily      string
	Event            string
}

type RPCMuxDiagnosisOperatorAction

type RPCMuxDiagnosisOperatorAction struct {
	Sink        string            `json:"sink"`
	Action      string            `json:"action"`
	Reason      string            `json:"reason"`
	DryRun      bool              `json:"dryRun"`
	Approved    bool              `json:"approved,omitempty"`
	Health      string            `json:"health,omitempty"`
	Details     map[string]string `json:"details,omitempty"`
	GeneratedAt time.Time         `json:"generatedAt"`
}

RPCMuxDiagnosisOperatorAction describes a dry-run operator action for one sink. It is intentionally declarative; callers must apply any real action in their own control plane after audit and approval.

type RPCMuxDiagnosisOperatorActionSource

type RPCMuxDiagnosisOperatorActionSource interface {
	RPCMuxDiagnosisOperatorActions(context.Context) []RPCMuxDiagnosisOperatorAction
}

RPCMuxDiagnosisOperatorActionSource exposes dry-run operator actions.

type RPCMuxDiagnosisOperatorApproval

type RPCMuxDiagnosisOperatorApproval struct {
	Sink   string `json:"sink"`
	Action string `json:"action"`
	Token  string `json:"token,omitempty"`
}

RPCMuxDiagnosisOperatorApproval confirms an operator action. Empty tokens keep the action in dry-run mode.

type RPCMuxDiagnosisOperatorAuditSchema

type RPCMuxDiagnosisOperatorAuditSchema struct {
	Schema     string          `json:"schema"`
	Fields     []string        `json:"fields"`
	JSONSchema json.RawMessage `json:"jsonSchema"`
}

func RPCMuxDiagnosisOperatorAuditRecordSchema

func RPCMuxDiagnosisOperatorAuditRecordSchema(action RPCMuxDiagnosisOperatorAction) (RPCMuxDiagnosisOperatorAuditSchema, bool)

RPCMuxDiagnosisOperatorAuditRecordSchema resolves the published audit schema for a recorded operator action by reading the schema marker written into its details, closing the write/read loop with RPCMuxDiagnosisOperatorAuditSchemas. It returns false when the record carries no recognized schema marker, so consumers can distinguish schema-bearing audit records (debug replay, sink actions) from records without a structured details contract.

func (RPCMuxDiagnosisOperatorAuditSchema) ValidateDetails

func (s RPCMuxDiagnosisOperatorAuditSchema) ValidateDetails(details map[string]string) error

ValidateDetails checks an audit details map against this schema: the schema marker must match, every declared field must be present, and no undeclared key may appear. It validates against the same field list the schema exposes, so it stays a single source of truth rather than a separate JSON Schema engine, and gives runtime/control-plane callers a dependency-free structural check for inbound audit payloads.

type RPCMuxDiagnosisOperatorAuditValidateResponse

type RPCMuxDiagnosisOperatorAuditValidateResponse struct {
	Schema string `json:"schema,omitempty"`
	Valid  bool   `json:"valid"`
	Error  string `json:"error,omitempty"`
}

RPCMuxDiagnosisOperatorAuditValidateResponse reports whether a submitted audit details payload conforms to its published schema. It is a read-only dry-run result: nothing is persisted.

type RPCMuxDiagnosisOperatorDebugReplayAuditDetails

type RPCMuxDiagnosisOperatorDebugReplayAuditDetails struct {
	Source      string `json:"source"`
	Limit       int    `json:"limit"`
	TokenResult string `json:"tokenResult"`
}

func (RPCMuxDiagnosisOperatorDebugReplayAuditDetails) StringMap

type RPCMuxDiagnosisOperatorHistoryDiagState

type RPCMuxDiagnosisOperatorHistoryDiagState struct {
	StoreEnabled        bool   `json:"storeEnabled,omitempty"`
	StoreKind           string `json:"storeKind,omitempty"`
	StoreChecksumStatus string `json:"storeChecksumStatus,omitempty"`
	ChecksumMismatch    bool   `json:"checksumMismatch,omitempty"`
	LastError           string `json:"lastError,omitempty"`
}

type RPCMuxDiagnosisOperatorHistoryFileEvidence

type RPCMuxDiagnosisOperatorHistoryFileEvidence struct {
	Source          string `json:"source"`
	Path            string `json:"path,omitempty"`
	Exists          bool   `json:"exists"`
	SizeBytes       int64  `json:"sizeBytes,omitempty"`
	StoredActions   int    `json:"storedActions,omitempty"`
	BadLines        int    `json:"badLines,omitempty"`
	TamperedLines   int    `json:"tamperedLines,omitempty"`
	TruncatedLines  int    `json:"truncatedLines,omitempty"`
	LegacyLines     int    `json:"legacyLines,omitempty"`
	HeaderPresent   bool   `json:"headerPresent,omitempty"`
	Checksum        string `json:"checksum,omitempty"`
	ChecksumStatus  string `json:"checksumStatus,omitempty"`
	IntegrityStatus string `json:"integrityStatus"`
	LastError       string `json:"lastError,omitempty"`
}

RPCMuxDiagnosisOperatorHistoryFileEvidence summarizes one history file without exposing its operator actions or raw contents.

type RPCMuxDiagnosisOperatorHistoryFileStore

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

func NewRPCMuxDiagnosisOperatorHistoryFileStore

func NewRPCMuxDiagnosisOperatorHistoryFileStore(path string) (*RPCMuxDiagnosisOperatorHistoryFileStore, error)

func NewRPCMuxDiagnosisOperatorHistoryFileStoreWithConfig

func NewRPCMuxDiagnosisOperatorHistoryFileStoreWithConfig(path string, config RPCMuxDiagnosisOperatorHistoryFileStoreConfig) (*RPCMuxDiagnosisOperatorHistoryFileStore, error)

NewRPCMuxDiagnosisOperatorHistoryFileStoreWithConfig constructs a bounded local file store. Zero limits retain the conservative defaults.

func (*RPCMuxDiagnosisOperatorHistoryFileStore) AppendRPCMuxDiagnosisOperatorAction

func (s *RPCMuxDiagnosisOperatorHistoryFileStore) AppendRPCMuxDiagnosisOperatorAction(ctx context.Context, action RPCMuxDiagnosisOperatorAction) error

func (*RPCMuxDiagnosisOperatorHistoryFileStore) LoadRPCMuxDiagnosisOperatorActions

func (s *RPCMuxDiagnosisOperatorHistoryFileStore) LoadRPCMuxDiagnosisOperatorActions(ctx context.Context, limit int) ([]RPCMuxDiagnosisOperatorAction, error)

func (*RPCMuxDiagnosisOperatorHistoryFileStore) RPCMuxDiagnosisOperatorStoreSnapshot

func (s *RPCMuxDiagnosisOperatorHistoryFileStore) RPCMuxDiagnosisOperatorStoreSnapshot() RPCMuxDiagnosisOperatorStoreSnapshot

func (*RPCMuxDiagnosisOperatorHistoryFileStore) ReplayRPCMuxDiagnosisOperatorHistory

func (s *RPCMuxDiagnosisOperatorHistoryFileStore) ReplayRPCMuxDiagnosisOperatorHistory(ctx context.Context, source string, limit int) (RPCMuxDiagnosisOperatorHistoryReplay, error)

ReplayRPCMuxDiagnosisOperatorHistory reads and validates one history file without updating the store snapshot or changing either history file.

func (*RPCMuxDiagnosisOperatorHistoryFileStore) VerifyRPCMuxDiagnosisOperatorHistory

VerifyRPCMuxDiagnosisOperatorHistory validates the primary and backup files without returning actions.

type RPCMuxDiagnosisOperatorHistoryFileStoreConfig

type RPCMuxDiagnosisOperatorHistoryFileStoreConfig struct {
	MaxSizeBytes int64 `json:"maxSizeBytes,omitempty"`
	MaxLineBytes int64 `json:"maxLineBytes,omitempty"`
	MaxActions   int   `json:"maxActions,omitempty"`
	MaxBackups   int   `json:"maxBackups,omitempty"`
}

RPCMuxDiagnosisOperatorHistoryFileStoreConfig bounds file reads and compaction. Zero values select the conservative defaults.

type RPCMuxDiagnosisOperatorHistoryHardLimits

type RPCMuxDiagnosisOperatorHistoryHardLimits struct {
	MaxSizeBytes             int64         `json:"maxSizeBytes"`
	MaxLineBytes             int64         `json:"maxLineBytes"`
	MaxActions               int           `json:"maxActions"`
	MaxBackups               int           `json:"maxBackups"`
	DebugReplayCooldown      time.Duration `json:"debugReplayCooldown"`
	MinDebugReplayCooldown   time.Duration `json:"minDebugReplayCooldown"`
	MaxDebugReplayCooldown   time.Duration `json:"maxDebugReplayCooldown"`
	MinAuditValidateCooldown time.Duration `json:"minAuditValidateCooldown"`
	MaxAuditValidateCooldown time.Duration `json:"maxAuditValidateCooldown"`
}

RPCMuxDiagnosisOperatorHistoryHardLimits reports the core hard bounds for operator history configuration and the default debug replay cooldown. It lets downstream tooling (for example the generated production check) assert its own recommended bounds never exceed what the core runtime enforces, so generated validation cannot lag behind the contract.

func RPCMuxDiagnosisOperatorHistoryLimits

func RPCMuxDiagnosisOperatorHistoryLimits() RPCMuxDiagnosisOperatorHistoryHardLimits

RPCMuxDiagnosisOperatorHistoryLimits returns the core operator history hard limits, the default debug replay cooldown, and the accepted debug replay cooldown range.

type RPCMuxDiagnosisOperatorHistoryIntegritySnapshot

type RPCMuxDiagnosisOperatorHistoryIntegritySnapshot struct {
	Store           RPCMuxDiagnosisOperatorStoreSnapshot       `json:"store"`
	IntegrityStatus string                                     `json:"integrityStatus"`
	DegradedReason  string                                     `json:"degradedReason,omitempty"`
	DegradedSource  string                                     `json:"degradedSource,omitempty"`
	Verification    RPCMuxDiagnosisOperatorHistoryVerification `json:"verification,omitempty"`
}

RPCMuxDiagnosisOperatorHistoryIntegritySnapshot is safe for control-plane export because it contains store and integrity summaries, never actions.

type RPCMuxDiagnosisOperatorHistoryReplay

type RPCMuxDiagnosisOperatorHistoryReplay struct {
	Source   string                                     `json:"source"`
	Actions  []RPCMuxDiagnosisOperatorAction            `json:"actions,omitempty"`
	Evidence RPCMuxDiagnosisOperatorHistoryFileEvidence `json:"evidence"`
}

RPCMuxDiagnosisOperatorHistoryReplay contains validated actions from one explicitly selected history file and its integrity evidence.

type RPCMuxDiagnosisOperatorHistoryReplayAdminResponse

type RPCMuxDiagnosisOperatorHistoryReplayAdminResponse struct {
	Verification             RPCMuxDiagnosisOperatorHistoryVerification `json:"verification"`
	Replay                   *RPCMuxDiagnosisOperatorHistoryReplay      `json:"replay,omitempty"`
	DebugActions             bool                                       `json:"debugActions,omitempty"`
	CooldownSeconds          float64                                    `json:"cooldownSeconds,omitempty"`
	CooldownRemainingSeconds float64                                    `json:"cooldownRemainingSeconds,omitempty"`
}

type RPCMuxDiagnosisOperatorHistorySnapshot

type RPCMuxDiagnosisOperatorHistorySnapshot struct {
	Actions       []RPCMuxDiagnosisOperatorAction         `json:"actions,omitempty"`
	Checksum      string                                  `json:"checksum,omitempty"`
	StoreSnapshot RPCMuxDiagnosisOperatorStoreSnapshot    `json:"store,omitempty"`
	Diagnostics   RPCMuxDiagnosisOperatorHistoryDiagState `json:"diagnostics,omitempty"`
}

type RPCMuxDiagnosisOperatorHistoryStore

type RPCMuxDiagnosisOperatorHistoryStore interface {
	AppendRPCMuxDiagnosisOperatorAction(context.Context, RPCMuxDiagnosisOperatorAction) error
	LoadRPCMuxDiagnosisOperatorActions(context.Context, int) ([]RPCMuxDiagnosisOperatorAction, error)
}

type RPCMuxDiagnosisOperatorHistoryStoreSnapshotter

type RPCMuxDiagnosisOperatorHistoryStoreSnapshotter interface {
	RPCMuxDiagnosisOperatorStoreSnapshot() RPCMuxDiagnosisOperatorStoreSnapshot
}

type RPCMuxDiagnosisOperatorHistoryStoreVerifier

type RPCMuxDiagnosisOperatorHistoryStoreVerifier interface {
	VerifyRPCMuxDiagnosisOperatorHistory(context.Context) (RPCMuxDiagnosisOperatorHistoryVerification, error)
}

RPCMuxDiagnosisOperatorHistoryStoreVerifier exposes redacted, read-only integrity evidence for a history store.

type RPCMuxDiagnosisOperatorHistoryVerification

type RPCMuxDiagnosisOperatorHistoryVerification struct {
	Primary RPCMuxDiagnosisOperatorHistoryFileEvidence   `json:"primary"`
	Backup  RPCMuxDiagnosisOperatorHistoryFileEvidence   `json:"backup"`
	Backups []RPCMuxDiagnosisOperatorHistoryFileEvidence `json:"backups,omitempty"`
}

RPCMuxDiagnosisOperatorHistoryVerification contains redacted evidence for the primary and backup files.

type RPCMuxDiagnosisOperatorStoreSnapshot

type RPCMuxDiagnosisOperatorStoreSnapshot struct {
	Enabled         bool      `json:"enabled"`
	Kind            string    `json:"kind,omitempty"`
	Path            string    `json:"path,omitempty"`
	SchemaVersion   string    `json:"schemaVersion,omitempty"`
	MaxSizeBytes    int64     `json:"maxSizeBytes,omitempty"`
	MaxLineBytes    int64     `json:"maxLineBytes,omitempty"`
	MaxActions      int       `json:"maxActions,omitempty"`
	StoredActions   int       `json:"storedActions,omitempty"`
	BadLines        int       `json:"badLines,omitempty"`
	TamperedLines   int       `json:"tamperedLines,omitempty"`
	TruncatedLines  int       `json:"truncatedLines,omitempty"`
	LegacyLines     int       `json:"legacyLines,omitempty"`
	HeaderPresent   bool      `json:"headerPresent,omitempty"`
	Checksum        string    `json:"checksum,omitempty"`
	ChecksumStatus  string    `json:"checksumStatus,omitempty"`
	IntegrityStatus string    `json:"integrityStatus,omitempty"`
	Compactions     int       `json:"compactions,omitempty"`
	Rotations       int       `json:"rotations,omitempty"`
	BackupRetention int       `json:"backupRetention,omitempty"`
	LastError       string    `json:"lastError,omitempty"`
	LastWriteAt     time.Time `json:"lastWriteAt,omitempty"`
	LastLoadAt      time.Time `json:"lastLoadAt,omitempty"`
	LastCompactedAt time.Time `json:"lastCompactedAt,omitempty"`
}

type RPCMuxDiagnosisProductionRecommendedLimits

type RPCMuxDiagnosisProductionRecommendedLimits struct {
	MaxSizeBytes int64 `json:"maxSizeBytes"`
	MaxLineBytes int64 `json:"maxLineBytes"`
	MaxActions   int   `json:"maxActions"`
	MaxBackups   int   `json:"maxBackups"`
}

RPCMuxDiagnosisProductionRecommendedLimits reports the recommended production upper bounds for operator history configuration. They are stricter than the hard limits and are the single source consumed by generated documentation and the generated production check, so those never drift from a second copy.

func RPCMuxDiagnosisOperatorHistoryRecommendedLimits

func RPCMuxDiagnosisOperatorHistoryRecommendedLimits() RPCMuxDiagnosisProductionRecommendedLimits

RPCMuxDiagnosisOperatorHistoryRecommendedLimits returns the recommended production upper bounds for operator history configuration.

type RPCMuxDiagnosisSecretResolver

type RPCMuxDiagnosisSecretResolver func(context.Context, string) (string, error)

RPCMuxDiagnosisSecretResolver resolves profile references before validation. Resolved profile values are never exposed by snapshots or diff plans.

func NewRPCMuxDiagnosisEnvSecretResolver

func NewRPCMuxDiagnosisEnvSecretResolver() RPCMuxDiagnosisSecretResolver

NewRPCMuxDiagnosisEnvSecretResolver resolves profile references of the form env://NAME. It intentionally supports only environment variables so generated projects can avoid logging or storing raw profile JSON.

func NewRPCMuxDiagnosisFileSecretResolver

func NewRPCMuxDiagnosisFileSecretResolver(root string, maxBytes int64) RPCMuxDiagnosisSecretResolver

NewRPCMuxDiagnosisFileSecretResolver resolves profile references of the form file://relative/path under root. Absolute paths, path traversal and oversized files are rejected.

func NewRPCMuxDiagnosisLayeredSecretResolver

func NewRPCMuxDiagnosisLayeredSecretResolver(resolvers ...RPCMuxDiagnosisSecretResolver) RPCMuxDiagnosisSecretResolver

NewRPCMuxDiagnosisLayeredSecretResolver tries resolvers in order until one resolves the reference. It preserves the last error for operator diagnosis.

type RPCMuxDiagnosisSinkConfig

type RPCMuxDiagnosisSinkConfig struct {
	Name             string                                `json:"name"`
	Profile          string                                `json:"profile,omitempty"`
	ProfileRef       string                                `json:"profileRef,omitempty"`
	ProfileSchema    string                                `json:"profileSchema,omitempty"`
	ProfileMigration string                                `json:"profileMigration,omitempty"`
	Priority         int                                   `json:"priority,omitempty"`
	Delivery         RPCMuxDiagnosisExporterDeliveryConfig `json:"delivery,omitempty"`
}

RPCMuxDiagnosisSinkConfig configures one named registry sink in a fan-out set. Profile values are used only during construction and are never exposed by runtime snapshots.

type RPCMuxDiagnosisSinkIsolationConfig

type RPCMuxDiagnosisSinkIsolationConfig struct {
	Mode            string            `json:"mode,omitempty"`
	ShutdownTimeout time.Duration     `json:"shutdownTimeout,omitempty"`
	MaxMemoryBytes  int64             `json:"maxMemoryBytes,omitempty"`
	MaxCPUPercent   int               `json:"maxCpuPercent,omitempty"`
	AuditFields     map[string]string `json:"auditFields,omitempty"`
}

RPCMuxDiagnosisSinkIsolationConfig describes the intended isolation profile for one sink generation. Non in-process modes are explicit operator contracts; applications must provide the actual isolated exporter.

type RPCMuxDiagnosisSinkRuntimeSnapshot

type RPCMuxDiagnosisSinkRuntimeSnapshot struct {
	Name             string                                  `json:"name"`
	ProfileSchema    string                                  `json:"profileSchema,omitempty"`
	ProfileMigration string                                  `json:"profileMigration,omitempty"`
	Priority         int                                     `json:"priority"`
	Delivery         RPCMuxDiagnosisExporterDeliverySnapshot `json:"delivery"`
}

RPCMuxDiagnosisSinkRuntimeSnapshot describes one active sink without profile values or provider instances.

type RPCMuxDiagnosisSinkSet

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

RPCMuxDiagnosisSinkSet is a versioned, hot-reloadable, multi-sink exporter. Reload constructs and validates a complete candidate generation before the active pointer is swapped, so failures leave the current generation intact.

func NewRPCMuxDiagnosisSinkSet

func NewRPCMuxDiagnosisSinkSet(config RPCMuxDiagnosisSinkSetConfig) (*RPCMuxDiagnosisSinkSet, error)

NewRPCMuxDiagnosisSinkSet builds the initial sink generation.

func (*RPCMuxDiagnosisSinkSet) ApplyRPCMuxDiagnosisOperatorAction

func (s *RPCMuxDiagnosisSinkSet) ApplyRPCMuxDiagnosisOperatorAction(ctx context.Context, approval RPCMuxDiagnosisOperatorApproval) RPCMuxDiagnosisOperatorAction

ApplyRPCMuxDiagnosisOperatorAction applies an explicitly approved sink action. Without a token it returns the same action as a dry-run plan.

func (*RPCMuxDiagnosisSinkSet) Close

func (s *RPCMuxDiagnosisSinkSet) Close() error

Close stops fan-out and drains every active sink exactly once.

func (*RPCMuxDiagnosisSinkSet) DiffRPCMuxDiagnosisSinkSetConfig

func (s *RPCMuxDiagnosisSinkSet) DiffRPCMuxDiagnosisSinkSetConfig(ctx context.Context, config RPCMuxDiagnosisSinkSetConfig) (RPCMuxDiagnosisSinkSetDiffPlan, error)

DiffRPCMuxDiagnosisSinkSetConfig validates a candidate generation and returns a redacted operator diff plan against the current active generation.

func (*RPCMuxDiagnosisSinkSet) ExportRPCMuxDiagnosisEvent

func (s *RPCMuxDiagnosisSinkSet) ExportRPCMuxDiagnosisEvent(ctx context.Context, record RPCMuxDiagnosisEventRecord)

ExportRPCMuxDiagnosisEvent fans out one record in descending priority order. Each sink has an independent bounded queue and breaker, so one slow sink cannot block or suppress another sink.

func (*RPCMuxDiagnosisSinkSet) OperatorHistoryStoreSnapshot

func (s *RPCMuxDiagnosisSinkSet) OperatorHistoryStoreSnapshot() RPCMuxDiagnosisOperatorStoreSnapshot

func (*RPCMuxDiagnosisSinkSet) RPCMuxDiagnosisOperatorActionHistory

func (s *RPCMuxDiagnosisSinkSet) RPCMuxDiagnosisOperatorActionHistory(limit int) []RPCMuxDiagnosisOperatorAction

func (*RPCMuxDiagnosisSinkSet) RPCMuxDiagnosisOperatorActions

func (s *RPCMuxDiagnosisSinkSet) RPCMuxDiagnosisOperatorActions(ctx context.Context) []RPCMuxDiagnosisOperatorAction

func (*RPCMuxDiagnosisSinkSet) RPCMuxDiagnosisOperatorHistoryIntegritySnapshot

func (s *RPCMuxDiagnosisSinkSet) RPCMuxDiagnosisOperatorHistoryIntegritySnapshot(ctx context.Context) (RPCMuxDiagnosisOperatorHistoryIntegritySnapshot, error)

RPCMuxDiagnosisOperatorHistoryIntegritySnapshot returns redacted, read-only integrity evidence for the configured store.

func (*RPCMuxDiagnosisSinkSet) RPCMuxDiagnosisOperatorHistorySnapshot

func (s *RPCMuxDiagnosisSinkSet) RPCMuxDiagnosisOperatorHistorySnapshot(limit int) RPCMuxDiagnosisOperatorHistorySnapshot

func (*RPCMuxDiagnosisSinkSet) RPCMuxDiagnosisSinkSetSnapshot

func (s *RPCMuxDiagnosisSinkSet) RPCMuxDiagnosisSinkSetSnapshot() RPCMuxDiagnosisSinkSetSnapshot

RPCMuxDiagnosisSinkSetSnapshot returns a deterministic runtime view.

func (*RPCMuxDiagnosisSinkSet) RecordRPCMuxDiagnosisOperatorAuditAction

func (s *RPCMuxDiagnosisSinkSet) RecordRPCMuxDiagnosisOperatorAuditAction(action RPCMuxDiagnosisOperatorAction)

func (*RPCMuxDiagnosisSinkSet) Reload

Reload atomically replaces the active generation after full validation and construction. The previous generation is drained only after the swap.

func (*RPCMuxDiagnosisSinkSet) ReplayRPCMuxDiagnosisOperatorHistory

func (s *RPCMuxDiagnosisSinkSet) ReplayRPCMuxDiagnosisOperatorHistory(ctx context.Context, source string, limit int) (RPCMuxDiagnosisOperatorHistoryReplay, error)

func (*RPCMuxDiagnosisSinkSet) StoredRPCMuxDiagnosisOperatorActionHistory

func (s *RPCMuxDiagnosisSinkSet) StoredRPCMuxDiagnosisOperatorActionHistory(ctx context.Context, limit int) []RPCMuxDiagnosisOperatorAction

func (*RPCMuxDiagnosisSinkSet) WithOperatorHistoryStore

type RPCMuxDiagnosisSinkSetConfig

type RPCMuxDiagnosisSinkSetConfig struct {
	Version       string                        `json:"version"`
	SchemaVersion string                        `json:"schemaVersion,omitempty"`
	Sinks         []RPCMuxDiagnosisSinkConfig   `json:"sinks,omitempty"`
	Secrets       RPCMuxDiagnosisSecretResolver `json:"-"`
}

RPCMuxDiagnosisSinkSetConfig describes one atomic sink-set generation.

type RPCMuxDiagnosisSinkSetDiffPlan

type RPCMuxDiagnosisSinkSetDiffPlan struct {
	FromVersion       string   `json:"fromVersion,omitempty"`
	ToVersion         string   `json:"toVersion,omitempty"`
	FromSchemaVersion string   `json:"fromSchemaVersion,omitempty"`
	ToSchemaVersion   string   `json:"toSchemaVersion,omitempty"`
	Activate          []string `json:"activate,omitempty"`
	Deactivate        []string `json:"deactivate,omitempty"`
	Retain            []string `json:"retain,omitempty"`
	ChangePriority    []string `json:"changePriority,omitempty"`
	ChangeProfile     []string `json:"changeProfile,omitempty"`
	ChangeDelivery    []string `json:"changeDelivery,omitempty"`
	MigrateProfile    []string `json:"migrateProfile,omitempty"`
}

RPCMuxDiagnosisSinkSetDiffPlan describes a generation change without profile values. Operators can inspect it before applying a hot reload.

type RPCMuxDiagnosisSinkSetSnapshot

type RPCMuxDiagnosisSinkSetSnapshot struct {
	Version           string                               `json:"version,omitempty"`
	SchemaVersion     string                               `json:"schemaVersion,omitempty"`
	UpdatedAt         time.Time                            `json:"updatedAt,omitempty"`
	SinkCount         int                                  `json:"sinkCount"`
	Sinks             []RPCMuxDiagnosisSinkRuntimeSnapshot `json:"sinks,omitempty"`
	LastDiffPlan      RPCMuxDiagnosisSinkSetDiffPlan       `json:"lastDiffPlan,omitempty"`
	Reloads           int64                                `json:"reloads"`
	Rollbacks         int64                                `json:"rollbacks"`
	LastReloadAt      time.Time                            `json:"lastReloadAt,omitempty"`
	LastReloadErrorAt time.Time                            `json:"lastReloadErrorAt,omitempty"`
	LastReloadError   string                               `json:"lastReloadError,omitempty"`
	Closed            bool                                 `json:"closed"`
}

RPCMuxDiagnosisSinkSetSnapshot exposes hot-reload version, rollback, fan-out, and per-sink delivery health.

type RPCMuxDiagnosisSinkSetSnapshotter

type RPCMuxDiagnosisSinkSetSnapshotter interface {
	RPCMuxDiagnosisSinkSetSnapshot() RPCMuxDiagnosisSinkSetSnapshot
}

RPCMuxDiagnosisSinkSetSnapshotter is implemented by versioned multi-sink exporters that expose hot-reload and per-sink SLO state.

type RPCMuxDrainDiagnosis

type RPCMuxDrainDiagnosis struct {
	Draining          bool   `json:"draining,omitempty"`
	RemoteDraining    bool   `json:"remoteDraining,omitempty"`
	DrainReason       string `json:"drainReason,omitempty"`
	RemoteDrainReason string `json:"remoteDrainReason,omitempty"`
	GoAwayFramesIn    int64  `json:"goAwayFramesIn,omitempty"`
	GoAwayFramesOut   int64  `json:"goAwayFramesOut,omitempty"`
	DrainRejects      int64  `json:"drainRejects,omitempty"`
}

type RPCMuxFlowControlDiagnosis

type RPCMuxFlowControlDiagnosis struct {
	ReceiveQueueSize                        int                               `json:"receiveQueueSize,omitempty"`
	ConnectionWindow                        int                               `json:"connectionWindow,omitempty"`
	ConnectionCreditWaits                   int64                             `json:"connectionCreditWaits,omitempty"`
	StreamCreditWaits                       int64                             `json:"streamCreditWaits,omitempty"`
	CreditWaitTimeouts                      int64                             `json:"creditWaitTimeouts,omitempty"`
	WriteTimeouts                           int64                             `json:"writeTimeouts,omitempty"`
	ConnectionWindowExhausted               int64                             `json:"connectionWindowExhausted,omitempty"`
	FragmentFramesIn                        int64                             `json:"fragmentFramesIn,omitempty"`
	FragmentFramesOut                       int64                             `json:"fragmentFramesOut,omitempty"`
	FragmentBackpressure                    int64                             `json:"fragmentBackpressure,omitempty"`
	FragmentStreamWindowUpdatePolicy        string                            `json:"fragmentStreamWindowUpdatePolicy,omitempty"`
	FragmentConnectionWindowUpdatePolicy    string                            `json:"fragmentConnectionWindowUpdatePolicy,omitempty"`
	FragmentStreamWindowRefillRatio         float64                           `json:"fragmentStreamWindowRefillRatio,omitempty"`
	FragmentConnectionWindowRefillRatio     float64                           `json:"fragmentConnectionWindowRefillRatio,omitempty"`
	FragmentMaxDeferredFragments            int                               `json:"fragmentMaxDeferredFragments,omitempty"`
	FragmentWindowRefills                   int64                             `json:"fragmentWindowRefills,omitempty"`
	FragmentWindowRefillLatencyTotal        time.Duration                     `json:"fragmentWindowRefillLatencyTotal,omitempty"`
	FragmentWindowRefillLatencyMax          time.Duration                     `json:"fragmentWindowRefillLatencyMax,omitempty"`
	FragmentWindowRefillLatencyAvg          time.Duration                     `json:"fragmentWindowRefillLatencyAvg,omitempty"`
	FragmentDeferredStreamWindowUpdates     int64                             `json:"fragmentDeferredStreamWindowUpdates,omitempty"`
	FragmentDeferredConnectionWindowUpdates int64                             `json:"fragmentDeferredConnectionWindowUpdates,omitempty"`
	FragmentWindowPolicyRisk                bool                              `json:"fragmentWindowPolicyRisk,omitempty"`
	FragmentWindowPolicyRiskReason          string                            `json:"fragmentWindowPolicyRiskReason,omitempty"`
	FragmentWindowPolicyRiskMode            string                            `json:"fragmentWindowPolicyRiskMode,omitempty"`
	FragmentEstimatedMaxFragments           int                               `json:"fragmentEstimatedMaxFragments,omitempty"`
	WindowFramesIn                          int64                             `json:"windowFramesIn,omitempty"`
	WindowFramesOut                         int64                             `json:"windowFramesOut,omitempty"`
	ConnectionWindowIn                      int64                             `json:"connectionWindowIn,omitempty"`
	ConnectionWindowOut                     int64                             `json:"connectionWindowOut,omitempty"`
	BackpressureEvents                      int64                             `json:"backpressureEvents,omitempty"`
	LastFlowControlEvent                    string                            `json:"lastFlowControlEvent,omitempty"`
	LastFlowControlEventAt                  time.Time                         `json:"lastFlowControlEventAt,omitempty"`
	LastBackpressureEvent                   string                            `json:"lastBackpressureEvent,omitempty"`
	LastBackpressureEventAt                 time.Time                         `json:"lastBackpressureEventAt,omitempty"`
	Events                                  []RPCMuxFlowControlEventDiagnosis `json:"events,omitempty"`
}

type RPCMuxFlowControlEventDiagnosis

type RPCMuxFlowControlEventDiagnosis struct {
	Event string `json:"event"`
	Count int64  `json:"count"`
}

type RPCMuxKeepaliveDiagnosis

type RPCMuxKeepaliveDiagnosis struct {
	Liveness           string        `json:"liveness,omitempty"`
	Interval           time.Duration `json:"interval,omitempty"`
	Idle               time.Duration `json:"idle,omitempty"`
	PingFramesIn       int64         `json:"pingFramesIn,omitempty"`
	PingFramesOut      int64         `json:"pingFramesOut,omitempty"`
	PongFramesIn       int64         `json:"pongFramesIn,omitempty"`
	PongFramesOut      int64         `json:"pongFramesOut,omitempty"`
	IdleTimeouts       int64         `json:"idleTimeouts,omitempty"`
	LastPingAt         time.Time     `json:"lastPingAt,omitempty"`
	LastPongAt         time.Time     `json:"lastPongAt,omitempty"`
	LastFrameReadAt    time.Time     `json:"lastFrameReadAt,omitempty"`
	LastFrameWrittenAt time.Time     `json:"lastFrameWrittenAt,omitempty"`
}

type RPCMuxNegotiationDiagnosis

type RPCMuxNegotiationDiagnosis struct {
	Failures            int64  `json:"failures,omitempty"`
	TLSFailure          int64  `json:"tls_failure,omitempty"`
	ALPNMismatch        int64  `json:"alpn_mismatch,omitempty"`
	PrefaceMismatch     int64  `json:"preface_mismatch,omitempty"`
	ProtocolMismatch    int64  `json:"protocol_mismatch,omitempty"`
	FramePolicyMismatch int64  `json:"frame_policy_mismatch,omitempty"`
	PolicyRiskRejected  int64  `json:"fragment_window_policy_risk,omitempty"`
	LastEvent           string `json:"lastEvent,omitempty"`
	LastPhase           string `json:"lastPhase,omitempty"`
	LastError           string `json:"lastError,omitempty"`
	PeerProtocol        string `json:"peerProtocol,omitempty"`
}

type RPCMuxOTelLogExporter

type RPCMuxOTelLogExporter interface {
	ExportRPCMuxOTelLog(context.Context, RPCMuxDiagnosisEventOTelLogRecord)
}

RPCMuxOTelLogExporter receives OTel-log-compatible mux diagnosis records.

func NewSlogRPCMuxOTelLogExporter

func NewSlogRPCMuxOTelLogExporter(logger *slog.Logger) RPCMuxOTelLogExporter

NewSlogRPCMuxOTelLogExporter emits OTel-log-compatible mux diagnosis records through slog. Use it as a dependency-free adapter when an application routes slog to an OTel log backend.

func NewSlogRPCMuxOTelLogExporterWithProfile

func NewSlogRPCMuxOTelLogExporterWithProfile(logger *slog.Logger, profile string) RPCMuxOTelLogExporter

NewSlogRPCMuxOTelLogExporterWithProfile emits OTel-log-compatible mux diagnosis records through slog and tags each record with a configured sink profile name.

type RPCMuxOTelLogExporterFunc

type RPCMuxOTelLogExporterFunc func(context.Context, RPCMuxDiagnosisEventOTelLogRecord)

RPCMuxOTelLogExporterFunc adapts a function to RPCMuxOTelLogExporter.

func (RPCMuxOTelLogExporterFunc) ExportRPCMuxOTelLog

type RPCMuxOTelLogSinkFactory

type RPCMuxOTelLogSinkFactory func(profile string) RPCMuxOTelLogExporter

RPCMuxOTelLogSinkFactory creates an OTel-log-compatible event sink for a configured profile. Applications can register custom sinks that forward to a concrete OTel log exporter without coupling gofly to a specific logs SDK.

type RPCMuxOTelLogSinkProvider

type RPCMuxOTelLogSinkProvider interface {
	NewRPCMuxOTelLogExporter(profile string) RPCMuxOTelLogExporter
	ValidateRPCMuxOTelLogProfile(profile string) error
}

RPCMuxOTelLogSinkProvider creates and validates one named OTel-compatible mux event sink. Use RegisterRPCMuxOTelLogSinkProvider when a sink owns profile-specific configuration such as endpoints or batch limits.

type RPCMuxOTelLogSinkRegistrySnapshot

type RPCMuxOTelLogSinkRegistrySnapshot struct {
	Sinks        []RPCMuxOTelLogSinkSnapshot `json:"sinks"`
	Capabilities []string                    `json:"capabilities"`
}

RPCMuxOTelLogSinkRegistrySnapshot is a deterministic, machine-readable view of the registered sink extension points.

func RPCMuxOTelLogSinkRegistry

func RPCMuxOTelLogSinkRegistry() RPCMuxOTelLogSinkRegistrySnapshot

RPCMuxOTelLogSinkRegistry returns a deterministic snapshot suitable for admin and control-plane introspection.

type RPCMuxOTelLogSinkSchemaProvider

type RPCMuxOTelLogSinkSchemaProvider interface {
	RPCMuxOTelLogProfileSchema() json.RawMessage
}

RPCMuxOTelLogSinkSchemaProvider optionally describes the JSON profile accepted by an RPCMuxOTelLogSinkProvider.

type RPCMuxOTelLogSinkSnapshot

type RPCMuxOTelLogSinkSnapshot struct {
	Name                        string          `json:"name"`
	ProfileValidation           bool            `json:"profileValidation"`
	ProfileSchema               json.RawMessage `json:"profileSchema,omitempty"`
	ProfileValidationCategories []string        `json:"profileValidationCategories,omitempty"`
	ClientExport                bool            `json:"clientExport"`
	ServerExport                bool            `json:"serverExport"`
	DeliveryGovernance          bool            `json:"deliveryGovernance"`
}

RPCMuxOTelLogSinkSnapshot describes one registered mux OTel log sink without exposing provider instances or profile values.

type RPCMuxOTelLogSinkValidationCategoryProvider

type RPCMuxOTelLogSinkValidationCategoryProvider interface {
	RPCMuxOTelLogValidationCategories() []string
}

type RPCMuxRefillProfile

type RPCMuxRefillProfile struct {
	Endpoint                        string        `json:"endpoint,omitempty"`
	ConnectionID                    string        `json:"connectionId,omitempty"`
	PoolSlot                        int           `json:"poolSlot,omitempty"`
	ReceiveQueueSize                int           `json:"receiveQueueSize,omitempty"`
	ConnectionWindow                int           `json:"connectionWindow,omitempty"`
	StreamWindowUpdatePolicy        string        `json:"streamWindowUpdatePolicy,omitempty"`
	ConnectionWindowUpdatePolicy    string        `json:"connectionWindowUpdatePolicy,omitempty"`
	StreamWindowRefillRatio         float64       `json:"streamWindowRefillRatio,omitempty"`
	ConnectionWindowRefillRatio     float64       `json:"connectionWindowRefillRatio,omitempty"`
	MaxDeferredFragments            int           `json:"maxDeferredFragments,omitempty"`
	Refills                         int64         `json:"refills,omitempty"`
	RefillLatencyTotal              time.Duration `json:"refillLatencyTotal,omitempty"`
	RefillLatencyMax                time.Duration `json:"refillLatencyMax,omitempty"`
	RefillLatencyAvg                time.Duration `json:"refillLatencyAvg,omitempty"`
	DeferredStreamWindowUpdates     int64         `json:"deferredStreamWindowUpdates,omitempty"`
	DeferredConnectionWindowUpdates int64         `json:"deferredConnectionWindowUpdates,omitempty"`
	BackpressureEvents              int64         `json:"backpressureEvents,omitempty"`
	FragmentBackpressure            int64         `json:"fragmentBackpressure,omitempty"`
	LastFlowControlEvent            string        `json:"lastFlowControlEvent,omitempty"`
	LastFlowControlEventAt          time.Time     `json:"lastFlowControlEventAt,omitempty"`
	LastBackpressureEvent           string        `json:"lastBackpressureEvent,omitempty"`
	LastBackpressureEventAt         time.Time     `json:"lastBackpressureEventAt,omitempty"`
	PolicyRisk                      bool          `json:"policyRisk,omitempty"`
	PolicyRiskReason                string        `json:"policyRiskReason,omitempty"`
	PolicyRiskMode                  string        `json:"policyRiskMode,omitempty"`
	EstimatedMaxFragments           int           `json:"estimatedMaxFragments,omitempty"`
}

type RPCMuxSubprocessExecutionPolicy

type RPCMuxSubprocessExecutionPolicy struct {
	Command       string
	Args          []string
	WorkDir       string
	WorkDirRoot   string
	AllowCommands []string
	DenyCommands  []string
	Env           map[string]string
	EnvWhitelist  []string
}

RPCMuxSubprocessExecutionPolicy is the reusable validation contract for local subprocess execution. It is shared by profile validation and runtime construction so security checks cannot drift.

func (RPCMuxSubprocessExecutionPolicy) Validate

type RPCMuxSubprocessExecutionPolicyError

type RPCMuxSubprocessExecutionPolicyError struct {
	Category string
	Message  string
}

func (RPCMuxSubprocessExecutionPolicyError) Error

type RPCMuxSubprocessExecutionPolicySnapshot

type RPCMuxSubprocessExecutionPolicySnapshot struct {
	AllowCommands []string `json:"allowCommands,omitempty"`
	DenyCommands  []string `json:"denyCommands,omitempty"`
	WorkDirRoot   string   `json:"workDirRoot,omitempty"`
	EnvWhitelist  []string `json:"envWhitelist,omitempty"`
	EnvCount      int      `json:"envCount,omitempty"`
}

RPCMuxSubprocessExecutionPolicySnapshot is a redacted summary of the local process execution policy. It intentionally omits env values.

type RPCMuxSubprocessExporterConfig

type RPCMuxSubprocessExporterConfig struct {
	Command        string            `json:"command"`
	Args           []string          `json:"args,omitempty"`
	Timeout        time.Duration     `json:"timeout,omitempty"`
	MaxOutputBytes int64             `json:"maxOutputBytes,omitempty"`
	WorkDir        string            `json:"workDir,omitempty"`
	WorkDirRoot    string            `json:"workDirRoot,omitempty"`
	AllowCommands  []string          `json:"allowCommands,omitempty"`
	DenyCommands   []string          `json:"denyCommands,omitempty"`
	Env            map[string]string `json:"env,omitempty"`
	EnvWhitelist   []string          `json:"envWhitelist,omitempty"`
}

RPCMuxSubprocessExporterConfig configures a local subprocess exporter. The executable and arguments are passed directly to exec.CommandContext; shell command strings are intentionally unsupported.

func (RPCMuxSubprocessExporterConfig) ExecutionPolicy

type RPCMuxSubprocessExporterSnapshot

type RPCMuxSubprocessExporterSnapshot struct {
	Command             string                                  `json:"command"`
	ArgsCount           int                                     `json:"argsCount"`
	WorkDir             string                                  `json:"workDir,omitempty"`
	Timeout             time.Duration                           `json:"timeout"`
	MaxOutputBytes      int64                                   `json:"maxOutputBytes"`
	Policy              RPCMuxSubprocessExecutionPolicySnapshot `json:"policy"`
	Runs                int64                                   `json:"runs"`
	LastExitCode        int                                     `json:"lastExitCode,omitempty"`
	LastDuration        time.Duration                           `json:"lastDuration,omitempty"`
	LastTimedOut        bool                                    `json:"lastTimedOut,omitempty"`
	LastOutputTruncated bool                                    `json:"lastOutputTruncated,omitempty"`
	LastError           string                                  `json:"lastError,omitempty"`
	LastRunAt           time.Time                               `json:"lastRunAt,omitempty"`
}

RPCMuxSubprocessExporterSnapshot exposes subprocess delivery diagnostics without event payloads, environment values, or profile material.

type RPCMuxSubprocessExporterSnapshotter

type RPCMuxSubprocessExporterSnapshotter interface {
	RPCMuxSubprocessExporterSnapshot() RPCMuxSubprocessExporterSnapshot
}

RPCMuxSubprocessExporterSnapshotter exposes subprocess delivery diagnostics.

type RPCMuxTransportDiagnosis

type RPCMuxTransportDiagnosis struct {
	Enabled     bool                             `json:"enabled"`
	Mode        string                           `json:"mode,omitempty"`
	Candidate   ExperimentalMuxCandidateSnapshot `json:"candidate,omitempty"`
	Adapter     ExperimentalMuxAdapterSnapshot   `json:"adapter,omitempty"`
	Transport   ExperimentalMuxTransportSnapshot `json:"transport,omitempty"`
	Negotiation RPCMuxNegotiationDiagnosis       `json:"negotiation,omitempty"`
	FlowControl RPCMuxFlowControlDiagnosis       `json:"flowControl,omitempty"`
	Keepalive   RPCMuxKeepaliveDiagnosis         `json:"keepalive,omitempty"`
	Drain       RPCMuxDrainDiagnosis             `json:"drain,omitempty"`
	Manager     RPCMuxConnectionManagerDiagnosis `json:"manager,omitempty"`
	Events      []RPCMuxDiagnosisEvent           `json:"events,omitempty"`
}

func FilterRPCMuxDiagnosisByFlowControlEvent

func FilterRPCMuxDiagnosisByFlowControlEvent(diagnosis RPCMuxTransportDiagnosis, event string) RPCMuxTransportDiagnosis

type RPCPolicy

type RPCPolicy struct {
	Timeout     time.Duration            `json:"timeout,omitempty"`
	Retry       governance.RetryPolicy   `json:"retry,omitempty"`
	Hedge       RPCHedgePolicy           `json:"hedge,omitempty"`
	Fallback    RPCFallbackPolicy        `json:"fallback,omitempty"`
	Breaker     governance.BreakerPolicy `json:"breaker,omitempty"`
	LoadShedder RPCLoadShedderPolicy     `json:"loadShedder,omitempty"`
	Balancer    RPCBalancerPolicy        `json:"balancer,omitempty"`
	Metadata    map[string]string        `json:"metadata,omitempty"`
	Headers     map[string]string        `json:"headers,omitempty"`
	Methods     map[string]RPCPolicy     `json:"methods,omitempty"`
}

RPCPolicy is the transport-neutral policy contract used by RPC clients, servers and generated manifests. It intentionally mirrors governance.Policy without tying future endpoint-chain work to a single rule source.

func RPCPolicyFromGovernance

func RPCPolicyFromGovernance(policy governance.Policy) RPCPolicy

func (RPCPolicy) Validate

func (p RPCPolicy) Validate() error

type RPCPolicyProvider

type RPCPolicyProvider interface {
	RPCPolicy(context.Context, governance.Request) (RPCPolicy, error)
}

type RPCPolicyProviderFunc

type RPCPolicyProviderFunc func(context.Context, governance.Request) (RPCPolicy, error)

func (RPCPolicyProviderFunc) RPCPolicy

type RPCPolicyRuntimeCacheSnapshot

type RPCPolicyRuntimeCacheSnapshot struct {
	RateLimiters        int `json:"rateLimiters,omitempty"`
	ConcurrencyLimiters int `json:"concurrencyLimiters,omitempty"`
	Breakers            int `json:"breakers,omitempty"`
	Balancers           int `json:"balancers,omitempty"`
}

type RPCPolicyRuntimeContributor

type RPCPolicyRuntimeContributor struct {
	Name   string
	Client RPCPolicyRuntimeSnapshotSource
}

func (RPCPolicyRuntimeContributor) ContributeSnapshot

func (c RPCPolicyRuntimeContributor) ContributeSnapshot(ctx context.Context, snapshot *controlplane.Snapshot) error

type RPCPolicyRuntimeSnapshot

type RPCPolicyRuntimeSnapshot struct {
	Policy            RPCPolicy                     `json:"policy,omitempty"`
	State             RPCPolicyRuntimeState         `json:"state"`
	Cache             RPCPolicyRuntimeCacheSnapshot `json:"cache,omitempty"`
	MethodPolicyCount int                           `json:"methodPolicyCount,omitempty"`
	MethodPolicyKeys  []string                      `json:"methodPolicyKeys,omitempty"`
	Priority          []string                      `json:"priority,omitempty"`
	Capabilities      []string                      `json:"capabilities,omitempty"`
}

type RPCPolicyRuntimeSnapshotSource

type RPCPolicyRuntimeSnapshotSource interface {
	PolicyRuntimeSnapshot() RPCPolicyRuntimeSnapshot
}

type RPCPolicyRuntimeState

type RPCPolicyRuntimeState struct {
	TimeoutEnforced     bool          `json:"timeoutEnforced"`
	EffectiveTimeout    time.Duration `json:"effectiveTimeout,omitempty"`
	RetryAttempts       int           `json:"retryAttempts,omitempty"`
	RetryBackoff        time.Duration `json:"retryBackoff,omitempty"`
	BreakerEnabled      bool          `json:"breakerEnabled"`
	Balancer            string        `json:"balancer,omitempty"`
	LoadShedderEnabled  bool          `json:"loadShedderEnabled"`
	LoadShedderLimit    int           `json:"loadShedderLimit,omitempty"`
	LoadShedderMode     string        `json:"loadShedderMode,omitempty"`
	LoadShedderWindow   time.Duration `json:"loadShedderWindow,omitempty"`
	FallbackEnabled     bool          `json:"fallbackEnabled"`
	FallbackTarget      string        `json:"fallbackTarget,omitempty"`
	HedgeEnabled        bool          `json:"hedgeEnabled"`
	HedgeAttempts       int           `json:"hedgeAttempts,omitempty"`
	GovernanceBacked    bool          `json:"governanceBacked"`
	ExplicitPolicyBound bool          `json:"explicitPolicyBound"`
	DynamicPolicyBound  bool          `json:"dynamicPolicyBound"`
}

type RPCResolverRuntimeSnapshot

type RPCResolverRuntimeSnapshot struct {
	Type     string            `json:"type,omitempty"`
	Watch    bool              `json:"watch"`
	Snapshot *ResolverSnapshot `json:"snapshot,omitempty"`
}

type RPCRetryDiagnosisSnapshot

type RPCRetryDiagnosisSnapshot struct {
	Enabled  bool          `json:"enabled"`
	Attempts int           `json:"attempts,omitempty"`
	Backoff  time.Duration `json:"backoff,omitempty"`
}

type RPCRuntimeContributor

type RPCRuntimeContributor struct {
	Name   string
	Client RPCRuntimeSnapshotSource
}

func (RPCRuntimeContributor) ContributeSnapshot

func (c RPCRuntimeContributor) ContributeSnapshot(ctx context.Context, snapshot *controlplane.Snapshot) error

type RPCRuntimeSnapshot

type RPCRuntimeSnapshot struct {
	Target      string                      `json:"target,omitempty"`
	Codec       string                      `json:"codec,omitempty"`
	Transport   RPCHTTPTransportSnapshot    `json:"transport,omitempty"`
	Middlewares RPCEndpointChainSnapshot    `json:"middlewares,omitempty"`
	Resolver    RPCResolverRuntimeSnapshot  `json:"resolver,omitempty"`
	Balancer    string                      `json:"balancer,omitempty"`
	ConnPool    ConnPoolManagerSnapshot     `json:"connPool,omitempty"`
	Policy      RPCPolicyRuntimeSnapshot    `json:"policy"`
	Discovery   RPCDiscoveryRuntimeSnapshot `json:"discovery,omitempty"`
	Stats       callstats.Snapshot          `json:"stats,omitempty"`
	Warmup      RPCWarmupSnapshot           `json:"warmup,omitempty"`
	Diagnosis   RPCDiagnosisSnapshot        `json:"diagnosis,omitempty"`
}

type RPCRuntimeSnapshotSource

type RPCRuntimeSnapshotSource interface {
	RuntimeSnapshot() RPCRuntimeSnapshot
}

type RPCStreamConnPolicySnapshot

type RPCStreamConnPolicySnapshot struct {
	Mode              string `json:"mode,omitempty"`
	MaxStreamsPerConn int    `json:"maxStreamsPerConn,omitempty"`
	Reuse             bool   `json:"reuse"`
	Multiplexed       bool   `json:"multiplexed"`
}

type RPCStreamTransportSnapshot

type RPCStreamTransportSnapshot struct {
	Active          int64            `json:"active,omitempty"`
	Dials           int64            `json:"dials,omitempty"`
	DedicatedConns  int64            `json:"dedicatedConns,omitempty"`
	Closes          int64            `json:"closes,omitempty"`
	LastTarget      string           `json:"lastTarget,omitempty"`
	LastDialedAt    time.Time        `json:"lastDialedAt,omitempty"`
	LastClosedAt    time.Time        `json:"lastClosedAt,omitempty"`
	LastCloseCode   Code             `json:"lastCloseCode,omitempty"`
	LastCloseReason string           `json:"lastCloseReason,omitempty"`
	CloseCodes      map[Code]int64   `json:"closeCodes,omitempty"`
	CloseReasons    map[string]int64 `json:"closeReasons,omitempty"`
}

type RPCTimeoutConfig

type RPCTimeoutConfig struct {
	Server time.Duration
	Client time.Duration
}

type RPCWarmupConfig

type RPCWarmupConfig struct {
	Enabled      bool          `json:"enabled"`
	Timeout      time.Duration `json:"timeout,omitempty"`
	ConnPool     bool          `json:"connPool,omitempty"`
	MaxEndpoints int           `json:"maxEndpoints,omitempty"`
}

type RPCWarmupSnapshot

type RPCWarmupSnapshot struct {
	Enabled         bool          `json:"enabled"`
	Attempted       bool          `json:"attempted"`
	Completed       bool          `json:"completed"`
	ConnPoolEnabled bool          `json:"connPoolEnabled,omitempty"`
	Endpoints       []string      `json:"endpoints,omitempty"`
	Selected        string        `json:"selected,omitempty"`
	ConnPoolWarmed  int           `json:"connPoolWarmed,omitempty"`
	Duration        time.Duration `json:"duration,omitempty"`
	Error           string        `json:"error,omitempty"`
	At              time.Time     `json:"at,omitempty"`
}

type RegisterOption

type RegisterOption func(*registerOptions)

func WithRegisterTTL

func WithRegisterTTL(ttl time.Duration) RegisterOption

type Registrar

type Registrar interface {
	RegisterService(ctx context.Context, service string, endpoint string) error
	DeregisterService(ctx context.Context, service string, endpoint string) error
}

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Deregister

func (r *Registry) Deregister(service string, endpoint string)

func (*Registry) DeregisterService

func (r *Registry) DeregisterService(ctx context.Context, service string, endpoint string) error

func (*Registry) Discovery

func (r *Registry) Discovery() *discovery.MemoryRegistry

func (*Registry) Register

func (r *Registry) Register(service string, endpoint string)

func (*Registry) RegisterInstance

func (r *Registry) RegisterInstance(ctx context.Context, service string, instance ServiceInstance, opts ...RegisterOption) error

func (*Registry) RegisterService

func (r *Registry) RegisterService(ctx context.Context, service string, endpoint string) error

func (*Registry) RegisterServiceWithOptions

func (r *Registry) RegisterServiceWithOptions(ctx context.Context, service string, endpoint string, opts ...RegisterOption) error

func (*Registry) ResolveInstances

func (r *Registry) ResolveInstances(ctx context.Context, service string) ([]ServiceInstance, error)

func (*Registry) ResolveService

func (r *Registry) ResolveService(ctx context.Context, service string) ([]string, error)

func (*Registry) Resolver

func (r *Registry) Resolver(service string) Resolver

func (*Registry) WatchEvents

func (r *Registry) WatchEvents(ctx context.Context, service string) (<-chan discovery.Event, error)

func (*Registry) WatchService

func (r *Registry) WatchService(ctx context.Context, service string) (<-chan []string, error)

type Resolver

type Resolver interface {
	Resolve(ctx context.Context) ([]string, error)
}

type ResolverFunc

type ResolverFunc func(context.Context) ([]string, error)

func (ResolverFunc) Resolve

func (f ResolverFunc) Resolve(ctx context.Context) ([]string, error)

type ResolverSnapshot

type ResolverSnapshot struct {
	Endpoints   []string  `json:"endpoints"`
	Removed     []string  `json:"removed,omitempty"`
	Error       string    `json:"error,omitempty"`
	Watchers    int       `json:"watchers"`
	Updates     int64     `json:"updates"`
	Fallbacks   int64     `json:"fallbacks,omitempty"`
	Stale       bool      `json:"stale,omitempty"`
	LastUpdated time.Time `json:"lastUpdated,omitempty"`
}

type RoundRobinBalancer

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

RoundRobinBalancer selects endpoints in round-robin order.

func (*RoundRobinBalancer) Pick

func (b *RoundRobinBalancer) Pick(ctx context.Context, endpoints []string) (string, error)

type RuntimeDescriber

type RuntimeDescriber interface {
	RuntimeDescriptor() Descriptor
}

type Server

type Server interface {
	RegisterService(desc ServiceDesc, impl any) error
	GetServiceInfos() map[string]ServiceDesc
	GetServiceDescriptors() map[string]Descriptor
	GetServiceDescriptor(name string) (Descriptor, bool)
	Run() error
	Stop(ctx context.Context) error
}

type ServerDiagnosisSnapshot

type ServerDiagnosisSnapshot struct {
	Service      string                        `json:"service,omitempty"`
	Method       string                        `json:"method,omitempty"`
	Endpoint     string                        `json:"endpoint,omitempty"`
	ConnectionID string                        `json:"connectionId,omitempty"`
	PoolSlot     int                           `json:"poolSlot,omitempty"`
	FlowControl  string                        `json:"flowControl,omitempty"`
	EventFamily  string                        `json:"eventFamily,omitempty"`
	Event        string                        `json:"event,omitempty"`
	Matched      bool                          `json:"matched"`
	State        StateSnapshot                 `json:"state"`
	Services     []ServiceSnapshot             `json:"services,omitempty"`
	PolicyCache  RPCPolicyRuntimeCacheSnapshot `json:"policyCache,omitempty"`
	Mux          RPCMuxTransportDiagnosis      `json:"mux,omitempty"`
	GeneratedAt  time.Time                     `json:"generatedAt"`
}

type ServerOption

type ServerOption func(*serverOptions)

func WithAddress

func WithAddress(addr string) ServerOption

func WithExperimentalMuxServerAdapter

func WithExperimentalMuxServerAdapter(adapter ExperimentalMuxServerDiagnosisSource) ServerOption

WithExperimentalMuxServerAdapter exposes an opt-in experimental mux server adapter through RPC admin runtime and diagnosis probes. It does not replace the default HTTP upgrade stream endpoint.

func WithKitexServerInterceptors

func WithKitexServerInterceptors(interceptors ...KitexInterceptor) ServerOption

func WithRegistry

func WithRegistry(registrar Registrar, serviceName string, advertiseEndpoint string) ServerOption

func WithRegistryRefreshInterval

func WithRegistryRefreshInterval(interval time.Duration) ServerOption

func WithRegistryTTL

func WithRegistryTTL(ttl time.Duration) ServerOption

func WithServerAdaptiveBreaker

func WithServerAdaptiveBreaker(brk *breaker.AdaptiveBreaker) ServerOption

func WithServerAdaptiveLimiter

func WithServerAdaptiveLimiter(limiter *limit.AdaptiveLimiter) ServerOption

func WithServerAdminAuditSink

func WithServerAdminAuditSink(sink controladmin.AuditSink) ServerOption

func WithServerAdminToken

func WithServerAdminToken(token string) ServerOption

func WithServerCodec

func WithServerCodec(codec Codec) ServerOption

func WithServerGovernanceManager

func WithServerGovernanceManager(manager *governance.Manager) ServerOption

func WithServerGovernanceRuleSet

func WithServerGovernanceRuleSet(rules *governance.RuleSet) ServerOption

func WithServerGovernanceSuite

func WithServerGovernanceSuite(suite *governance.Suite) ServerOption

func WithServerMaxConcurrency

func WithServerMaxConcurrency(max int) ServerOption

func WithServerMiddleware

func WithServerMiddleware(mw endpoint.Middleware) ServerOption

func WithServerMuxDiagnosisAuditValidateCooldown

func WithServerMuxDiagnosisAuditValidateCooldown(cooldown time.Duration) ServerOption

WithServerMuxDiagnosisAuditValidateCooldown throttles the read-only audit details validation endpoint. A zero cooldown (the default) leaves the endpoint unthrottled so batch validation is not crippled; a positive value rejects calls that arrive within the cooldown window, mirroring the debug replay cooldown governance style.

func WithServerMuxDiagnosisDebugReplayCooldown

func WithServerMuxDiagnosisDebugReplayCooldown(cooldown time.Duration) ServerOption

func WithServerMuxDiagnosisEventExporter

func WithServerMuxDiagnosisEventExporter(exporter RPCMuxDiagnosisEventExporter, filter RPCMuxDiagnosisFilter) ServerOption

WithServerMuxDiagnosisEventExporter enables explicit server-side mux diagnosis export. Use HTTPServer.ObserveMuxDiagnosis after capturing an admin or runtime snapshot.

func WithServerMuxDiagnosisEventExporterDelivery

func WithServerMuxDiagnosisEventExporterDelivery(exporter RPCMuxDiagnosisEventExporter, filter RPCMuxDiagnosisFilter, config RPCMuxDiagnosisExporterDeliveryConfig) ServerOption

WithServerMuxDiagnosisEventExporterDelivery enables bounded asynchronous delivery for a server-side mux diagnosis exporter.

func WithServerMuxDiagnosisEventLogging

func WithServerMuxDiagnosisEventLogging(logger *slog.Logger, filter RPCMuxDiagnosisFilter) ServerOption

WithServerMuxDiagnosisEventLogging exports server-side mux diagnosis events through slog.

func WithServerMuxDiagnosisOperatorApprovalToken

func WithServerMuxDiagnosisOperatorApprovalToken(token string) ServerOption

WithServerMuxDiagnosisOperatorApprovalToken enables approved mux sink operator actions. Without this token, admin action requests remain dry-run.

func WithServerReadHeaderTimeout

func WithServerReadHeaderTimeout(timeout time.Duration) ServerOption

func WithServerRuleSet

func WithServerRuleSet(rules *governance.RuleSet) ServerOption

func WithServerStreamMiddleware

func WithServerStreamMiddleware(mw StreamMiddleware) ServerOption

func WithServerSuite

func WithServerSuite(suite Suite) ServerOption

func WithServerTLS

func WithServerTLS(certFile string, keyFile string) ServerOption

func WithServerTLSConfig

func WithServerTLSConfig(cfg security.TLSConfig) ServerOption

WithServerTLSConfig configures TLS or mutual TLS for the self-developed RPC server. Set CertFile/KeyFile for TLS and ClientCAFile to additionally require and verify client certificates (mTLS).

type ServiceDesc

type ServiceDesc struct {
	Name     string
	Version  string
	Metadata map[string]string
	Methods  []MethodDesc
	Streams  []StreamDesc
}

ServiceDesc describes a registered RPC service.

func BindGenericHandlers

func BindGenericHandlers(desc ServiceDesc, handlers map[string]GenericHandler) (ServiceDesc, error)

func CloneServiceDesc

func CloneServiceDesc(desc ServiceDesc) ServiceDesc

func (ServiceDesc) Descriptor

func (d ServiceDesc) Descriptor() Descriptor

func (ServiceDesc) Method

func (d ServiceDesc) Method(name string) (MethodDesc, bool)

func (ServiceDesc) MethodPath

func (d ServiceDesc) MethodPath(name string) (string, error)

func (ServiceDesc) MustMethodPath

func (d ServiceDesc) MustMethodPath(name string) string

func (ServiceDesc) MustStreamPath

func (d ServiceDesc) MustStreamPath(name string) string

func (ServiceDesc) Stream

func (d ServiceDesc) Stream(name string) (StreamDesc, bool)

func (ServiceDesc) StreamPath

func (d ServiceDesc) StreamPath(name string) (string, error)

func (ServiceDesc) Validate

func (d ServiceDesc) Validate() error

type ServiceInstance

type ServiceInstance struct {
	Endpoint string            `json:"endpoint"`
	Weight   int               `json:"weight,omitempty"`
	Version  string            `json:"version,omitempty"`
	Zone     string            `json:"zone,omitempty"`
	Status   string            `json:"status,omitempty"`
	Tags     map[string]string `json:"tags,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type ServiceSnapshot

type ServiceSnapshot struct {
	Name          string                 `json:"name"`
	Version       string                 `json:"version,omitempty"`
	Metadata      map[string]string      `json:"metadata,omitempty"`
	Methods       []string               `json:"methods"`
	MethodDetails []MethodSnapshot       `json:"methodDetails,omitempty"`
	Streams       []StreamMethodSnapshot `json:"streams,omitempty"`
}

ServiceSnapshot captures the runtime state of a registered RPC service.

type SingleflightKeyFunc

type SingleflightKeyFunc func(ctx context.Context, method string, request any) (string, error)

type StateSnapshot

type StateSnapshot struct {
	Address           string        `json:"address"`
	AdvertiseEndpoint string        `json:"advertiseEndpoint,omitempty"`
	State             string        `json:"state"`
	Since             time.Time     `json:"since"`
	For               time.Duration `json:"for"`
}

type StaticResolver

type StaticResolver struct {
	Endpoints []string
}

func NewStaticResolver

func NewStaticResolver(endpoints ...string) StaticResolver

func (StaticResolver) Resolve

func (r StaticResolver) Resolve(ctx context.Context) ([]string, error)

func (StaticResolver) Snapshot

func (r StaticResolver) Snapshot() ResolverSnapshot

type Stream

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

func (*Stream) Close

func (s *Stream) Close() error

func (*Stream) Recv

func (s *Stream) Recv(v any) error

func (*Stream) Send

func (s *Stream) Send(v any) error

func (*Stream) SendError

func (s *Stream) SendError(code Code, text string) error

type StreamDesc

type StreamDesc struct {
	Name        string
	Handler     StreamHandler
	NewMessage  func() any
	Message     string
	Codec       string
	Mode        StreamMode
	Timeout     time.Duration
	Metadata    map[string]string
	Middlewares []StreamMiddleware
}

StreamDesc describes a single RPC stream.

type StreamDescriptor

type StreamDescriptor struct {
	Name     string            `json:"name"`
	Timeout  time.Duration     `json:"timeout,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
	Message  string            `json:"message,omitempty"`
	Codec    string            `json:"codec,omitempty"`
	Mode     StreamMode        `json:"mode,omitempty"`
}

type StreamHandler

type StreamHandler func(ctx context.Context, stream *Stream) error

StreamHandler is an RPC streaming handler.

type StreamMethodSnapshot

type StreamMethodSnapshot struct {
	Name        string            `json:"name"`
	Message     string            `json:"message,omitempty"`
	Timeout     string            `json:"timeout,omitempty"`
	Metadata    map[string]string `json:"metadata,omitempty"`
	Middlewares int               `json:"middlewares,omitempty"`
}

StreamMethodSnapshot captures the metadata for a streaming RPC method.

type StreamMiddleware

type StreamMiddleware func(StreamHandler) StreamHandler

StreamMiddleware wraps a streaming RPC handler with cross-cutting behavior.

func StreamLoggingMiddleware

func StreamLoggingMiddleware(name string) StreamMiddleware

func StreamLoggingMiddlewareWithSampler

func StreamLoggingMiddlewareWithSampler(name string, sampler trace.Sampler) StreamMiddleware

func StreamMetricsMiddleware

func StreamMetricsMiddleware(name string, reg *metrics.Registry) StreamMiddleware

func StreamRecoverMiddleware

func StreamRecoverMiddleware() StreamMiddleware

func StreamRequestIDMiddleware

func StreamRequestIDMiddleware() StreamMiddleware

func StreamServerAuthMiddleware

func StreamServerAuthMiddleware(validator auth.Validator) StreamMiddleware

func StreamTraceMiddleware

func StreamTraceMiddleware(service string) StreamMiddleware

func StreamTraceMiddlewareWithSampler

func StreamTraceMiddlewareWithSampler(service string, sampler trace.Sampler) StreamMiddleware

type StreamMode

type StreamMode string
const (
	StreamModeUnary        StreamMode = "unary"
	StreamModeClientStream StreamMode = "client_stream"
	StreamModeServerStream StreamMode = "server_stream"
	StreamModeBidiStream   StreamMode = "bidi_stream"
)

type Suite

type Suite interface {
	ServerOptions() []ServerOption
	ClientOptions() []ClientOption
}

func GovernanceSuite

func GovernanceSuite(name string, conf GovernanceConfig) Suite

func ObservabilitySuite

func ObservabilitySuite(name string, timeout time.Duration) Suite

type TransportConfig

type TransportConfig struct {
	Timeout               time.Duration                         `json:"timeout"`
	MaxIdleConns          int                                   `json:"maxIdleConns"`
	MaxIdleConnsPerHost   int                                   `json:"maxIdleConnsPerHost"`
	MaxConnsPerHost       int                                   `json:"maxConnsPerHost"`
	DialTimeout           time.Duration                         `json:"dialTimeout"`
	KeepAlive             time.Duration                         `json:"keepAlive"`
	IdleConnTimeout       time.Duration                         `json:"idleConnTimeout"`
	TLSHandshakeTimeout   time.Duration                         `json:"tlsHandshakeTimeout"`
	ResponseHeaderTimeout time.Duration                         `json:"responseHeaderTimeout"`
	ExpectContinueTimeout time.Duration                         `json:"expectContinueTimeout"`
	Proxy                 func(*http.Request) (*url.URL, error) `json:"-"`
	TLSClientConfig       *tls.Config                           `json:"-"`
}

func DefaultTransportConfig

func DefaultTransportConfig() TransportConfig

type TransportStats

type TransportStats struct {
	FramesIn  int64 `json:"framesIn"`
	FramesOut int64 `json:"framesOut"`
	BytesIn   int64 `json:"bytesIn"`
	BytesOut  int64 `json:"bytesOut"`
}

type WatchResolver

type WatchResolver interface {
	Resolver
	Watch(ctx context.Context) (<-chan []string, error)
}

type WeightedRoundRobinBalancer

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

WeightedRoundRobinBalancer selects endpoints using weighted round-robin.

func NewWeightedRoundRobinBalancer

func NewWeightedRoundRobinBalancer(weights map[string]int) *WeightedRoundRobinBalancer

func (*WeightedRoundRobinBalancer) Pick

func (b *WeightedRoundRobinBalancer) Pick(ctx context.Context, endpoints []string) (string, error)

Directories

Path Synopsis
Package endpoint provides RPC client middleware primitives: chaining, hedging, timeouts and retries.
Package endpoint provides RPC client middleware primitives: chaining, hedging, timeouts and retries.
Package grpc provides gRPC server and client wrappers with governance, authentication, observability and OpenTelemetry tracing.
Package grpc provides gRPC server and client wrappers with governance, authentication, observability and OpenTelemetry tracing.

Jump to

Keyboard shortcuts

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