go_translator

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

README

go-translator

Helper and utility functions for WirePact translators written in Go

Documentation

Index

Constants

View Source
const (
	TranslatorEnvPkiAddress      = "PKI_ADDRESS"
	TranslatorEnvIngressPort     = "INGRESS_PORT"
	TranslatorEnvEgressPort      = "EGRESS_PORT"
	TranslatorEnvCommonName      = "COMMON_NAME"
	TranslatorDefaultIngressPort = 50051
	TranslatorDefaultEgressPort  = 50052
	TranslatorDefaultCaPath      = "/ca"
	TranslatorDefaultCsrPath     = "/csr"
)
View Source
const (
	ErrPkiAddressNotSet = "pki address not set"
	ErrCommonNameNotSet = "common name not set"
)

Variables

This section is empty.

Functions

func SetLogLevel added in v1.1.0

func SetLogLevel(level logrus.Level)

Types

type Translator

type Translator struct {
	// contains filtered or unexported fields
}

Translator acts as the server for translation and communicating with envoy.

func NewTranslator

func NewTranslator(config *TranslatorConfig) (*Translator, error)

NewTranslator creates a new translator that adheres to the given config.

func (*Translator) Start

func (translator *Translator) Start()

Start runs the server by ensuring the PKI key material and then starting the grpc servers. When a system interrupt is received the server stops.

func (*Translator) Stop

func (translator *Translator) Stop()

Stop closes the server and returns the "start" function.

type TranslatorConfig

type TranslatorConfig struct {
	// Port for the incoming communication grpc server.
	IngressPort int
	// Function for the incoming translation.
	IngressTranslator translator.IngressTranslation

	// Port for the outgoing communication grpc server.
	EgressPort int
	// Function for the outgoing translation.
	EgressTranslator translator.EgressTranslation

	// Config for the PKI.
	pki.Config
	// Config for the WirePact JWT.
	wirepact.JWTConfig
}

TranslatorConfig contains all necessary configurations for the Translator.

func NewConfigFromEnvironmentVariables

func NewConfigFromEnvironmentVariables(
	ingressTranslator translator.IngressTranslation,
	egressTranslator translator.EgressTranslation) (TranslatorConfig, error)

NewConfigFromEnvironmentVariables returns a TranslatorConfig that is filled with values from environment variables. The config can further be customized after it is returned.

The variables are: INGRESS_PORT, EGRESS_PORT, PKI_ADDRESS, COMMON_NAME The common name gets set for the certificate common name and the issuer for the JWTs. Ingress and Egress ports have default values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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