enricher

package
v0.0.0-...-d8c2abc Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppMetadata

type AppMetadata struct {
	App       string
	Space     string
	Org       string
	AppGUID   string
	SpaceGUID string
	OrgGUID   string
}

type CFClient

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

func NewCFClient

func NewCFClient(cfg ConfigCF) (*CFClient, error)

func (*CFClient) GetAppMetadata

func (e *CFClient) GetAppMetadata(appGUID string) (AppMetadata, error)

GetAppMetadata returns the metadata for the application with the specified GUID

func (*CFClient) GetRunningAppMetadata

func (e *CFClient) GetRunningAppMetadata() ([]AppMetadata, error)

GetRunningAppMetadata returns the metadata for all STARTED applications.

type Callback

type Callback func(err error)

type CfCallback

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

func NewCfCallback

func NewCfCallback(parent Enricher, cb Callback) *CfCallback

func (*CfCallback) GetAppMetadata

func (c *CfCallback) GetAppMetadata(app_guid string) (AppMetadata, error)

type ConfigCF

type ConfigCF struct {
	API               string        `required:"true" desc:"URL of the Cloud Foundry API endpoint"`                          // CFMR_CF_API
	User              string        `required:"true" desc:"Username for the Cloud Foundry API"`                             // CFMR_CF_USER
	Password          string        `required:"true" desc:"Password for the Cloud Foundry API"`                             // CFMR_CF_PASSWORD
	Timeout           time.Duration `default:"1m" desc:"Timeout for Cloud Foundry API requests"`                            // CFMR_CF_TIMEOUT
	SkipSSLValidation bool          `default:"false" desc:"Skip SSL certificate validation for Cloud Foundry API requests"` // CFMR_CF_SKIPSSLVALIDATION
	ResultsPerPage    int           `default:"50" desc:"Number of results per page to fetch from CF API"`                   // CFMR_CF_RESULTSPERPAGE
	Token             string        `desc:"Token for Cloud Foundry API"`                                                    // CFMR_CF_TOKEN
	ClientID          string        `desc:"Client ID for Cloud Foundry API"`                                                // CFMR_CF_CLIENTID
	ClientSecret      string        `desc:"Client secret for Cloud Foundry API"`                                            // CFMR_CF_CLIENTSECRET
	UserAgent         string        `ignored:"true"`
}

type Enricher

type Enricher interface {
	GetAppMetadata(app_guid string) (AppMetadata, error)
}

func NewMemLRUCache

func NewMemLRUCache(parent Enricher) Enricher

NewMemLRUCache creates a MemLRUCache that uses the provided parent Enricher to resolve misses

func NewNegativeMemLRUCache

func NewNegativeMemLRUCache(parent Enricher) Enricher

NewNegativeMemLRUCache creates a NegativeMemLRUCache that uses the provided parent Enricher to add negative cache

func NewRetrier

func NewRetrier(e Enricher) Enricher

TODO: change retries to be configurable

type MemLRUCache

type MemLRUCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MemLRUCache is an in-memory LRU/passthru cache that satisfies the Enricher interface. It can be used to add local caching to a parent Enricher.

func (*MemLRUCache) Expire

func (e *MemLRUCache) Expire(olderThan time.Duration)

Expire removes from the cache all entries that have not been queried in the specified duration.

func (*MemLRUCache) GetAppMetadata

func (e *MemLRUCache) GetAppMetadata(appGUID string) (AppMetadata, error)

GetAppMetadata returns the application metadata for the specified application GUID. If the metadata is in the in-memory cache, it is returned directly; otherwise the parent Enriched is queried and the in-memory cache updated.

func (*MemLRUCache) Warmup

func (e *MemLRUCache) Warmup(mds []AppMetadata)

Warmup merges the list of application metadata returned by the supplied function with the metadata in cache. If the cache already contains metadata about a certain application, but the supplied function does not include new metadata for it, the cached metadata is not modified/overwritten.

type NegativeMemLRUCache

type NegativeMemLRUCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

NegativeMemLRUCache is an in-memory LRU/passthru cache that satisfies the Enricher interface. It can be used to add local caching to a parent Enricher.

func (*NegativeMemLRUCache) Expire

func (nm *NegativeMemLRUCache) Expire(olderThan time.Duration)

Expire removes from the negative cache all entries that have not been queried in the specified duration.

func (*NegativeMemLRUCache) GetAppMetadata

func (nm *NegativeMemLRUCache) GetAppMetadata(appGUID string) (AppMetadata, error)

GetAppMetadata returns the application metadata for the specified application GUID. If the metadata is in the in-memory negative cache, it is returned empty metadata directly; otherwise the parent Enriched is queried and the in-memory negative cache updated if the parent could not find the app.

func (*NegativeMemLRUCache) Warmup

func (nm *NegativeMemLRUCache) Warmup(mds []AppMetadata)

Warmup compares the list of running applications with the ones in the negative cache. If the application in the negative cache is in the list of running applications, then remove it, otherwise, keep it and update the time last not found.

type Retrier

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

func (*Retrier) GetAppMetadata

func (e *Retrier) GetAppMetadata(app_guid string) (AppMetadata, error)

Jump to

Keyboard shortcuts

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