postgresql

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2019 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package postgresql contains an implementation of the `gokv.Store` interface for PostgreSQL.

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	ConnectionURL:      "postgres://postgres@/" + defaultDBname + "?sslmode=disable",
	TableName:          "Item",
	MaxOpenConnections: 100,
	Codec:              encoding.JSON,
}

DefaultOptions is an Options object with default values. ConnectionURL: "postgres://postgres@/gokv?sslmode=disable", TableName: "Item", MaxOpenConnections: 100, Codec: encoding.JSON

Functions

This section is empty.

Types

type Client

type Client struct {
	*sql.Client
}

Client is a gokv.Store implementation for PostgreSQL.

func NewClient

func NewClient(options Options) (Client, error)

NewClient creates a new PostgreSQL client.

You must call the Close() method on the client when you're done working with it.

type Options

type Options struct {
	// Connection URL.
	// Format: postgres://username[:password]@[address]/dbname[?param1=value1&...&paramN=valueN].
	// Full example: "postgres://username:password@host:123/dbname?sslmode=verify-full".
	// Minimal example: "postgres://postgres@/dbname".
	// The database ("dbname" in the example) must already exist.
	// Optional ("postgres://postgres@/gokv?sslmode=disable" by default,
	// which will connect to "localhost:5432"
	// and requires the server to be configured with "trust" authentication
	// to not require a password when connecting from the same host.
	// When running the official PostgreSQL Docker container
	// and accessing it from outside the container,
	// this is NOT the "same host" (except when running with `--network host`)).
	ConnectionURL string
	// Name of the table in which the key-value pairs are stored.
	// Optional ("Item" by default).
	TableName string
	// Limits the number of open connections to the PostgreSQL server.
	// -1 for no limit. 0 will lead to the default value (100) being set.
	// Optional (100 by default).
	MaxOpenConnections int
	// Encoding format.
	// Optional (encoding.JSON by default).
	Codec encoding.Codec
}

Options are the options for the PostgreSQL client.

Jump to

Keyboard shortcuts

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