client

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: Apache-2.0 Imports: 37 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

	// web server config
	WebServerConfig *WebServerConfig

	// 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))

  2. Notifier Client yaml a) xyz-notifier-client.yaml where xyz is the target gRPC service endpoint 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) ConfiguredDialMinConnectTimeoutSeconds added in v1.0.7

func (c *Client) ConfiguredDialMinConnectTimeoutSeconds() uint

ConfiguredDialMinConnectTimeoutSeconds gets the timeout seconds from config yaml

func (*Client) ConfiguredForClientDial added in v1.0.7

func (c *Client) ConfiguredForClientDial() bool

ConfiguredForClientDial checks if the config yaml is ready for client dial operation

func (*Client) ConfiguredForSNSDiscoveryTopicArn added in v1.0.7

func (c *Client) ConfiguredForSNSDiscoveryTopicArn() bool

ConfiguredForSNSDiscoveryTopicArn indicates if the sns topic arn for service discovery is configured within the config yaml

func (*Client) ConfiguredSNSDiscoveryTopicArn added in v1.0.7

func (c *Client) ConfiguredSNSDiscoveryTopicArn() string

ConfiguredSNSDiscoveryTopicArn returns the sns discovery topic arn as configured in config yaml

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) PreloadConfigData added in v1.0.7

func (c *Client) PreloadConfigData() error

PreloadConfigData will load the config data before Dial()

func (*Client) RemoteAddress

func (c *Client) RemoteAddress() string

RemoteAddress gets the remote endpoint address currently connected to

type WebServerConfig added in v1.0.7

type WebServerConfig struct {
	AppName          string
	ConfigFileName   string
	CustomConfigPath string

	// define web server router info
	WebServerRoutes map[string]*ginw.RouteDefinition

	// getter only
	WebServerLocalAddress string
}

note: WebServerLocalAddress = read only getter

note: WebServerRoutes = map[string]*ginw.RouteDefinition{
		"base": {
			Routes: []*ginw.Route{
				{
					Method: ginhttpmethod.GET,
					RelativePath: "/",
					Handler: func(c *gin.Context, bindingInputPtr interface{}) {
						c.String(200, "Connector Client Http Host Up")
					},
				},
			},
		},
	}

Jump to

Keyboard shortcuts

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