Documentation
¶
Overview ¶
Package postgres is postgres database implementation of the `key.Storage` interface
Index ¶
Constants ¶
const (
// EnvPostgresPassword is the environment variable name for the postgres password.
EnvPostgresPassword = "HANCOCK_POSTGRES_PASSWORD"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { key.Config // The database user User string `json:"user"` // The user password Password string `json:"password"` // The hostname of the database Host string `json:"host"` // The port of the database Port int `json:"port"` // The database name Name string `json:"dbname"` // The ssl mode for connecting to the database. // See https://www.postgresql.org/docs/9.1/ssl-tcp.html for options and info. SSLMode string `json:"sslmode"` }
Config is a struct for holding settings for a postgres backed key `Storage`.
func LoadConfig ¶
LoadConfig loads the config provided in the []byte rawConfig. It is assummed the array encodes a json configuration of `Config`.
type KeyStorage ¶
type KeyStorage struct {
// contains filtered or unexported fields
}
KeyStorage is an implementation of `key.Storage` using a postgres as a backend.
func (*KeyStorage) Create ¶
Create inserts a new `key.Key` into the database. The id will be generated as a v4 uuid.
func (*KeyStorage) Get ¶
func (s *KeyStorage) Get(sid string) (*key.Key, error)
Get fetches the `key.Key` specified by the unique sid from the database. All IDs MUST parse to a valid uuid.
func (*KeyStorage) Open ¶
func (s *KeyStorage) Open(rawConfig []byte) error
Open configures the `KeyStorage` using rawConfig and connects to the database. If validation passes, the return value is the result of pinging the database.