Documentation ¶
Overview ¶
Package connection provides a set of helpers to establish connections with gRPC and HTTP endpoints.
Index ¶
Constants ¶
const AgentHeader = "agent"
AgentHeader with the key name for the agent payload.
const ContextTimeout = 5 * time.Minute
ContextTimeout with the default timeout for Napptive playground operations.
const VersionHeader = "version"
VersionHeader with the key name for the version payload.
Variables ¶
This section is empty.
Functions ¶
func GetConnection ¶
func GetConnection(cfg *Config) (*grpc.ClientConn, error)
GetConnection creates a connection with a gRPC server.
func GetNonTLSConnection ¶
func GetNonTLSConnection(_ *Config, address string) (*grpc.ClientConn, error)
GetNonTLSConnection returns a plain connection with the playground server.
func GetTLSConnection ¶
func GetTLSConnection(cfg *Config, address string) (*grpc.ClientConn, error)
GetTLSConnection returns a TLS wrapped connection with the playground server.
Types ¶
type Config ¶
type Config struct { // Name of the connection as user information. Name string // ServerAddress with the dns/IP of the target gRPC server. ServerAddress string // ServerPort with the port of the catalog-manager gRPC server. ServerPort int // AuthEnable with a flag to indicate if the authentication is enabled or not AuthEnable bool // UseTLS indicates that a TLS connection is expected with the service. UseTLS bool // SkipCertValidation flag that enables ignoring the validation step of the certificate presented by the server. SkipCertValidation bool // ClientCA with a client trusted CA ClientCA string }
Config contains the configuration elements related to the connection with gRPC services.
func (*Config) GetEffectiveAddress ¶
GetEffectiveAddress returns an address:port string.
type ContextHelper ¶
type ContextHelper struct { // Version of the application sending the request. Version string // Agent sending the request. Agent string printer.ResultPrinter }
ContextHelper structure to facilitate the generation of secure contexts.
func NewContextHelper ¶
func NewContextHelper(version string, agent string, printer printer.ResultPrinter) *ContextHelper
NewContextHelper creates a ContextHelper with a given configuration.
func (*ContextHelper) GetContext ¶
func (ch *ContextHelper) GetContext() (context.Context, context.CancelFunc)
GetContext returns a valid gRPC context with the appropriate authorization header.