client

package
v0.0.0-...-ad68a05 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultPoolMaxStreams maximum streams on a connectioin
	// (20)
	DefaultPoolMaxStreams = 20

	// DefaultPoolMaxIdle maximum idle conns of a pool
	// (50)
	DefaultPoolMaxIdle = 50
	// // DefaultNamingClient is a default client to use out of the box
	//  DefaultNamingClient Client = newNamingClient()
	// // DefaultIPAddrClient is a default client to use addr to connection
	// DefaultIPAddrClient Client = newIPAddrClient()
	// DefaultRetries is the default number of times a request is tried
	DefaultRetries = 1
	// DefaultRequestTimeout is the default request timeout
	DefaultRequestTimeout = time.Second * 5
	// DefaultPoolSize sets the connection pool size
	DefaultPoolSize = 100
	// DefaultPoolTTL sets the connection pool ttl
	DefaultPoolTTL = time.Minute

	// DefaultPoolTimeout sets the connection pool ttl
	DefaultPoolTimeout = 5 * time.Second

	// NewClient returns a new client
	NewClient func(...Option) Client = newNamingClient
	// NewIPAddrClient returns a new client
	NewIPAddrClient func(...Option) Client = newIPAddrClient
)

Functions

This section is empty.

Types

type Client

type Client interface {
	Init(...Option) error
	Options() Options
	String() string
	Next() (*poolConn, error) // next connon

}

Client is the interface used to make requests to services. It supports Request/Response via Transport and Publishing via the Broker. It also supports bidirectional streaming of requests.

type Option

type Option func(*Options)

Option used by the Client

func RegisterInterval

func RegisterInterval(t time.Duration) Option

RegisterInterval Register the service with at interval

func RegisterTTL

func RegisterTTL(t time.Duration) Option

RegisterTTL Register the service with a TTL

func WithName

func WithName(name string) Option

WithName 设置客户端名字

func WithPoolSize

func WithPoolSize(d int) Option

WithPoolSize sets the connection pool size

func WithPoolTTL

func WithPoolTTL(d time.Duration) Option

WithPoolTTL sets the connection pool ttl

func WithRegistryNaming

func WithRegistryNaming(reg registry.RegNaming) Option

WithRegistryNaming 注册naming 服务发现

func WithScheme

func WithScheme(name string) Option

WithScheme 设置客户端服务名

func WithServiceIps

func WithServiceIps(ips []string) Option

WithServiceIps 设置服务ip列表

func WithServiceName

func WithServiceName(name string) Option

WithServiceName 设置服务名字

type Options

type Options struct {
	// Connection Pool
	PoolSize int
	PoolTTL  time.Duration
	TimeOut  time.Duration

	Registry *registry.Registry
	// registry
	// The register expiry time
	RegisterTTL time.Duration
	// The interval on which to register
	RegisterInterval time.Duration
	Scheme           string // client gmsec (注册名)

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
	// contains filtered or unexported fields
}

Options client of options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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