client

package
v3.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: Apache-2.0 Imports: 28 Imported by: 49

Documentation

Overview

Package client provides APIs for starting RPC calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallOption

type CallOption func(*CallOptions)

func WithCallRequestTimeout

func WithCallRequestTimeout(timeout time.Duration) CallOption

WithCallRequestTimeout the maximum waiting time for one specific call, only works for 'tri' and 'dubbo' protocol

func WithCallRetries

func WithCallRetries(retries int) CallOption

WithCallRetries the maximum retry times on request failure for one specific call, only works for 'tri' and 'dubbo' protocol

type CallOptions

type CallOptions struct {
	RequestTimeout string
	Retries        string
}

todo: need to be consistent with MethodConfig

type Client

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

ConsumerConfig

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

func (*Client) Dial

func (cli *Client) Dial(interfaceName string, opts ...ReferenceOption) (*Connection, error)

func (*Client) DialWithDefinition

func (cli *Client) DialWithDefinition(interfaceName string, definition *ClientDefinition, opts ...ReferenceOption) (*Connection, error)

func (*Client) DialWithInfo

func (cli *Client) DialWithInfo(interfaceName string, info *ClientInfo, opts ...ReferenceOption) (*Connection, error)

func (*Client) DialWithService added in v3.3.1

func (cli *Client) DialWithService(interfaceName string, service any, opts ...ReferenceOption) (*Connection, error)

func (*Client) NewService added in v3.3.1

func (cli *Client) NewService(service any, opts ...ReferenceOption) (*Connection, error)

type ClientDefinition

type ClientDefinition struct {
	Svc  any
	Info *ClientInfo
	Conn *Connection
}

func (*ClientDefinition) GetConnection added in v3.3.1

func (d *ClientDefinition) GetConnection() (*Connection, error)

func (*ClientDefinition) SetConnection added in v3.3.1

func (d *ClientDefinition) SetConnection(conn *Connection)

type ClientInfo

type ClientInfo struct {
	InterfaceName        string
	MethodNames          []string
	ConnectionInjectFunc func(dubboCliRaw any, conn *Connection)
	Meta                 map[string]any
}

type ClientOption

type ClientOption func(*ClientOptions)

func SetClientApplication added in v3.3.1

func SetClientApplication(application *global.ApplicationConfig) ClientOption

func SetClientConsumer

func SetClientConsumer(consumer *global.ConsumerConfig) ClientOption

func SetClientMetrics

func SetClientMetrics(metrics *global.MetricsConfig) ClientOption

func SetClientOtel

func SetClientOtel(otel *global.OtelConfig) ClientOption

func SetClientProtocols added in v3.3.1

func SetClientProtocols(protocols map[string]*global.ProtocolConfig) ClientOption

SetClientProtocols sets the protocols configuration for the client. This function is used by the framework to configure protocol settings from global configuration. It accepts a map of protocol configurations where the key is the protocol name and the value is the corresponding protocol configuration.

func SetClientRegistries

func SetClientRegistries(regs map[string]*global.RegistryConfig) ClientOption

func SetClientShutdown

func SetClientShutdown(shutdown *global.ShutdownConfig) ClientOption

func SetClientTLS added in v3.3.1

func SetClientTLS(tls *global.TLSConfig) ClientOption

func WithClientClusterAdaptiveService

func WithClientClusterAdaptiveService() ClientOption

func WithClientClusterAvailable

func WithClientClusterAvailable() ClientOption

func WithClientClusterBroadcast

func WithClientClusterBroadcast() ClientOption

func WithClientClusterFailBack

func WithClientClusterFailBack() ClientOption

func WithClientClusterFailFast

func WithClientClusterFailFast() ClientOption

func WithClientClusterFailOver

func WithClientClusterFailOver() ClientOption

func WithClientClusterFailSafe

func WithClientClusterFailSafe() ClientOption

func WithClientClusterForking

func WithClientClusterForking() ClientOption

func WithClientClusterStrategy

func WithClientClusterStrategy(strategy string) ClientOption

func WithClientClusterZoneAware

func WithClientClusterZoneAware() ClientOption

func WithClientFilter

func WithClientFilter(filter string) ClientOption

todo(DMwangnima): change Filter Option like Cluster and LoadBalance

func WithClientForceTag

func WithClientForceTag() ClientOption

func WithClientGroup

func WithClientGroup(group string) ClientOption

is this needed?

func WithClientLoadBalance

func WithClientLoadBalance(lb string) ClientOption

func WithClientLoadBalanceConsistentHashing

func WithClientLoadBalanceConsistentHashing() ClientOption

func WithClientLoadBalanceLeastActive

func WithClientLoadBalanceLeastActive() ClientOption

