client

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShardFromContext

func ShardFromContext(ctx context.Context) shard.Name

ShardFromContext returns the value of the shard key on the ctx, or an empty Name if there is no shard key.

func WithDefaultShardRoundTripper

func WithDefaultShardRoundTripper(cfg *rest.Config, shard clientshard.Name) *rest.Config

WithDefaultShardRoundTripper wraps an existing config's with DefaultShardRoundTripper

Note: it is the caller responsibility to make a copy of the rest config

func WithShardInContext

func WithShardInContext(parent context.Context, shard shard.Name) context.Context

WithShardInContext returns a context with the given shard set

func WithShardRoundTripper

func WithShardRoundTripper(cfg *rest.Config) *rest.Config

WithShardRoundTripper wraps an existing config's with ShardRoundTripper.

Note: it is the caller responsibility to make a copy of the rest config

Types

type DefaultShardRoundTripper

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

DefaultShardRoundTripper is a http.RoundTripper that sets a default shard name if not specified in the context

func NewDefaultShardRoundTripper

func NewDefaultShardRoundTripper(delegate http.RoundTripper, shard clientshard.Name) *DefaultShardRoundTripper

NewDefaultShardRoundTripper creates a new round tripper that sets a default shard name

func (*DefaultShardRoundTripper) RoundTrip

func (c *DefaultShardRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type ShardRoundTripper

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

ShardRoundTripper is a shard aware wrapper around http.RoundTripper. It changes the URL path to target a shard from the context.

For example given "amber" shard name in the context it will change apis/apis.kcp.dev/v1alpha1/apiexports to /shards/amber/apis/apis.kcp.dev/v1alpha1/apiexports

func NewShardRoundTripper

func NewShardRoundTripper(delegate http.RoundTripper) *ShardRoundTripper

NewShardRoundTripper creates a new shard aware round tripper

func (*ShardRoundTripper) RoundTrip

func (c *ShardRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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