storedb

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MongoDatabaseName     = "kubehound"
	MongoLocalDatabaseURL = "mongodb://localhost:27017"
)
View Source
const (
	StorageProviderName = "mongodb"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncWriter

type AsyncWriter interface {
	// Queue add a model to an asynchronous write queue. Non-blocking.
	Queue(ctx context.Context, model any) error

	// Flush triggers writes of any remaining items in the queue. Blocks until operation completes.
	Flush(ctx context.Context) error

	// Close cleans up any resources used by the AsyncWriter implementation. Writer cannot be reused after this call.
	Close(ctx context.Context) error
}

AysncWriter defines the interface for writer clients to queue aysnchronous, batched writes to the storedb.

type IndexBuilder added in v1.1.0

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

IndexBuilder handles the creation of indices for the store collections.

func NewIndexBuilder added in v1.1.0

func NewIndexBuilder(db *mongo.Database) (*IndexBuilder, error)

NewIndexBuilder creates a new index builder instance for the provided DB.

func (*IndexBuilder) BuildAll added in v1.1.0

func (ib *IndexBuilder) BuildAll(ctx context.Context) error

BuildAll builds all the store indices.

type MongoAsyncWriter

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

func NewMongoAsyncWriter

func NewMongoAsyncWriter(ctx context.Context, db *mongo.Database, collection collections.Collection, opts ...WriterOption) *MongoAsyncWriter

func (*MongoAsyncWriter) Close

func (maw *MongoAsyncWriter) Close(ctx context.Context) error

Close cleans up any resources used by the AsyncWriter implementation. Writer cannot be reused after this call.

func (*MongoAsyncWriter) Flush

func (maw *MongoAsyncWriter) Flush(ctx context.Context) error

Flush triggers writes of any remaining items in the queue. This is blocking

func (*MongoAsyncWriter) Queue

func (maw *MongoAsyncWriter) Queue(ctx context.Context, model any) error

Queue add a model to an asynchronous write queue. Non-blocking.

type MongoProvider

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

A MongoDB based store provider implementation.

func NewMongoProvider

func NewMongoProvider(ctx context.Context, cfg *config.KubehoundConfig) (*MongoProvider, error)

NewMongoProvider creates a new instance of the MongoDB store provider

func (*MongoProvider) BulkWriter

func (mp *MongoProvider) BulkWriter(ctx context.Context, collection collections.Collection, opts ...WriterOption) (AsyncWriter, error)

func (*MongoProvider) Close

func (mp *MongoProvider) Close(ctx context.Context) error

func (*MongoProvider) HealthCheck

func (mp *MongoProvider) HealthCheck(ctx context.Context) (bool, error)

func (*MongoProvider) Name

func (mp *MongoProvider) Name() string

func (*MongoProvider) Prepare added in v1.1.0

func (mp *MongoProvider) Prepare(ctx context.Context) error

func (*MongoProvider) Reader added in v1.2.0

func (mp *MongoProvider) Reader() any

type Optimization added in v1.2.0

type Optimization int
const (
	BalancedOptimization Optimization = iota
	ReadOptimization
	WriteOptimization
)

type Provider

type Provider interface {
	services.Dependency

	// Prepare drops all collections from the database (usually to ensure a clean start) and recreates indices.
	Prepare(ctx context.Context) error

	// Reader returns a handle to the underlying provider to allow implementation specific queries against the mongo DB
	Reader() any

	// BulkWriter creates a new AsyncWriter instance to enable asynchronous bulk inserts.
	BulkWriter(ctx context.Context, collection collections.Collection, opts ...WriterOption) (AsyncWriter, error)

	// Close cleans up any resources used by the Provider implementation. Provider cannot be reused after this call.
	Close(ctx context.Context) error
}

Provider defines the interface for implementations of the storedb provider for intermediate storage of normalized K8s data.

func Factory

func Factory(ctx context.Context, cfg *config.KubehoundConfig) (Provider, error)

Factory returns an initialized instance of a storedb provider from the provided application config.

type WriterOption

type WriterOption func(*writerOptions)

func WithTags

func WithTags(tags []string) WriterOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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