db

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultBatchSize     = 100
	DefaultFlushInterval = time.Minute
	DefaultTableName     = "results"
	DefaultDatabaseName  = "httpx"
	EnvConnectionString  = "HTTPX_DB_CONNECTION_STRING"
)

Variables

This section is empty.

Functions

func Register

func Register(dbType DatabaseType, factory databaseFactory)

Types

type Config

type Config struct {
	Type             DatabaseType  `yaml:"type"`
	ConnectionString string        `yaml:"connection-string"`
	DatabaseName     string        `yaml:"database-name"`
	TableName        string        `yaml:"table-name"`
	BatchSize        int           `yaml:"batch-size"`
	FlushInterval    time.Duration `yaml:"flush-interval"`
	OmitRaw          bool          `yaml:"omit-raw"`
}

func LoadConfigFromFile

func LoadConfigFromFile(configPath string) (*Config, error)

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

func (*Config) Validate

func (c *Config) Validate() error

type Database

type Database interface {
	Connect(ctx context.Context) error

	Close() error

	InsertBatch(ctx context.Context, results []runner.Result) error

	EnsureSchema(ctx context.Context) error

	Type() DatabaseType
}

func NewDatabase

func NewDatabase(cfg *Config) (Database, error)

type DatabaseType

type DatabaseType string
const (
	MongoDB    DatabaseType = "mongodb"
	PostgreSQL DatabaseType = "postgres"
	MySQL      DatabaseType = "mysql"
)

func SupportedDatabases

func SupportedDatabases() []DatabaseType

func (DatabaseType) IsValid

func (d DatabaseType) IsValid() bool

func (DatabaseType) String

func (d DatabaseType) String() string

type Options

type Options struct {
	Enabled          bool
	ConfigFile       string
	Type             string
	ConnectionString string
	DatabaseName     string
	TableName        string
	BatchSize        int
	OmitRaw          bool
}

func (*Options) ToConfig

func (o *Options) ToConfig() (*Config, error)

type Writer

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

func NewWriter

func NewWriter(ctx context.Context, cfg *Config) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close()

func (*Writer) GetWriterCallback

func (w *Writer) GetWriterCallback() runner.OnResultCallback

func (*Writer) Stats

func (w *Writer) Stats() int64

Jump to

Keyboard shortcuts

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