runner

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogFields

func LogFields(def integration.Definition) logrus.Fields

func NewGroup

func NewGroup(
	loadFn LoadFn,
	il integration.InstancesLookup,
	passthroughEnv []string,
	emitter emitter.Emitter,
	cmdReqHandle cmdrequest.HandleFn,
	configHandle configrequest.HandleFn,
	cfgPath string,
	terminateDefinitionQ chan string,
	idLookup host.IDLookup,
) (g Group, c FeaturesCache, err error)

NewGroup configures a Group instance that is provided by the passed LoadFn cfgPath is used for caching to be consumed by cmd-channel FF enabler.

func NewRunner

func NewRunner(
	intDef integration.Definition,
	emitter emitter.Emitter,
	dSources *databind.Sources,
	handleErrorsProvide func() runnerErrorHandler,
	cmdReqHandle cmdrequest.HandleFn,
	configHandle configrequest.HandleFn,
	terminateQ chan<- string,
	idLookup host.IDLookup,
) *runner

NewRunner creates an integration runner instance. args: discoverySources, handleErrorsProvide and cmdReqHandle are optional (nils allowed).

Types

type CmdFF

type CmdFF struct {
	Name    string // feature flag name
	Enabled bool
}

CmdFF DTO storing a request from the cmd-channel to enable or disable an integration feature.

func (*CmdFF) IsEnabledOHI

func (c *CmdFF) IsEnabledOHI(ff string) *bool

IsEnabledOHI returns if enabled or nil in case it's unknown.

type Features

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

Features carries the agent config features and a cmd-channel feature, to be able to determine a future OHI execution.

func NewFeatures

func NewFeatures(fromAgent map[string]bool, cmdFF *CmdFF) *Features

NewFeatures creates a features object bundling features provided by agent and cmd-channel FF. If no matching feature is found nil is returned. Formats btw CC FF and config files:

  • Cmd-Channel FF: | docker_enabled
  • Agent yaml: | features: | docker_enabled: true
  • OHI yaml: | - name: nri-docker | when: | feature: docker_enabled

func (*Features) IsOHIExecutable

func (f *Features) IsOHIExecutable(featureFromOHICfg string) bool

IsOHIExecutable determines the execution of an OHI given the features from config deps (agent & OHI) and cmd-channel. Rules: a. !ohi FF -> executed b. ohi FF + agent FF -> agent determines c. ohi FF + !agent FF + !CC -> not executed d. ohi FF + !agent FF + CC -> cmd-channel determines

type FeaturesCache

type FeaturesCache map[string]string

FeaturesCache stores per feature name it's config path.

func (FeaturesCache) Update

func (c FeaturesCache) Update(newFC FeaturesCache)

Update updates current cache merging from provided one.

type Group

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

Group represents a set of runnable integrations that are located in the same integration configuration file, and thus share a common discovery mechanism configuration. It also does the following tasks: - parses integration output and forwards it - parses standard error and logs it - catches errors and logs them - manages the cancellation of tasks, as this should-be hot-reloaded

func (*Group) Run

func (g *Group) Run(ctx context.Context) (hasStartedAnyOHI bool)

Run launches all the integrations to run in background. They can be cancelled with the provided context

func (*Group) RunOnce

func (g *Group) RunOnce(ctx context.Context)

RunOnce will execute the group of integrations just one time.

type LoadFn

type LoadFn func(dr integration.InstancesLookup, passthroughEnv []string, cfgPath string, cmdReqHandle cmdrequest.HandleFn, configHandle configrequest.HandleFn, terminateDefinitionQ chan string) (Group, FeaturesCache, error)

LoadFn provides a basic, incomplete Group instance to be configured by the NewGroup function. InstancesLookup is only required to load v3 integrations from an external definitions folder.

func NewLoadFn

func NewLoadFn(cfg config2.YAML, agentAndCCFeatures *Features) LoadFn

NewLoadFn returns a function that provides partial Group holding provided configuration and features cache. Optionally agent and integration "features" can be provided to be able to load disabled integrations.

Jump to

Keyboard shortcuts

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