Documentation ¶
Overview ¶
Package client contains core part of Kitex client. Users should not directly use any method here other than the options and call options. Users should call NewClient in the generated code, which wraps the NewClient call in this package.
Index ¶
- func CallOptionInfoFromCtx(ctx context.Context) (res string)
- func CallOptionsFromCtx(ctx context.Context) (res []callopt.Option)
- func NewCtxWithCallOptions(ctx context.Context, opts []callopt.Option) context.Context
- func WithMetaHandler(h remote.MetaHandler) client.Option
- type Client
- type Option
- func WithACLRules(rules ...acl.RejectFunc) Option
- func WithBackupRequest(p *retry.BackupPolicy) Option
- func WithBoundHandler(h remote.BoundHandler) Option
- func WithCircuitBreaker(s *circuitbreak.CBSuite) Option
- func WithClientBasicInfo(ebi *rpcinfo.EndpointBasicInfo) Option
- func WithCloseCallbacks(callback func() error) Option
- func WithCodec(c remote.Codec) Option
- func WithConnMetric() Optiondeprecated
- func WithConnPool(pool remote.ConnPool) Option
- func WithConnReporterEnabled() Option
- func WithConnectTimeout(d time.Duration) Option
- func WithDestService(svr string) Option
- func WithDiagnosisService(ds diagnosis.Service) Option
- func WithDialer(d remote.Dialer) Option
- func WithErrorHandler(f func(error) error) Option
- func WithFailureRetry(p *retry.FailurePolicy) Option
- func WithFirstMetaHandler(h remote.MetaHandler) Option
- func WithFramedTransport() Optiondeprecated
- func WithGeneric(g generic.Generic) Option
- func WithHTTPConnection() Option
- func WithHTTPResolver(r http.Resolver) Option
- func WithHostPorts(hostports ...string) Option
- func WithInstanceMW(mw endpoint.Middleware) Option
- func WithLoadBalancer(lb loadbalance.Loadbalancer, opts ...*lbcache.Options) Option
- func WithLogger(logger klog.FormatLogger) Option
- func WithLongConnection(cfg connpool.IdleConfig) Option
- func WithMiddleware(mw endpoint.Middleware) Option
- func WithMiddlewareBuilder(mwb endpoint.MiddlewareBuilder) Option
- func WithMuxConnection(connNum int) Option
- func WithPayloadCodec(c remote.PayloadCodec) Option
- func WithProxy(p proxy.ForwardProxy) Option
- func WithRPCTimeout(d time.Duration) Option
- func WithResolver(r discovery.Resolver) Option
- func WithRetryContainer(rc *retry.Container) Option
- func WithShortConnection() Option
- func WithStatsLevel(level stats.Level) Option
- func WithSuite(suite Suite) Option
- func WithTag(key, val string) Option
- func WithTimeoutProvider(p rpcinfo.TimeoutProvider) Option
- func WithTracer(c stats.Tracer) Option
- func WithTransHandlerFactory(f remote.ClientTransHandlerFactory) Option
- func WithTransportProtocol(tp transport.Protocol) Option
- type Options
- type Streaming
- type Suite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallOptionInfoFromCtx ¶
CallOptionInfoFromCtx retrieves the call Options debug information from the given context.
func CallOptionsFromCtx ¶
CallOptionsFromCtx retrieves call-Options from the given context.
func NewCtxWithCallOptions ¶
NewCtxWithCallOptions returns a new context associated with the given call-Options.
func WithMetaHandler ¶
func WithMetaHandler(h remote.MetaHandler) client.Option
WithMetaHandler adds a MetaHandler.
Types ¶
type Client ¶
type Client interface {
Call(ctx context.Context, method string, request, response interface{}) error
}
Client is the core interface abstraction of kitex client. It is designed for generated codes and should not be used directly. Parameter method specifies the method of a RPC call. Request is a packing of request parameters in the actual method defined in IDL, consist of zero, one or multiple arguments. So is response to the actual result type. Response may be nil to address oneway calls.
func NewClient ¶
func NewClient(svcInfo *serviceinfo.ServiceInfo, opts ...Option) (Client, error)
NewClient creates a kitex.Client with the given ServiceInfo, it is from generated code.
type Option ¶
Option is the only way to config client.
func WithACLRules ¶
func WithACLRules(rules ...acl.RejectFunc) Option
WithACLRules adds ACL rules. Note that the ACL checking process happens before service discovery.
func WithBackupRequest ¶
func WithBackupRequest(p *retry.BackupPolicy) Option
WithBackupRequest sets the backup request policy for client.
func WithBoundHandler ¶
func WithBoundHandler(h remote.BoundHandler) Option
WithBoundHandler adds remote.BoundHandler for client.
func WithCircuitBreaker ¶ added in v0.0.5
func WithCircuitBreaker(s *circuitbreak.CBSuite) Option
WithCircuitBreaker adds a circuitbreaker suite for the client.
func WithClientBasicInfo ¶
func WithClientBasicInfo(ebi *rpcinfo.EndpointBasicInfo) Option
WithClientBasicInfo provides initial information for client endpoint in RPCInfo.
func WithCloseCallbacks ¶
WithCloseCallbacks adds callback to Close
func WithConnMetric
deprecated
func WithConnMetric() Option
WithConnMetric to enable reporting connection pool stats.
Deprecated: Use WithConnReporterEnabled instead.
func WithConnPool ¶
WithConnPool sets the connection pool. Note that this option can only be specified once. If more than one pool is specified by this option, only the first one will be used.
func WithConnReporterEnabled ¶
func WithConnReporterEnabled() Option
WithConnReporterEnabled to enable reporting connection pool stats.
func WithConnectTimeout ¶
WithConnectTimeout specifies the connection timeout.
func WithDestService ¶
WithDestService specifies the name of target service.
func WithDiagnosisService ¶
WithDiagnosisService sets the diagnosis service for gathering debug informations.
func WithDialer ¶
WithDialer sets the Dialer for creating connections.
func WithErrorHandler ¶
WithErrorHandler sets the error handler.
func WithFailureRetry ¶
func WithFailureRetry(p *retry.FailurePolicy) Option
WithFailureRetry sets the failure retry policy for client.
func WithFirstMetaHandler ¶
func WithFirstMetaHandler(h remote.MetaHandler) Option
WithFirstMetaHandler adds a MetaHandler.
func WithFramedTransport
deprecated
func WithFramedTransport() Option
WithFramedTransport to use framed transport
Deprecated: Use WithTransportProtocol(transport.Framed) instead.
IMPORTANT: this option will be deleted in the future!!!
func WithGeneric ¶
WithGeneric set Generic type for generic call
func WithHTTPConnection ¶
func WithHTTPConnection() Option
WithHTTPConnection specifies client use RPC over http.
func WithHTTPResolver ¶
WithHTTPResolver specifies resolver for url (which specified by WithURL).
func WithHostPorts ¶
WithHostPorts specifies the target instance addresses when doing service discovery. It overwrites the results from the Resolver.
func WithInstanceMW ¶
func WithInstanceMW(mw endpoint.Middleware) Option
WithInstanceMW adds middleware for client to handle request after service discovery and loadbalance process.
func WithLoadBalancer ¶
func WithLoadBalancer(lb loadbalance.Loadbalancer, opts ...*lbcache.Options) Option
WithLoadBalancer sets the loadbalancer for client.
func WithLogger ¶
func WithLogger(logger klog.FormatLogger) Option
WithLogger sets the Logger for kitex client. Deprecated: client uses the global klog.DefaultLogger.
func WithLongConnection ¶
func WithLongConnection(cfg connpool.IdleConfig) Option
WithLongConnection enables long connection with kitex's built-in pooling implementation.
func WithMiddleware ¶
func WithMiddleware(mw endpoint.Middleware) Option
WithMiddleware adds middleware for client to handle request.
func WithMiddlewareBuilder ¶
func WithMiddlewareBuilder(mwb endpoint.MiddlewareBuilder) Option
WithMiddlewareBuilder adds middleware that depend on context for client to handle request
func WithMuxConnection ¶
WithMuxConnection specifies the transport type to be mux.
func WithPayloadCodec ¶
func WithPayloadCodec(c remote.PayloadCodec) Option
WithPayloadCodec to set a payloadCodec that handle other payload which not support by kitex
func WithProxy ¶
func WithProxy(p proxy.ForwardProxy) Option
WithProxy sets the forward Proxy for client.
func WithRPCTimeout ¶
WithRPCTimeout specifies the RPC timeout.
func WithResolver ¶
WithResolver provides the Resolver for kitex client.
func WithRetryContainer ¶
WithRetryContainer sets Container
func WithShortConnection ¶ added in v0.0.2
func WithShortConnection() Option
WithShortConnection forces kitex to close connection after each call is finished.
func WithStatsLevel ¶
WithStatsLevel sets the stats level for client.
func WithTimeoutProvider ¶ added in v0.0.5
func WithTimeoutProvider(p rpcinfo.TimeoutProvider) Option
WithTimeoutProvider adds a TimeoutProvider to the client. Note that the timeout settings provided by the TimeoutProvider will be applied before the other timeout options in this package and those in the callopt package. Thus it can not modify the timeouts set by WithRPCTimeout or WithConnectTimeout.
func WithTransHandlerFactory ¶
func WithTransHandlerFactory(f remote.ClientTransHandlerFactory) Option
WithTransHandlerFactory sets the TransHandlerFactory for client.
func WithTransportProtocol ¶
WithTransportProtocol sets the transport protocol for client.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package callopt contains options that control the behavior of client on request level.
|
Package callopt contains options that control the behavior of client on request level. |
Package genericclient ...
|
Package genericclient ... |