caddypostgresql

package module
v0.0.0-...-f0fc3af Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 14 Imported by: 0

README

Caddy Storage PostgresQL

[!WARNING] This project is still a work in progress. Do not use in production.

A storage implementation for Caddy that uses PostgreSQL as the backend.

  • ✅ Supports all Caddy storage operations
  • ✅ Directories semantics fully implemented (e.g. listing objects in a directory)
  • ✅ Supports storage export (recursive listing of all files)
  • ✅ Works in distributed Caddy setups thanks to distributed locking with fencing tokens (pglock)
  • ✅ Fully tested (integration tests + smoke tests and real export test)

How to use

Build the module into your Caddy binary:

xcaddy build --with github.com/dmarcwise/caddy-storage-postgresql

Configure Caddy to use the PostgreSQL storage module. Example Caddyfile:

{
    storage postgresql {
        dsn "postgres://user:password@localhost:5432/caddy?sslmode=disable"
    }
}

The dsn parameter is a PostgreSQL connection string, either as a key/value string or as a connection URI.

The sslmode connection parameter defaults to require. We recommend setting a statement_timeout (e.g. 30s) and other basic parameters.

This module implementation already sets the following connection pooling parameters: maximum open connection (10), maximum idle connections (3), and connection maximum idle time (1h).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresStorage

type PostgresStorage struct {
	Dsn        string `json:"dsn,omitempty"`
	DebugLocks bool   `json:"debug_locks,omitempty"`
	// contains filtered or unexported fields
}

func NewPostgresStorage

func NewPostgresStorage() *PostgresStorage

func (PostgresStorage) CaddyModule

func (PostgresStorage) CaddyModule() caddy.ModuleInfo

func (*PostgresStorage) CertMagicStorage

func (s *PostgresStorage) CertMagicStorage() (certmagic.Storage, error)

func (*PostgresStorage) Cleanup

func (s *PostgresStorage) Cleanup() error

func (*PostgresStorage) Delete

func (s *PostgresStorage) Delete(ctx context.Context, key string) error

func (*PostgresStorage) Exists

func (s *PostgresStorage) Exists(ctx context.Context, key string) bool

func (*PostgresStorage) List

func (s *PostgresStorage) List(ctx context.Context, path string, recursive bool) ([]string, error)

func (*PostgresStorage) Load

func (s *PostgresStorage) Load(ctx context.Context, key string) ([]byte, error)

func (*PostgresStorage) Lock

func (s *PostgresStorage) Lock(ctx context.Context, name string) error

func (*PostgresStorage) Provision

func (s *PostgresStorage) Provision(ctx caddy.Context) error

func (*PostgresStorage) Stat

func (*PostgresStorage) Store

func (s *PostgresStorage) Store(ctx context.Context, key string, value []byte) error

func (*PostgresStorage) Unlock

func (s *PostgresStorage) Unlock(ctx context.Context, name string) error

func (*PostgresStorage) UnmarshalCaddyfile

func (s *PostgresStorage) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

Jump to

Keyboard shortcuts

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