func WithClientLoadBalanceP2C

func WithClientLoadBalanceP2C() ClientOption

func WithClientLoadBalanceRandom

func WithClientLoadBalanceRandom() ClientOption

func WithClientLoadBalanceRoundRobin

func WithClientLoadBalanceRoundRobin() ClientOption

func WithClientMeshProviderPort

func WithClientMeshProviderPort(port int) ClientOption

func WithClientNoCheck

func WithClientNoCheck() ClientOption

func WithClientParam

func WithClientParam(k, v string) ClientOption

func WithClientParams

func WithClientParams(params map[string]string) ClientOption

func WithClientProtocol

func WithClientProtocol(opts ...protocol.ClientOption) ClientOption

func WithClientProtocolDubbo

func WithClientProtocolDubbo() ClientOption

func WithClientProtocolJsonRPC

func WithClientProtocolJsonRPC() ClientOption

func WithClientProtocolTriple

func WithClientProtocolTriple() ClientOption

func WithClientProvidedBy

func WithClientProvidedBy(providedBy string) ClientOption

func WithClientRegistry

func WithClientRegistry(opts ...registry.Option) ClientOption

func WithClientRegistryIDs

func WithClientRegistryIDs(registryIDs ...string) ClientOption

todo(DMwangnima): think about a more ideal configuration style

func WithClientRequestTimeout

func WithClientRequestTimeout(timeout time.Duration) ClientOption

func WithClientRetries

func WithClientRetries(retries int) ClientOption

func WithClientSerialization

func WithClientSerialization(ser string) ClientOption

func WithClientSerializationJSON

func WithClientSerializationJSON() ClientOption

func WithClientShutdown

func WithClientShutdown(opts ...graceful_shutdown.Option) ClientOption

func WithClientSticky

func WithClientSticky() ClientOption

func WithClientTLSOption added in v3.3.1

func WithClientTLSOption(opts ...tls.Option) ClientOption

func WithClientURL

func WithClientURL(url string) ClientOption

func WithClientVersion

func WithClientVersion(version string) ClientOption

is this needed?

func WithKeepAliveInterval

func WithKeepAliveInterval(keepAliveInterval time.Duration) ClientOption

Deprecated:use triple.WithKeepAliveInterval()

func WithKeepAliveTimeout

func WithKeepAliveTimeout(keepAliveTimeout time.Duration) ClientOption

Deprecated:use triple.WithKeepAliveTimeout()

type ClientOptions

type ClientOptions struct {
	Consumer    *global.ConsumerConfig
	Application *global.ApplicationConfig
	Registries  map[string]*global.RegistryConfig
	Shutdown    *global.ShutdownConfig
	Metrics     *global.MetricsConfig
	Otel        *global.OtelConfig
	TLS         *global.TLSConfig
	Protocols   map[string]*global.ProtocolConfig
	// contains filtered or unexported fields
}

type Connection

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

InterfaceName/group/version /ReferenceConfig TODO: In the Connection structure, we are only using the invoker in the refOpts. Considering simplifying the Connection. Make the structure of Connection more in line with human logic.

func (*Connection) CallBidiStream

func (conn *Connection) CallBidiStream(ctx context.Context, methodName string, opts ...CallOption) (any, error)

func (*Connection) CallClientStream

func (conn *Connection) CallClientStream(ctx context.Context, methodName string, opts ...CallOption) (any, error)

func (*Connection) CallServerStream

func (conn *Connection) CallServerStream(ctx context.Context, req any, methodName string, opts ...CallOption) (any, error)

func (*Connection) CallUnary

func (conn *Connection) CallUnary(ctx context.Context, reqs []any, resp any, methodName string, opts ...CallOption) error

type ReferenceOption

type ReferenceOption func(*ReferenceOptions)

func WithAsync

func WithAsync() ReferenceOption

func WithCheck

func WithCheck() ReferenceOption

func WithCluster

func WithCluster(cluster string) ReferenceOption

func WithClusterAdaptiveService

func WithClusterAdaptiveService() ReferenceOption

func WithClusterAvailable

func WithClusterAvailable() ReferenceOption

func WithClusterBroadcast

func WithClusterBroadcast() ReferenceOption

func WithClusterFailBack

func WithClusterFailBack() ReferenceOption

func WithClusterFailFast

func WithClusterFailFast() ReferenceOption

func WithClusterFailOver

func WithClusterFailOver() ReferenceOption

func WithClusterFailSafe

func WithClusterFailSafe() ReferenceOption

func WithClusterForking

func WithClusterForking() ReferenceOption

func WithClusterZoneAware

func WithClusterZoneAware() ReferenceOption

func WithFilter

func WithFilter(filter string) ReferenceOption

