adapter

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Copyright 2020 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithMetricTag

func ContextWithMetricTag(ctx context.Context, metric *MetricTag) context.Context

ContextWithMetricTag returns a copy of parent context in which the value associated with metric key is the supplied metric tag.

func Main

func Main(component string, ector EnvConfigConstructor, ctor AdapterConstructor)

func MainWithContext

func MainWithContext(ctx context.Context, component string, ector EnvConfigConstructor, ctor AdapterConstructor)

func NewCloudEventsClient

func NewCloudEventsClient(target string, ceOverrides *duckv1.CloudEventOverrides, reporter source.StatsReporter) (cloudevents.Client, error)

NewCloudEventsClient returns a client that will apply the ceOverrides to outbound events and report outbound event counts.

Types

type Adapter

type Adapter interface {
	Start(stopCh <-chan struct{}) error
}

type AdapterConstructor

type AdapterConstructor func(ctx context.Context, env EnvConfigAccessor, client cloudevents.Client) Adapter

type EnvConfig

type EnvConfig struct {
	// Component is the kind of this adapter.
	Component string `envconfig:"K_COMPONENT"`

	// Environment variable containing the namespace of the adapter.
	Namespace string `envconfig:"NAMESPACE" required:"true"`

	// Environment variable containing the name of the adapter.
	Name string `envconfig:"NAME" default:"adapter"`

	// Environment variable containing the resource group of the adapter for metrics.
	ResourceGroup string `envconfig:"K_RESOURCE_GROUP" default:"adapter.sources.knative.dev"`

	// Sink is the URI messages will be sent.
	Sink string `envconfig:"K_SINK"`

	// CEOverrides are the CloudEvents overrides to be applied to the outbound event.
	CEOverrides string `envconfig:"K_CE_OVERRIDES"`

	// MetricsConfigJson is a json string of metrics.ExporterOptions.
	// This is used to configure the metrics exporter options,
	// the config is stored in a config map inside the controllers
	// namespace and copied here.
	MetricsConfigJson string `envconfig:"K_METRICS_CONFIG" required:"true"`

	// LoggingConfigJson is a json string of logging.Config.
	// This is used to configure the logging config, the config is stored in
	// a config map inside the controllers namespace and copied here.
	LoggingConfigJson string `envconfig:"K_LOGGING_CONFIG" required:"true"`
}

EnvConfig is the minimal set of configuration parameters source adapters should support.

func (*EnvConfig) GetCloudEventOverrides

func (e *EnvConfig) GetCloudEventOverrides() (*duckv1.CloudEventOverrides, error)

func (*EnvConfig) GetLogger

func (e *EnvConfig) GetLogger() *zap.SugaredLogger

func (*EnvConfig) GetMetricsConfig

func (e *EnvConfig) GetMetricsConfig() (*metrics.ExporterOptions, error)

func (*EnvConfig) GetName

func (e *EnvConfig) GetName() string

func (*EnvConfig) GetNamespace

func (e *EnvConfig) GetNamespace() string

func (*EnvConfig) GetSink

func (e *EnvConfig) GetSink() string

func (*EnvConfig) SetComponent

func (e *EnvConfig) SetComponent(component string)

type EnvConfigAccessor

type EnvConfigAccessor interface {
	// Set the component name.
	SetComponent(string)

	// Get the URI where messages will be forwarded to.
	GetSink() string

	// Get the namespace of the adapter.
	GetNamespace() string

	// Get the name of the adapter.
	GetName() string

	// Get the parsed metrics.ExporterOptions.
	GetMetricsConfig() (*metrics.ExporterOptions, error)

	// Get the parsed logger.
	GetLogger() *zap.SugaredLogger

	GetCloudEventOverrides() (*duckv1.CloudEventOverrides, error)
}

EnvConfigAccessor defines accessors for the minimal set of source adapter configuration parameters.

type EnvConfigConstructor

type EnvConfigConstructor func() EnvConfigAccessor

type MetricTag

type MetricTag struct {
	Name          string
	Namespace     string
	ResourceGroup string
}

func MetricTagFromContext

func MetricTagFromContext(ctx context.Context) *MetricTag

MetricTagFromContext returns the metric tag stored in context. Returns nil if no metric tag is set in context, or if the stored value is not of correct type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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