Documentation ¶
Index ¶
- type Cache
- type Client
- func (c *Client) ClientConnection() grpc.ClientConnInterface
- func (c *Client) Close()
- func (c *Client) Dial(ctx context.Context) error
- func (c *Client) GetState() connectivity.State
- func (c *Client) HealthProbe(serviceName string, timeoutDuration ...time.Duration) (grpc_health_v1.HealthCheckResponse_ServingStatus, error)
- func (c *Client) RemoteAddress() string
- func (c *Client) WaitForReady(timeoutDuration ...time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { ServiceEndpoints map[string][]*serviceEndpoint // contains filtered or unexported fields }
func (*Cache) AddServiceEndpoints ¶
AddServiceEndpoints will append slice of service endpoints associated with the given serviceName within map
func (*Cache) GetLiveServiceEndpoints ¶
func (c *Cache) GetLiveServiceEndpoints(serviceName string, version string) (liveEndpoints []*serviceEndpoint)
GetLiveServiceEndpoints will retrieve currently non-expired service endpoints and remove any expired service endpoints from map, for a given serviceName
func (*Cache) PurgeServiceEndpoints ¶
PurgeServiceEndpoints will remove all endpoints associated with the given serviceName within map
type Client ¶
type Client struct { // client properties AppName string ConfigFileName string CustomConfigPath string // indicate if after dial, client will wait for target service health probe success before continuing to allow rpc WaitForServerReady bool // one or more unary client interceptors for handling wrapping actions UnaryClientInterceptors []grpc.UnaryClientInterceptor // one or more stream client interceptors for handling wrapping actions StreamClientInterceptors []grpc.StreamClientInterceptor // typically wrapper action to handle monitoring StatsHandler stats.Handler // handler to invoke before gRPC client dial is to start BeforeClientDial func(cli *Client) // handler to invoke after gRPC client dial performed AfterClientDial func(cli *Client) // handler to invoke before gRPC client connection is to close BeforeClientClose func(cli *Client) // handler to invoke after gRPC client connection has closed AfterClientClose func(cli *Client) // *** Setup by Dial Action *** // helper for creating metadata context, // and evaluate metadata header or trailer value when received from rpc MetadataHelper *metadata.MetaClient // contains filtered or unexported fields }
Client represents a gRPC client's connection and entry point
note:
- Using Compressor with RPC a) import "google.golang.org/grpc/encoding/gzip" b) in RPC Call, pass grpc.UseCompressor(gzip.Name)) in the third parameter example: RPCCall(ctx, &pb.Request{...}, grpc.UseCompressor(gzip.Name))
func (*Client) ClientConnection ¶
func (c *Client) ClientConnection() grpc.ClientConnInterface
ClientConnection returns the currently loaded grpc client connection
func (*Client) GetState ¶
func (c *Client) GetState() connectivity.State
GetState returns the current grpc client connection's state
func (*Client) HealthProbe ¶
func (c *Client) HealthProbe(serviceName string, timeoutDuration ...time.Duration) (grpc_health_v1.HealthCheckResponse_ServingStatus, error)
HealthProbe manually checks service serving health status
func (*Client) RemoteAddress ¶
RemoteAddress gets the remote endpoint address currently connected to