storedb

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

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

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 MongoAsyncWriter

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

func NewMongoAsyncWriter

func NewMongoAsyncWriter(ctx context.Context, mp *MongoProvider, 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
}

func NewMongoProvider

func NewMongoProvider(ctx context.Context, url string, connectionTimeout time.Duration) (*MongoProvider, error)

func (*MongoProvider) BulkWriter

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

func (*MongoProvider) Clear

func (mp *MongoProvider) Clear(ctx context.Context) 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) Raw

func (mp *MongoProvider) Raw() any

type Provider

type Provider interface {
	services.Dependency

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

	// Raw returns a handle to the underlying provider to allow implementation specific operations e.g db queries.
	Raw() 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