client

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomTransport

func CustomTransport() *http.Transport

func HTTPClient

func HTTPClient() *http.Client

func NewAuthValueRoundTripper added in v1.3.0

func NewAuthValueRoundTripper(base http.RoundTripper, auth *config.AuthValue) http.RoundTripper

func NewExtraHeaderRoundTripper added in v1.3.0

func NewExtraHeaderRoundTripper(
	base http.RoundTripper,
	headers map[string]string,
) http.RoundTripper

func NewOAuth2RoundTripper added in v1.3.0

func NewOAuth2RoundTripper(base http.RoundTripper) http.RoundTripper

func NewTokenExchangeRoundTrip added in v1.3.0

func NewTokenExchangeRoundTrip(base http.RoundTripper, registry TokenSource) http.RoundTripper

func OTELTransport

func OTELTransport() *otelhttp.Transport

func SafeHTTPClient

func SafeHTTPClient() *http.Client

func Transport

func Transport() http.RoundTripper

Types

type BaseTokenRegister added in v1.3.0

type BaseTokenRegister interface {
	Get(apiKey string) (oauth2.TokenSource, bool)
	Set(apiKey string, ts oauth2.TokenSource) error
	// GetOrCreate は apiKey に対応する TokenSource を取得し、存在しない場合のみ create で
	// 作成・登録する。この取得と登録を単一のアトミック操作として行う実装を要求する
	// (実装は sync.Map.LoadOrStore 等を想定)。これにより baseTokenRegistry.Get の
	// Get→Set という非アトミックな手順に起因する、同一 apiKey への同時初回アクセスでの
	// TokenSource 重複生成を防ぐ。
	GetOrCreate(apiKey string, create func() oauth2.TokenSource) oauth2.TokenSource
}

type InMemoryRegistry added in v1.3.0

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

func (*InMemoryRegistry) Get added in v1.3.0

func (r *InMemoryRegistry) Get(apiKey string) (oauth2.TokenSource, bool)

func (*InMemoryRegistry) GetOrCreate added in v1.3.0

func (r *InMemoryRegistry) GetOrCreate(
	apiKey string,
	create func() oauth2.TokenSource,
) oauth2.TokenSource

GetOrCreate は apiKey に対応する TokenSource を取得する。存在しない場合のみ create で 新規作成し、sync.Map.LoadOrStore によって取得と格納をアトミックに行う。これにより、 同一 apiKey に対して複数の goroutine が同時に初回アクセスした場合でも、最終的に 全ての呼び出し元が同じ TokenSource インスタンスを共有することを保証する (create が複数回呼ばれること自体はあり得るが、実際に保存・返却されるのは常に1つだけ)。

func (*InMemoryRegistry) Set added in v1.3.0

func (r *InMemoryRegistry) Set(apiKey string, ts oauth2.TokenSource) error

type TokenSource added in v1.3.0

type TokenSource interface {
	Get(key string) oauth2.TokenSource
}

func NewBaseTokenRegistry added in v1.3.0

func NewBaseTokenRegistry(url string, sources BaseTokenRegister) TokenSource

Jump to

Keyboard shortcuts

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