client

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

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

func (c *Cache) AddServiceEndpoints(serviceName string, eps []*serviceEndpoint)

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

func (c *Cache) PurgeServiceEndpoints(serviceName string)

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:

  1. 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 NewClient

func NewClient(appName string, configFileName string, customConfigPath string) *Client

create client

func (*Client) ClientConnection

func (c *Client) ClientConnection() grpc.ClientConnInterface

ClientConnection returns the currently loaded grpc client connection

func (*Client) Close

func (c *Client) Close()

Close will close grpc client connection

func (*Client) Dial

func (c *Client) Dial(ctx context.Context) error

Dial will dial grpc service and establish 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

func (c *Client) RemoteAddress() string

RemoteAddress gets the remote endpoint address currently connected to

func (*Client) WaitForReady

func (c *Client) WaitForReady(timeoutDuration ...time.Duration) error

WaitForReady is called after Dial to check if target service is ready as reported by health probe

Jump to

Keyboard shortcuts

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