env

package
v0.0.0-...-11b31ba Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidBackend = errors.New("invalid backend")

Functions

func Backend

func Backend() (string, error)

Backend returns the selected backend based on the environment variable "BACKEND". "NATS" is the default value in case of an empty variable.

Types

type BackendConfig

type BackendConfig struct {
	PublisherConfig PublisherConfig

	// namespace where eventing-manager is deployed.
	Namespace           string `default:"kyma-system" envconfig:"NAMESPACE"`
	EventingCRName      string `default:"eventing"    envconfig:"EVENTING_CR_NAME"`
	EventingCRNamespace string `default:"kyma-system" envconfig:"EVENTING_CR_NAMESPACE"`

	DefaultSubscriptionConfig DefaultSubscriptionConfig

	//nolint:lll
	EventingWebhookAuthSecretName string `default:"eventing-webhook-auth" envconfig:"EVENTING_WEBHOOK_AUTH_SECRET_NAME" required:"true"`
	//nolint:lll
	EventingWebhookAuthSecretNamespace string `default:"kyma-system" envconfig:"EVENTING_WEBHOOK_AUTH_SECRET_NAMESPACE" required:"true"`
}

BackendConfig represents the environment config for the Backend Controller.

func GetBackendConfig

func GetBackendConfig() BackendConfig

type Config

type Config struct {
	// Following details are for eventing-controller to communicate to BEB
	BEBAPIURL     string `default:"https://enterprise-messaging-pubsub.cfapps.sap.hana.ondemand.com/sap/ems/v1" envconfig:"BEB_API_URL"`
	ClientID      string `default:"client-id"                                                                   envconfig:"CLIENT_ID"`
	ClientSecret  string `default:"client-secret"                                                               envconfig:"CLIENT_SECRET"`
	TokenEndpoint string `default:"token-endpoint"                                                              envconfig:"TOKEN_ENDPOINT"`

	// Following details are for BEB to communicate to Kyma
	WebhookActivationTimeout time.Duration `default:"60s" envconfig:"WEBHOOK_ACTIVATION_TIMEOUT"`

	// Default protocol setting for BEB
	ExemptHandshake bool   `default:"true"          envconfig:"EXEMPT_HANDSHAKE"`
	Qos             string `default:"AT_LEAST_ONCE" envconfig:"QOS"`
	ContentMode     string `default:""              envconfig:"CONTENT_MODE"`

	// Default namespace for BEB
	BEBNamespace string `default:"ns" envconfig:"BEB_NAMESPACE"`

	// EventTypePrefix prefix for the EventType
	// note: eventType format is <prefix>.<application>.<event>.<version>
	EventTypePrefix string `envconfig:"EVENT_TYPE_PREFIX" required:"true"`

	// EventingWebhookAuthEnabled enable/disable the Eventing webhook auth feature flag.
	EventingWebhookAuthEnabled bool `default:"false" envconfig:"EVENTING_WEBHOOK_AUTH_ENABLED" required:"false"`

	// NATSProvisioningEnabled enable/disable the NATS resources provisioning feature flag.
	NATSProvisioningEnabled bool `default:"true" envconfig:"NATS_PROVISIONING_ENABLED" required:"false"`
}

Config represents the environment config for the Eventing Controller.

func GetConfig

func GetConfig() Config

type DefaultSubscriptionConfig

type DefaultSubscriptionConfig struct {
	MaxInFlightMessages   int           `default:"10" envconfig:"DEFAULT_MAX_IN_FLIGHT_MESSAGES"`
	DispatcherRetryPeriod time.Duration `default:"5m" envconfig:"DEFAULT_DISPATCHER_RETRY_PERIOD"`
	DispatcherMaxRetries  int           `default:"10" envconfig:"DEFAULT_DISPATCHER_MAX_RETRIES"`
}

type NATSConfig

