bulk

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: 4 Imported by: 0

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0 Package bulk provides utilities and mechanism for sending bulk inventories to the backend, including management of sources from different entities and dividing payloads when they do not fit into the size limits at backend side

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer helps creating payloads from multiple PostDeltaBody instances and control their size

func NewBuffer

func NewBuffer(capacity int) Buffer

NewBuffer creates a new bulk buffer

func (*Buffer) Add

func (b *Buffer) Add(ent entity.Key, body inventoryapi.PostDeltaBody) error

Add a given payload to buffers and associates it with the given entity. It returns error if: - There is already a payload for the entity - The body can't be marshaled into a JSON - The object is too big for the free space of the buffer

func (Buffer) AsSlice

func (b Buffer) AsSlice() []inventoryapi.PostDeltaBody

AsSlice returns the PostDeltaBody entries as a slice

func (*Buffer) Clear

func (b *Buffer) Clear()

Clear empties the buffer

func (Buffer) Entries

func (b Buffer) Entries() int

Entries returns the number of entries that are buffered

func (Buffer) Get

Get returns the PostDeltaBody buffered for the given entity ID, or nil if there is no PostDeltaBody for such entity

Jump to

Keyboard shortcuts

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