disk

package
v3.20.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Name = "disk"
)

Variables

View Source
var Connections = &Writer{
	openConnections:   make(map[string]Connection),
	closedConnections: make(map[string]FailedConnection),
	cleanupDone:       make(chan struct{}),
	closeAndRemoveFilesWithRetry: func(conn Connection) error {
		return wait.ExponentialBackoff(retry.DefaultBackoff, func() (bool, error) {
			if conn.File != nil {
				if err := conn.unlockAndCloseFile(); err != nil {
					return false, fmt.Errorf("error closing file: %w", err)
				}
			}
			if err := os.RemoveAll(conn.Path); err != nil {
				return false, fmt.Errorf("error deleting violations stored at old path: %w", err)
			}
			return true, nil
		})
	},
}

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// path to store audit logs
	Path string `json:"path,omitempty"`
	// max number of audit results to store
	MaxAuditResults int `json:"maxAuditResults,omitempty"`
	// ClosedConnectionTTL specifies how long a failed connection remains
	// in the cleanup queue before being permanently removed (not retried).
	// This prevents memory leaks from accumulating failed connections.
	ClosedConnectionTTL time.Duration `json:"closedConnectionTTL,omitempty"`
	// File to write audit logs
	File *os.File
	// contains filtered or unexported fields
}

type FailedConnection

type FailedConnection struct {
	Connection
	FailedAt    time.Time
	RetryCount  int
	NextRetryAt time.Time
}

FailedConnection wraps a Connection with retry metadata.

type Writer

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

func (*Writer) CloseConnection

func (r *Writer) CloseConnection(connectionName string) error

func (*Writer) CreateConnection

func (r *Writer) CreateConnection(_ context.Context, connectionName string, config interface{}) error

func (*Writer) Publish

func (r *Writer) Publish(_ context.Context, connectionName string, data interface{}, topic string) error

func (*Writer) UpdateConnection

func (r *Writer) UpdateConnection(_ context.Context, connectionName string, config interface{}) error

Jump to

Keyboard shortcuts

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