type NATSConfig struct {
	// Following details are for eventing-controller to communicate to Nats
	URL           string
	MaxReconnects int
	ReconnectWait time.Duration

	// EventTypePrefix prefix for the EventType
	// note: eventType format is <prefix>.<application>.<event>.<version>
	EventTypePrefix string

	// HTTP Transport config for the message dispatcher
	MaxIdleConns        int           `default:"50"  envconfig:"MAX_IDLE_CONNS"`
	MaxConnsPerHost     int           `default:"50"  envconfig:"MAX_CONNS_PER_HOST"`
	MaxIdleConnsPerHost int           `default:"50"  envconfig:"MAX_IDLE_CONNS_PER_HOST"`
	IdleConnTimeout     time.Duration `default:"10s" envconfig:"IDLE_CONN_TIMEOUT"`

	// JetStream-specific configs
	// Name of the JetStream stream where all events are stored.
	JSStreamName string `default:"sap" envconfig:"JS_STREAM_NAME"`
	// Prefix for the subjects in the stream.
	JSSubjectPrefix string `envconfig:"JS_STREAM_SUBJECT_PREFIX"`
	// Storage type of the stream, memory or file.
	JSStreamStorageType string
	// Number of replicas for the JetStream stream
	JSStreamReplicas int
	// Retention policy specifies when to delete events from the stream.
	//  interest: when all known observables have acknowledged a message, it can be removed.
	//  limits: messages are retained until any given limit is reached.
	//  configured via JSStreamMaxMessages and JSStreamMaxBytes.
	JSStreamRetentionPolicy string `default:"interest" envconfig:"JS_STREAM_RETENTION_POLICY"`
	JSStreamMaxMessages     int64  `default:"-1"       envconfig:"JS_STREAM_MAX_MSGS"`
	JSStreamMaxBytes        string
	JSStreamMaxMsgsPerTopic int64
	// JSStreamDiscardPolicy specifies which events to discard from the stream in case limits are reached
	//  new: reject new messages for the stream
	//  old: discard old messages from the stream to make room for new messages
	JSStreamDiscardPolicy string `default:"new" envconfig:"JS_STREAM_DISCARD_POLICY"`
	// Deliver Policy determines for a consumer where in the stream it starts receiving messages
	// (more info https://docs.nats.io/nats-concepts/jetstream/consumers#deliverpolicy-optstartseq-optstarttime):
	// - all: The consumer starts receiving from the earliest available message.
	// - last: When first consuming messages, the consumer starts receiving messages with the latest message.
	// - last_per_subject: When first consuming messages, start with the latest one for each filtered subject
	//   currently in the stream.
	// - new: When first consuming messages, the consumer starts receiving messages that were created
	//   after the consumer was created.
	JSConsumerDeliverPolicy string `default:"new" envconfig:"JS_CONSUMER_DELIVER_POLICY"`
}

NATSConfig represents the environment config for the Eventing Controller with Nats.

func GetNATSConfig

func GetNATSConfig(maxReconnects int, reconnectWait time.Duration) (NATSConfig, error)

func (NATSConfig) GetNewNATSConfig

func (nc NATSConfig) GetNewNATSConfig(eventingCR v1alpha1.Eventing) NATSConfig

GetNewNATSConfig returns NATSConfig with values based on Eventing CR.

type PublisherConfig

type PublisherConfig struct {
	Image             string `default:"eu.gcr.io/kyma-project/event-publisher-proxy:c06eb4fc" envconfig:"PUBLISHER_IMAGE"`
	ImagePullPolicy   string `default:"IfNotPresent"                                          envconfig:"PUBLISHER_IMAGE_PULL_POLICY"`
	PortNum           int    `default:"8080"                                                  envconfig:"PUBLISHER_PORT_NUM"`
	MetricsPortNum    int    `default:"8080"                                                  envconfig:"PUBLISHER_METRICS_PORT_NUM"`
	ServiceAccount    string `default:"eventing-publisher-proxy"                              envconfig:"PUBLISHER_SERVICE_ACCOUNT"`
	RequestTimeout    string `default:"5s"                                                    envconfig:"PUBLISHER_REQUEST_TIMEOUT"`
	PriorityClassName string `default:""                                                      envconfig:"PUBLISHER_PRIORITY_CLASS_NAME"`
	// publisher takes the controller values
	AppLogFormat          string `default:"json" envconfig:"APP_LOG_FORMAT"`
	ApplicationCRDEnabled bool
}

Jump to

Keyboard shortcuts

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