certmagicsql

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 6 Imported by: 0

README

certmagic-sqlstorage

GoDoc

SQL storage for CertMagic/Caddy TLS data.

Currently supports PostgreSQL but it'd be pretty easy to support other RDBs like SQLite and MySQL. Please make a pull-request if you add support for them and I'll gladly merge.

Example

db, err := sql.Open("postgres", "conninfo")
if err != nil { ... }
storage, err := certmagicsql.NewStorage(
    db,
    certmagicsql.Options{},
)
if err != nil { ... }
certmagic.Default.Storage = storage

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStorage

func NewStorage(ctx context.Context, db DB, options Options) (certmagic.Storage, error)

NewStorage creates a new storage instance. The `db` you pass in will likely be a *database/sql.DB. This method will create the required metadata tables if necessary (certmagic_data and certmagic_locks).

Types

type DB

type DB interface {
	BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
}

DB represents the required database API. You can use a *database/sql.DB.

type Database

type Database int

Database RDBs this library supports, currently supports Postgres only.

const (
	Postgres Database = iota
)

type Options

type Options struct {
	QueryTimeout time.Duration
	LockTimeout  time.Duration
	Database     Database
}

Jump to

Keyboard shortcuts

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