pgevents

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Schema    = "postgres"
	AltSchema = "postgresql"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMode

type AuthMode string

AuthMode determines if we should use some environment-specific authentication mechanism or credentials.

const (
	// FixedAuth uses the static credentials as defined in the connection
	// string.
	FixedAuth AuthMode = ""
	// AzureADAuth gets a connection token from Azure and uses it as the
	// password when connecting.
	AzureADAuth AuthMode = "azure"
)

func (AuthMode) Check

func (a AuthMode) Check() error

Check returns an error if the AuthMode is invalid.

type Config

type Config struct {
	Log        logrus.FieldLogger
	PoolConfig *pgxpool.Config

	AuthMode AuthMode

	DisableCleanup  bool
	RetentionPeriod time.Duration
	CleanupInterval time.Duration
}

Config is the configuration struct to pass to New.

func (*Config) CheckAndSetDefaults

func (c *Config) CheckAndSetDefaults() error

CheckAndSetDefaults checks if the Config is valid, setting default parameters where they're unset. PoolConfig is only checked for presence.

func (*Config) SetFromURL

func (c *Config) SetFromURL(u *url.URL) error

SetFromURL sets config params from the URL, as per pgxpool.ParseConfig (with some additional query params in the fragment for our own options).

type Log

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

Log is an external events.AuditLogger backed by a PostgreSQL database.

func New

func New(ctx context.Context, cfg Config) (*Log, error)

Returns a new Log given a Config. Starts a background cleanup task unless disabled in the Config.

func (*Log) Close

func (l *Log) Close() error

Close stops all background tasks and closes the connection pool.

func (*Log) EmitAuditEvent

func (l *Log) EmitAuditEvent(ctx context.Context, event apievents.AuditEvent) error

EmitAuditEvent implements events.AuditLogger.

func (*Log) SearchEvents

func (l *Log) SearchEvents(ctx context.Context, req events.SearchEventsRequest) ([]apievents.AuditEvent, string, error)

SearchEvents implements events.AuditLogger.

func (*Log) SearchSessionEvents

func (l *Log) SearchSessionEvents(ctx context.Context, req events.SearchSessionEventsRequest) ([]apievents.AuditEvent, string, error)

SearchSessionEvents implements events.AuditLogger.

Jump to

Keyboard shortcuts

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