Documentation
¶
Overview ¶
Package rest provides a mesh-aware transport for client-go's rest.Config. It lets a generated clientset resolve a logical service name through the onexmesh registry and load-balance across its instances on every request, without giving up the typed client-go API surface.
Index ¶
- func MeshServiceName(host string) (string, bool)
- func NewForMeshConfig(serviceName string, opts ...Option) (*rest.Config, error)
- func SetDefaultRegistry(name string, opts any)
- type Option
- func WithBreaker(window, probeInterval time.Duration) Option
- func WithBulkhead(maxConcurrent int) Option
- func WithDiscovery(d registry.Discovery) Option
- func WithDiscoveryCache(ttl time.Duration, opts ...cache.Option) Option
- func WithRegistry(name string, opts any) Option
- func WithRetry(maxAttempts int, base, max time.Duration) Option
- func WithRetryable(f func(error) bool) Option
- func WithSelector(s selector.Selector) Option
- func WithTimeout(d time.Duration) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MeshServiceName ¶
MeshServiceName reports the service name when host is a onexmesh:// reference (e.g. "onexmesh://mb-ginserver" -> "mb-ginserver"), and ok=false otherwise.
func NewForMeshConfig ¶
NewForMeshConfig builds a client-go rest.Config whose transport discovers the logical service via the onexmesh registry and load-balances across its instances. The returned config is meant to be passed to a generated clientset's NewForConfig.
The caller owns any TLS configuration: for TLS-backed (https) instances set the returned config's TLSClientConfig (e.g. Insecure or CAData) before use.
func SetDefaultRegistry ¶
SetDefaultRegistry forwards to meshclient.SetDefaultRegistry so REST callers can configure the process-wide default registry without importing the gRPC client package.
Types ¶
type Option ¶
type Option func(*options)
Option configures a mesh-aware REST config (see NewForMeshConfig).
func WithBreaker ¶
WithBreaker enables a sliding-window circuit breaker around calls. window is the sliding window duration; probeInterval is how often a request is force-passed while throttling.
func WithBulkhead ¶
WithBulkhead isolates the downstream service by bounding the number of concurrent in-flight requests. A value <= 0 disables the bulkhead.
func WithDiscovery ¶
WithDiscovery injects a pre-built registry.Discovery, taking precedence over WithRegistry.
func WithDiscoveryCache ¶
WithDiscoveryCache wraps the discovery backend in a read-through cache with the given service TTL. When ttl <= 0 the cache is disabled.
func WithRegistry ¶
WithRegistry selects the registry backend and its options.
func WithRetry ¶
WithRetry enables retry with exponential backoff. base and max are the base and maximum backoff durations.
func WithRetryable ¶
WithRetryable sets the predicate deciding which errors are retried. When nil, every error surfaced by node selection or transport is retried (those are the only errors that reach the retry layer; HTTP status errors are returned to the caller untouched).
func WithSelector ¶
WithSelector overrides the default round-robin selector.
func WithTimeout ¶
WithTimeout imposes a per-call deadline.