instancemgmt

package
v0.84.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 3 Imported by: 136

Documentation

Overview

Package instancemgmt provides utilities for managing plugin instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedInstance

type CachedInstance struct {
	PluginContext backend.PluginContext
	// contains filtered or unexported fields
}

CachedInstance a cached Instance.

type Instance

type Instance interface{}

Instance is a marker interface for an instance.

type InstanceCallbackFunc

type InstanceCallbackFunc interface{}

InstanceCallbackFunc defines the callback function of the InstanceManager.Do method. The argument provided will of type Instance.

type InstanceDisposer

type InstanceDisposer interface {
	Dispose()
}

InstanceDisposer is implemented by an Instance that has a Dispose method, which defines that the instance is disposable.

InstanceManager will call the Dispose method before an Instance is replaced with a new Instance. This allows an Instance to clean up resources in use, if any.

type InstanceManager

type InstanceManager interface {
	// Get returns an Instance.
	//
	// If Instance is cached and not updated it's returned. If Instance is not cached or
	// updated, a new Instance is created and cached before returned.
	Get(pluginContext backend.PluginContext) (Instance, error)

	// Do provides an Instance as argument to fn.
	//
	// If Instance is cached and not updated provides as argument to fn. If Instance is not cached or
	// updated, a new Instance is created and cached before provided as argument to fn.
	Do(pluginContext backend.PluginContext, fn InstanceCallbackFunc) error
}

InstanceManager manages the lifecycle of instances.

func New

func New(provider InstanceProvider) InstanceManager

New create a new instance manager.

type InstanceProvider

type InstanceProvider interface {
	// GetKey returns a cache key to be used for caching an Instance.
	GetKey(pluginContext backend.PluginContext) (interface{}, error)

	// NeedsUpdate returns whether a cached Instance have been updated.
	NeedsUpdate(pluginContext backend.PluginContext, cachedInstance CachedInstance) bool

	// NewInstance creates a new Instance.
	NewInstance(pluginContext backend.PluginContext) (Instance, error)
}

InstanceProvider defines an instance provider, providing instances.

Jump to

Keyboard shortcuts

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