client

package
v0.0.0-...-54d1621 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(address string, tracer opentracing.Tracer, clientFactory func(cc grpc.ClientConnInterface) interface{}) (interface{}, func() error, error)

New creates a new gRPC connection and generic service client. Automatically injects contexts over gRPC and starts a new server-side tracing span.

To make this work as a generic client constructor, you must wrap the `pb.NewXXXCLient` function to return an empty interface{} Every service should create their own client implementation by calling this function. Example from the account service client. ```

func New(address string, tracer opentracing.Tracer) (pb.AccountClient, func() error, error) {
	c, close, err := client.New(address, tracer, createAccountClient)
	return c.(pb.AccountClient), close, err

} // Generic wrapper around the pb.NewXXXClient function

func createAccountClient(cc grpc.ClientConnInterface) interface{} {
	return pb.NewAccountClient(cc)
}

```

Types

This section is empty.

Jump to

Keyboard shortcuts

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