func WithForceTag

func WithForceTag() ReferenceOption

func WithGeneric

func WithGeneric() ReferenceOption

func WithGroup

func WithGroup(group string) ReferenceOption

func WithIDL added in v3.3.1

func WithIDL(IDLMode string) ReferenceOption

TODO: remove this function after old triple removed

func WithInterface added in v3.3.1

func WithInterface(interfaceName string) ReferenceOption

WithInterface sets the interface name for the service reference.

As a functional option, it is passed to a client constructor (e.g., NewGreetService) to configure which remote service to connect to.

The interfaceName is a crucial identifier for service discovery and routing, and it must exactly match the name registered by the service provider.

Usage:

svc, err := greet.NewGreetService(
    cli,
    client.WithInterface("com.your.company.GreetService"),
)

func WithLoadBalance

func WithLoadBalance(lb string) ReferenceOption

func WithLoadBalanceConsistentHashing

func WithLoadBalanceConsistentHashing() ReferenceOption

func WithLoadBalanceLeastActive

func WithLoadBalanceLeastActive() ReferenceOption

func WithLoadBalanceP2C

func WithLoadBalanceP2C() ReferenceOption

func WithLoadBalanceRandom

func WithLoadBalanceRandom() ReferenceOption

func WithLoadBalanceRoundRobin

func WithLoadBalanceRoundRobin() ReferenceOption

func WithMeshProviderPort

func WithMeshProviderPort(port int) ReferenceOption

func WithMethod

func WithMethod(opts ...config.MethodOption) ReferenceOption

func WithParam

func WithParam(k, v string) ReferenceOption

func WithParams

func WithParams(params map[string]string) ReferenceOption

func WithProtocol

func WithProtocol(protocol string) ReferenceOption

func WithProtocolDubbo

func WithProtocolDubbo() ReferenceOption

func WithProtocolJsonRPC

func WithProtocolJsonRPC() ReferenceOption

func WithProtocolTriple

func WithProtocolTriple() ReferenceOption

func WithProvidedBy

func WithProvidedBy(providedBy string) ReferenceOption

func WithRegistry added in v3.3.1

func WithRegistry(opts ...registry.Option) ReferenceOption

func WithRegistryIDs

func WithRegistryIDs(registryIDs ...string) ReferenceOption

func WithRequestTimeout

func WithRequestTimeout(timeout time.Duration) ReferenceOption

func WithRetries

func WithRetries(retries int) ReferenceOption

func WithSerialization

func WithSerialization(serialization string) ReferenceOption

func WithSerializationJSON

func WithSerializationJSON() ReferenceOption

func WithSticky

func WithSticky() ReferenceOption

func WithURL

func WithURL(url string) ReferenceOption

func WithVersion

func WithVersion(version string) ReferenceOption

type ReferenceOptions

type ReferenceOptions struct {
	Reference   *global.ReferenceConfig
	Consumer    *global.ConsumerConfig
	Application *global.ApplicationConfig
	Shutdown    *global.ShutdownConfig
	Metrics     *global.MetricsConfig
	Otel        *global.OtelConfig
	TLS         *global.TLSConfig
	Protocols   map[string]*global.ProtocolConfig
	Registries  map[string]*global.RegistryConfig
	// contains filtered or unexported fields
}

func (*ReferenceOptions) CheckAvailable

func (refOpts *ReferenceOptions) CheckAvailable() bool

func (*ReferenceOptions) GetInvoker

func (refOpts *ReferenceOptions) GetInvoker() base.Invoker

GetInvoker get invoker from ReferenceConfigs

func (*ReferenceOptions) GetProxy

func (refOpts *ReferenceOptions) GetProxy() *proxy.Proxy

GetProxy gets proxy

func (*ReferenceOptions) GetRPCService

func (refOpts *ReferenceOptions) GetRPCService() common.RPCService

GetRPCService gets RPCService from proxy

func (*ReferenceOptions) Implement

func (refOpts *ReferenceOptions) Implement(v common.RPCService)

Implement @v is service provider implemented RPCService

func (*ReferenceOptions) Refer added in v3.3.1

func (refOpts *ReferenceOptions) Refer()

func (*ReferenceOptions) ReferWithInfo

func (refOpts *ReferenceOptions) ReferWithInfo(info *ClientInfo)

func (*ReferenceOptions) ReferWithService

func (refOpts *ReferenceOptions) ReferWithService(srv common.RPCService)

ReferWithService retrieves invokers from urls.

func (*ReferenceOptions) ReferWithServiceAndInfo

func (refOpts *ReferenceOptions) ReferWithServiceAndInfo(srv common.RPCService, info *ClientInfo)

Jump to

Keyboard shortcuts

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