sdk

package
v0.0.0-...-8b05a81 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

Wrappers over grpc.Dial that take care of option setting, endpoint determination, api key loading and handling, etc.

Documentation

Overview

Package SDK provides a simple wrapper for gRPC's Dial function. It arranges for the application's API key to be sent with each RPC, that TLS is used, the setting of the appropriate connection endpoint and server name, and the configuration of any other parameters that are deemed necessary to work well with the nsys.io server complex and services.

Index

Constants

View Source
const (
	// Endpoint for host TLS connections
	EndpointDefault = "api.nsys.io:39111"
	EndpointKey     = "NSYS_ENDPOINT"

	// The TLS server we expect to find there.
	ServerNameDefault = "api.nsys.io"
	ServerNameKey     = "NSYS_SERVER_NAME"

	// API Key environmental var
	ApiKeyKey = "NSYS_API_KEY"

	// Maximum message size over gRPC
	MaxMessageSize = 200 * 1024 * 1024
)

Variables

View Source
var (
	// These may be set prior to calling NewConn.
	// Environmental variables override anything set here except for ApiKey.
	Endpoint   = EndpointDefault
	ServerName = ServerNameDefault
	ApiKey     string
)

Functions

func New

func New(ctx context.Context, ni *NewInput) (*grpc.ClientConn, error)

New returns a grpc.ClientConn instance after having performed a grpc.Dial to the nsys.io host complex with options set such TLS is used, a connection-specific API key (aka ticket) is supplied with every RPC, and so on. Supplied dial options are added to the base set. Parameters not set in the input structure are set to package default values (or those zapped into the package's public globals) with those defaults being overridden by anything found in the environment.

func NewConn

func NewConn(ctx context.Context, xopts ...grpc.DialOption) (*grpc.ClientConn, error)

NewConn is a legacy function which is now a simple wrapper on New(). It is only appropriate for use when the application is using a single API key.

Types

type NewInput

type NewInput struct {
	Endpoint       string
	ServerName     string
	ApiKey         string
	MaxMessageSize int
	DialOptions    []grpc.DialOption
}

NewInput supplies input parameters for the New() function.

Jump to

Keyboard shortcuts

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