cn-infra: github.com/ligato/cn-infra/infra Index | Files

package infra

import "github.com/ligato/cn-infra/infra"

Package infra provides Plugin interface and related utilities.

Index

Package Files

infra.go

type Plugin Uses

type Plugin interface {
    // Init is called in the agent`s startup phase.
    Init() error
    // Close is called in the agent`s cleanup phase.
    Close() error
    // String returns unique name of the plugin.
    String() string
}

Plugin interface defines plugin's basic life-cycle methods.

type PluginDeps Uses

type PluginDeps struct {
    PluginName
    Log logging.PluginLogger
    Cfg config.PluginConfig
}

PluginDeps defines common dependencies for use with plugins. It can easily be embedded in Deps for Plugin:

type Deps struct {

infra.PluginDeps
// other dependencies

}

func (*PluginDeps) Close Uses

func (d *PluginDeps) Close() error

Close is an empty implementation used to avoid need for implementing it by plugins that do not need it.

func (*PluginDeps) Setup Uses

func (d *PluginDeps) Setup()

Setup sets up default instances for plugin deps.

func (*PluginDeps) SetupLog Uses

func (d *PluginDeps) SetupLog()

SetupLog sets up default instance for plugin log dep.

type PluginName Uses

type PluginName string

PluginName is a part of the plugin's API. It's used by embedding it into Plugin to provide unique name of the plugin.

func (*PluginName) SetName Uses

func (name *PluginName) SetName(n string)

SetName sets plugin name.

func (PluginName) String Uses

func (name PluginName) String() string

String returns the PluginName.

type PostInit Uses

type PostInit interface {
    // AfterInit is called once Init() of all plugins have returned without error.
    AfterInit() error
}

PostInit interface defines an optional method for plugins with additional initialization.

Package infra imports 2 packages (graph) and is imported by 91 packages. Updated 2019-05-06. Refresh now. Tools for package owners.