couchdb

package
v0.4.22 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 10 Imported by: 0

README

Environment based configuration

  • COUCHDB_URL default: "http://couchdb:5984/"
    • URL to connect to couchdb, http or https.
  • COUCHDB_USER default: "admin"
    • User used to authenticate with couchdb.
  • COUCHDB_PASSWORD default: "secret"
    • Password user to authenticate with couchdb.
  • COUCHDB_DB default: "test"
    • Default database to connect to.
  • COUCHDB_DB_AUTO_CREATE default: "true"
    • If enabled will create the couchdb database if possible.
  • COUCHDB_HEALTH_CHECK_KEY default: "$health_check"
    • Name of the object that is used for the health check operation.
  • COUCHDB_HEALTH_CHECK_RESULT_TTL default: 10s
    • Amount of time to cache the last health check result.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(cfg *Config) (*kivik.Client, error)

func Database

func Database(name string) (*kivik.DB, error)

func DefaultDatabase

func DefaultDatabase() (*kivik.DB, error)

Types

type AuthTransport

type AuthTransport struct {
	Username, Password string
	// contains filtered or unexported fields
}

func (*AuthTransport) RoundTrip

func (l *AuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

func (*AuthTransport) SetTransport

func (l *AuthTransport) SetTransport(rt http.RoundTripper)

func (*AuthTransport) Transport

func (rt *AuthTransport) Transport() http.RoundTripper

type Config

type Config struct {
	URL                   string        `env:"COUCHDB_URL" envDefault:"http://couchdb:5984/"`
	User                  string        `env:"COUCHDB_USER" envDefault:"admin"`
	Password              string        `env:"COUCHDB_PASSWORD" envDefault:"secret"`
	Database              string        `env:"COUCHDB_DB" envDefault:"test"`
	DatabaseAutoCreate    bool          `env:"COUCHDB_DB_AUTO_CREATE" envDefault:"true"`
	HealthCheckKey        string        `env:"COUCHDB_HEALTH_CHECK_KEY" envDefault:"$health_check"`
	HealthCheckResultTTL  time.Duration `env:"COUCHDB_HEALTH_CHECK_RESULT_TTL" envDefault:"10s"`
	DisableHealthCheck    bool          `env:"COUCHDB_DISABLE_HEALTH_CHECK" envDefault:"false"`
	DisableRequestLogging bool          `env:"COUCHDB_DB_DISABLE_REQUEST_LOGGING" envDefault:"false"`
}

func ParseConfig

func ParseConfig() (*Config, error)

type Doc

type Doc struct {
	ID   string `json:"_id"`
	Rev  string `json:"_rev,omitempty"`
	Time string `json:"at"`
}

type HealthCheck

type HealthCheck struct {
	Name   string
	Client *kivik.Client
	DB     *kivik.DB
	Config *Config
	// contains filtered or unexported fields
}

HealthCheck checks the state of the object storage client. It must not be changed after it was registered as a health check.

func (*HealthCheck) HealthCheck

HealthCheck checks if the object storage client is healthy. If the last result is outdated, object storage is checked for upload and download, otherwise returns the old result

Jump to

Keyboard shortcuts

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