Documentation ¶
Overview ¶
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- type EntityIDFilePersist
- type EntityIDPersist
- type LastSubmissionFileStore
- type LastSubmissionInMemory
- type LastSubmissionStore
- type PIEntity
- type PluginInfo
- type Storage
- type Store
- func (s *Store) ChangeDefaultEntity(newEntityKey string)
- func (s *Store) CompactStorage(entityKey string, threshold uint64) (err error)
- func (s *Store) DeltaFilePath(pluginItem *PluginInfo, entityKey string) string
- func (s *Store) EntityFolder(entityKey string) string
- func (s *Store) PluginDirPath(pluginCategory, entityKey string) string
- func (s *Store) ReadDeltas(entityKey string) ([]inventoryapi.RawDeltaBlock, error)
- func (s *Store) RemoveEntity(entityKey string) error
- func (s *Store) RemoveEntityFolders(entityFolder string) error
- func (s *Store) ResetAllDeltas(entityKey string)
- func (s *Store) SavePluginSource(entityKey, category, term string, source map[string]interface{}) (err error)
- func (s *Store) SaveState() (err error)
- func (s *Store) ScanEntityFolders() (map[string]interface{}, error)
- func (s *Store) SourceFilePath(pluginItem *PluginInfo, entityKey string) string
- func (s *Store) StorageSize(path string) (uint64, error)
- func (s *Store) UpdatePluginsInventoryCache(entityKey string) (err error)
- func (s *Store) UpdateState(entityKey string, deltas []*inventoryapi.RawDelta, ...)
Constants ¶
const ( DATA_DIR_MODE = 0755 // default mode for data directories DATA_FILE_MODE = 0644 // default mode for data files CACHE_DIR = ".delta_repo" SAMPLING_REPO = ".sampling_repo" CACHE_ID_FILE = "delta_id_cache.json" UNSENT_DELTA_JOURNAL_EXT = ".pending" ARCHIVE_DELTA_JOURNAL_EXT = ".sent" NO_DELTA_ID = 0 DisableInventorySplit = 0 )
Variables ¶
var EMPTY_DELTA = []byte{'{', '}'}
var ErrNoPreviousSuccessSubmissionTime = fmt.Errorf("no previous success submission time")
var NULL = []byte{'n', 'u', 'l', 'l'}
Functions ¶
This section is empty.
Types ¶
type EntityIDFilePersist ¶
type EntityIDFilePersist struct {
// contains filtered or unexported fields
}
EntityIDFilePersist will store on the given file the EntityID in order to persist it between agent restarts.
func NewEntityIDFilePersist ¶
func NewEntityIDFilePersist(dataDir string, fileName string) *EntityIDFilePersist
NewEntityIDFilePersist create a new instance of EntityIDFilePersist.
func (*EntityIDFilePersist) GetEntityID ¶
func (e *EntityIDFilePersist) GetEntityID() (entity.ID, error)
GetEntityID will return entityID from memory or disk.
func (*EntityIDFilePersist) UpdateEntityID ¶
func (e *EntityIDFilePersist) UpdateEntityID(id entity.ID) error
UpdateEntityID will store the entityID on memory and disk.
type EntityIDPersist ¶
type LastSubmissionFileStore ¶
type LastSubmissionFileStore struct {
// contains filtered or unexported fields
}
LastSubmissionFileStore persists last successful submission date.
func (*LastSubmissionFileStore) UpdateTime ¶
func (l *LastSubmissionFileStore) UpdateTime(t time.Time) error
type LastSubmissionInMemory ¶
type LastSubmissionInMemory struct {
// contains filtered or unexported fields
}
LastSubmissionInMemory stores last successful submission date in memory.
func (*LastSubmissionInMemory) UpdateTime ¶
func (l *LastSubmissionInMemory) UpdateTime(t time.Time) error
type LastSubmissionStore ¶
LastSubmissionStore retrieves and stores last inventory successful submission time.
func NewLastSubmissionInMemory ¶
func NewLastSubmissionInMemory() LastSubmissionStore
NewLastSubmissionInMemory creates a fake LastSubmissionStore with ephemeral persistence for tests new instance assumes current time as last submission.
func NewLastSubmissionStore ¶
func NewLastSubmissionStore(dataDir, fileName string) LastSubmissionStore
NewLastSubmissionStore creates a new LastSubmissionStore storing data in file.
type PIEntity ¶
type PIEntity struct { MostRecentID int64 `json:"mru_id"` // latest ID for an plugin entity to be used for submission LastSentID int64 `json:"last_sent_id"` // latest ID from platform, decides whether archive or keep delta }
PIEntity persisted info about an entity for a plugin.
type PluginInfo ¶
type PluginInfo struct { Source string `json:"source"` Plugin string `json:"plugin"` FileName string `json:"filename"` Entities map[string]PIEntity `json:"entities"` }
PluginInfo persisted information about plugins.
type Storage ¶
type Storage interface { ReadDeltas(entityKey string) ([]inventoryapi.RawDeltaBlock, error) RemoveEntity(entityKey string) error CompactStorage(entityKey string, threshold uint64) (err error) ResetAllDeltas(entityKey string) UpdateState(entityKey string, deltas []*inventoryapi.RawDelta, deltaStateResults *inventoryapi.DeltaStateMap) SaveState() (err error) }
type Store ¶
type Store struct { // DataDir holds the agent data directory DataDir string // CacheDir holds the agent cache directory CacheDir string // contains filtered or unexported fields }
Store handles information about the storage of Deltas.
func NewStore ¶
NewStore creates a new Store and returns a pointer to it. If maxInventorySize <= 0, the inventory splitting is disabled
func (*Store) ChangeDefaultEntity ¶
func (*Store) CompactStorage ¶
CompactStorage reduces the size of the Delta Storage
func (*Store) DeltaFilePath ¶
func (s *Store) DeltaFilePath(pluginItem *PluginInfo, entityKey string) string
func (*Store) EntityFolder ¶
EntityFolder provides the folder name for a given entity ID, or for the agent default entity in case entityKey is an empty string
func (*Store) PluginDirPath ¶
func (*Store) ReadDeltas ¶
func (s *Store) ReadDeltas(entityKey string) ([]inventoryapi.RawDeltaBlock, error)
ReadDeltas collects the plugins and read their deltas, grouped in blocks of size < maxInventorySize
func (*Store) RemoveEntity ¶
RemoveEntity removes the entity cached storage.
func (*Store) RemoveEntityFolders ¶
RemoveEntityFolders removes the entity cached storage from the entities whose folder is equal to the argument.
func (*Store) ResetAllDeltas ¶
ResetAllDeltas clears the plugin delta store for all the existing plugins
func (*Store) SavePluginSource ¶
func (s *Store) SavePluginSource(entityKey, category, term string, source map[string]interface{}) (err error)
StorePluginOutput will take a PluginOutput blob and write it to the data directory in JSON format
func (*Store) ScanEntityFolders ¶
ScanEntityFolders returns a set of those entities that have been found in the different plugin folders.
func (*Store) SourceFilePath ¶
func (s *Store) SourceFilePath(pluginItem *PluginInfo, entityKey string) string
func (*Store) StorageSize ¶
StorageSize returns the size used in bytes of all the loose objects in the cache, non-inclusive of dirs
func (*Store) UpdatePluginsInventoryCache ¶
UpdatePluginsInventoryCache looks for all the plugins of the given entityKey located in the store DataDir, for each of the plugins, it compares the inventory json source and compares it against the cached json.
If the JSONs differ, creates a delta file and replaces the cache with the source file. Then finally writes on disk the plugin ID maps.
func (*Store) UpdateState ¶
func (s *Store) UpdateState(entityKey string, deltas []*inventoryapi.RawDelta, deltaStateResults *inventoryapi.DeltaStateMap)
UpdateState updates in disk the state of the deltas according to the passed PostDeltaBody, whose their ExternalKeys field may be empty.