client

package
v0.0.0-...-7429660 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPoolSize       = 5
	DefaultPoolTTL        = time.Minute
	DefaultDialTimeout    = time.Second * 5
	DefaultRetries        = 1
	DefaultRequestTimeout = time.Second * 1
)

Functions

This section is empty.

Types

type CallOption

type CallOption func(*CallOptions)

CallOption used by Invoke

func WithRequestTimeout

func WithRequestTimeout(d time.Duration) CallOption

WithRequestTimeout is a CallOption which overrides that which set in Options.CallOptions

func WithRetries

func WithRetries(i int) CallOption

WithRetries is a CallOption which overrides that which set in Options.CallOptions

type CallOptions

type CallOptions struct {
	// Number of Call attempts
	Retries int
	// Request/Response timeout
	RequestTimeout time.Duration
}

type Client

type Client interface {
	Invoke(context.Context, interface{}, interface{}, ...CallOption) error
}

func HClient

func HClient(endpoint string, options ...Option) Client

func SClient

func SClient(endpoint string, options ...Option) Client

type Factory

type Factory interface {
	Client(endpoint string) Client
}

func HFactory

func HFactory(opts ...Option) Factory

func SFactory

func SFactory(opts ...Option) Factory

type Option

type Option func(*Options)

func Breaker

func Breaker(config *breaker.Config) Option

func Cluster

func Cluster(cluster *upstream.Cluster) Option

func Codec

func Codec(codec codec.Codec) Option

Codec sets the codec

func DialTimeout

func DialTimeout(d time.Duration) Option

Transport dial timeout

func KeepAlivesDisable

func KeepAlivesDisable(t bool) Option

func Kit

func Kit(logger log.Kit) Option

Logger sets the logger

func Limiter

func Limiter(config *ratelimit.Config) Option

func MaxIdleConns

func MaxIdleConns(d int) Option

func MaxIdleConnsPerHost

func MaxIdleConnsPerHost(d int) Option

func Name

func Name(n string) Option

func Namespace

func Namespace(n string) Option

func PoolSize

func PoolSize(d int) Option

PoolSize sets the connection pool size

func PoolTTL

func PoolTTL(d time.Duration) Option

PoolSize sets the connection pool size

func RequestTimeout

func RequestTimeout(d time.Duration) Option

The request timeout. Should this be a Call Option?

func Retries

func Retries(i int) Option

Number of retries when making the request. Should this be a Call Option?

func SDName

func SDName(n string) Option

func Slow

func Slow(slow time.Duration) Option

func Tracer

func Tracer(tracer opentracing.Tracer) Option

Tracer sets the opentracing tracer

type Options

type Options struct {
	Retries   int
	Kit       log.Kit
	Tracer    opentracing.Tracer
	Codec     codec.Codec
	Name      string // 包含app_name的下游service_name
	SDName    string
	Slow      time.Duration
	Limiter   *ratelimit.Config
	Breaker   *breaker.Config
	Cluster   *upstream.Cluster
	Namespace string

	// Connection Pool
	PoolSize int
	PoolTTL  time.Duration
	// Transport Dial Timeout
	DialTimeout time.Duration

	// Default CallOptions
	CallOptions CallOptions
	// contains filtered or unexported fields
}

Directories

Path Synopsis
old

Jump to

Keyboard shortcuts

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