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.
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.
Index ¶
- Constants
- func ConfigMapWatcherFromContext(ctx context.Context) configmap.Watcher
- func ContextWithMetricTag(ctx context.Context, metric *MetricTag) context.Context
- func FilterConfigByLabelEquals(labelKey string, labelValue string) (*labels.Requirement, error)
- func IsConfigMapWatcherEnabled(ctx context.Context) bool
- func IsHAEnabled(ctx context.Context) bool
- func IsInjectorEnabled(ctx context.Context) bool
- func Main(component string, ector EnvConfigConstructor, ctor AdapterConstructor)
- func MainMessageAdapter(component string, ector EnvConfigConstructor, ctor MessageAdapterConstructor)
- func MainMessageAdapterWithContext(ctx context.Context, component string, ector EnvConfigConstructor, ...)
- func MainWithContext(ctx context.Context, component string, ector EnvConfigConstructor, ...)
- func MainWithEnv(ctx context.Context, component string, env EnvConfigAccessor, ...)
- func MainWithInformers(ctx context.Context, component string, env EnvConfigAccessor, ...)
- func NewCloudEventsClient(target string, ceOverrides *duckv1.CloudEventOverrides, ...) (cloudevents.Client, error)
- func NewCloudEventsClientCRStatus(target string, ceOverrides *duckv1.CloudEventOverrides, ...) (cloudevents.Client, error)
- func SetupConfigMapWatchOrDie(ctx context.Context, component string, namespace string) configmap.Watcher
- func SetupInformers(ctx context.Context, logger *zap.SugaredLogger) (context.Context, []controller.Informer)
- func StartInformers(ctx context.Context, informers []controller.Informer)
- func WithConfigMapWatcher(ctx context.Context, watcher configmap.Watcher) context.Context
- func WithConfigMapWatcherEnabled(ctx context.Context) context.Context
- func WithHAEnabled(ctx context.Context) context.Context
- func WithInjectorEnabled(ctx context.Context) context.Context
- type Adapter
- type AdapterConstructor
- type EnvConfig
- func (e *EnvConfig) GetCloudEventOverrides() (*duckv1.CloudEventOverrides, error)
- func (e *EnvConfig) GetLeaderElectionConfig() (*kle.ComponentConfig, error)
- func (e *EnvConfig) GetLogger() *zap.SugaredLogger
- func (e *EnvConfig) GetMetricsConfig() (*metrics.ExporterOptions, error)
- func (e *EnvConfig) GetName() string
- func (e *EnvConfig) GetNamespace() string
- func (e *EnvConfig) GetSink() string
- func (e *EnvConfig) SetComponent(component string)
- func (e *EnvConfig) SetupTracing(logger *zap.SugaredLogger) error
- type EnvConfigAccessor
- type EnvConfigConstructor
- type MessageAdapter
- type MessageAdapterConstructor
- type MetricTag
Constants ¶
const ( EnvConfigComponent = "K_COMPONENT" EnvConfigNamespace = "NAMESPACE" EnvConfigName = "NAME" EnvConfigResourceGroup = "K_RESOURCE_GROUP" EnvConfigSink = "K_SINK" EnvConfigCEOverrides = "K_CE_OVERRIDES" EnvConfigMetricsConfig = "K_METRICS_CONFIG" EnvConfigLoggingConfig = "K_LOGGING_CONFIG" EnvConfigTracingConfig = "K_TRACING_CONFIG" EnvConfigLeaderElectionConfig = "K_LEADER_ELECTION_CONFIG" )
Variables ¶
This section is empty.
Functions ¶
func ConfigMapWatcherFromContext ¶ added in v0.17.0
ConfigMapWatcherFromContext gets the ConfigMapWatchers from the context or nil if there is none suitable
func ContextWithMetricTag ¶
ContextWithMetricTag returns a copy of parent context in which the value associated with metric key is the supplied metric tag.
func FilterConfigByLabelEquals ¶ added in v0.17.0
func FilterConfigByLabelEquals(labelKey string, labelValue string) (*labels.Requirement, error)
FilterConfigByLabelEquals returns an "equas" label requirement for the given label key and value
func IsConfigMapWatcherEnabled ¶ added in v0.17.0
IsConfigMapWatcherEnabled tells MainWithContext that the ConfigMapWatcher is enabled
func IsHAEnabled ¶ added in v0.17.0
IsHAEnabled checks the context for the desire to enable leader elector.
func IsInjectorEnabled ¶ added in v0.17.0
IsInjectorEnabled checks the context for the desire to enable injectors
func Main ¶
func Main(component string, ector EnvConfigConstructor, ctor AdapterConstructor)
func MainMessageAdapter ¶ added in v0.15.0
func MainMessageAdapter(component string, ector EnvConfigConstructor, ctor MessageAdapterConstructor)
func MainMessageAdapterWithContext ¶ added in v0.15.0
func MainMessageAdapterWithContext(ctx context.Context, component string, ector EnvConfigConstructor, ctor MessageAdapterConstructor)
func MainWithContext ¶
func MainWithContext(ctx context.Context, component string, ector EnvConfigConstructor, ctor AdapterConstructor)
func MainWithEnv ¶ added in v0.17.0
func MainWithEnv(ctx context.Context, component string, env EnvConfigAccessor, ctor AdapterConstructor)
func MainWithInformers ¶ added in v0.17.0
func MainWithInformers(ctx context.Context, component string, env EnvConfigAccessor, 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.
func NewCloudEventsClientCRStatus ¶ added in v0.17.0
func NewCloudEventsClientCRStatus(target string, ceOverrides *duckv1.CloudEventOverrides, reporter source.StatsReporter, crStatusEventClient *crstatusevent.CRStatusEventClient) (cloudevents.Client, error)
func SetupConfigMapWatchOrDie ¶ added in v0.17.0
func SetupConfigMapWatchOrDie(ctx context.Context, component string, namespace string) configmap.Watcher
SetupConfigMapWatchOrDie establishes a watch of the configmaps in the component namespace that are labeled to be watched or dies by calling log.Fatalf.
func SetupInformers ¶ added in v0.17.0
func SetupInformers(ctx context.Context, logger *zap.SugaredLogger) (context.Context, []controller.Informer)
func StartInformers ¶ added in v0.17.0
func StartInformers(ctx context.Context, informers []controller.Informer)
func WithConfigMapWatcher ¶ added in v0.17.0
WithConfigWatcher signals to MainWithContext that it should create and configure a ConfigMap watcher
func WithConfigMapWatcherEnabled ¶ added in v0.17.0
WithConfigMapWatcherEnabled signals to MainWithContext that it should create and configure a ConfigMap watcher
func WithHAEnabled ¶ added in v0.17.0
WithHAEnabled signals to MainWithContext that it should set up an appropriate leader elector for this component.
Types ¶
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"` // 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" default:"{}"` // 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" default:"{}"` // TracingConfigJson is a json string of tracing.Config. // This is used to configure the tracing config, the config is stored in // a config map inside the controllers namespace and copied here. // Default is no-op. TracingConfigJson string `envconfig:"K_TRACING_CONFIG"` // LeaderElectionConfigJson is the leader election component configuration. LeaderElectionConfigJson string `envconfig:"K_LEADER_ELECTION_CONFIG"` }
EnvConfig is the minimal set of configuration parameters source adapters should support.
func (*EnvConfig) GetCloudEventOverrides ¶
func (e *EnvConfig) GetCloudEventOverrides() (*duckv1.CloudEventOverrides, error)
func (*EnvConfig) GetLeaderElectionConfig ¶ added in v0.16.0
func (e *EnvConfig) GetLeaderElectionConfig() (*kle.ComponentConfig, error)
func (*EnvConfig) GetLogger ¶
func (e *EnvConfig) GetLogger() *zap.SugaredLogger
func (*EnvConfig) GetMetricsConfig ¶
func (e *EnvConfig) GetMetricsConfig() (*metrics.ExporterOptions, error)
func (*EnvConfig) GetNamespace ¶
func (*EnvConfig) SetComponent ¶
func (*EnvConfig) SetupTracing ¶ added in v0.15.0
func (e *EnvConfig) SetupTracing(logger *zap.SugaredLogger) error
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 SetupTracing(*zap.SugaredLogger) error GetCloudEventOverrides() (*duckv1.CloudEventOverrides, error) // GetLeaderElectionConfig returns leader election configuration. GetLeaderElectionConfig() (*kle.ComponentConfig, error) }
EnvConfigAccessor defines accessors for the minimal set of source adapter configuration parameters.
func ConstructEnvOrDie ¶ added in v0.17.0
func ConstructEnvOrDie(ector EnvConfigConstructor) EnvConfigAccessor
type EnvConfigConstructor ¶
type EnvConfigConstructor func() EnvConfigAccessor
type MessageAdapter ¶ added in v0.15.0
type MessageAdapterConstructor ¶ added in v0.15.0
type MessageAdapterConstructor func(ctx context.Context, env EnvConfigAccessor, adapter *kncloudevents.HttpMessageSender, reporter source.StatsReporter) MessageAdapter
type MetricTag ¶
func MetricTagFromContext ¶
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.