postgresql

package module
v0.0.0-...-1a43f7c Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Overview

Package postgresql implements a storage provider conforming to the storage interface in aries-framework-go. This implementation is not complete. Check each method's documentation for details on current limitations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(opts *Provider)

Option represents an option for a PostgreSQL Provider.

func WithDBPrefix

func WithDBPrefix(dbPrefix string) Option

WithDBPrefix is an option for adding a prefix to all created database names.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout is an option for specifying the timeout for all calls to PostgreSQL. The timeout is 10 seconds by default.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider represents a PostgreSQL implementation of the storage.Provider interface. This implementation is not complete. Check each method's documentation for details on current limitations. WARNING: Certain inputs could be used for an SQL injection attack. While prepared statements are used whenever possible to prevent this, some inputs cannot be used in a prepared statement. Be very careful when using user-supplied data as inputs to the methods specified in this file. See the documentation above each method for details.

func NewProvider

func NewProvider(connectionString string, opts ...Option) (*Provider, error)

NewProvider instantiates a new PostgreSQL provider. connectionString can take one of several forms - see the pgxpool.Connect method for details. This PostgreSQL provider implementation is not yet complete. Check each method's documentation for details on current limitations. WARNING: Certain inputs to the various Provider and store functions could be used for an SQL injection attack. While prepared statements are used whenever possible to prevent this, some inputs cannot be used in a prepared statement. Be very careful when using user-supplied data as inputs to the methods specified in this file. See the documentation above each method for details.

func (*Provider) Close

func (p *Provider) Close() error

Close closes all stores created under this store provider.

func (*Provider) GetOpenStores

func (p *Provider) GetOpenStores() []storage.Store

GetOpenStores is not implemented.

func (*Provider) GetStoreConfig

func (p *Provider) GetStoreConfig(string) (storage.StoreConfiguration, error)

GetStoreConfig is not implemented.

func (*Provider) OpenStore

func (p *Provider) OpenStore(name string) (storage.Store, error)

OpenStore opens a Store with the given name and returns a handle. If the underlying database and table for the given name has never been created before, then it is created. Store names are not case-sensitive. If name is blank, then an error will be returned. WARNING: This method will create a database and table based on the given name. Those database calls may be vulnerable to an SQL injection attack as prepared statements cannot be used. Be very careful if you use a user-provided string in the store name!

func (*Provider) Ping

func (p *Provider) Ping() error

Ping verifies whether the PostgreSQL client can successfully connect to the deployment specified by the connection string used in the NewProvider call.

func (*Provider) SetStoreConfig

func (p *Provider) SetStoreConfig(storeName string, config storage.StoreConfiguration) error

SetStoreConfig uses the given tag names in the storage.StoreConfiguration passed in here to create columns in the table used by the store referred to by storeName. These columns have indexes created on them. This method must be called before attempting to store data using those tag names and also before trying to do a query using those tag names. WARNING: This method will create columns in the table based on the given tag names. Those database calls may be vulnerable to an SQL injection attack as prepared statements cannot be used here. Be very careful if you use any user-provided strings in the tag names! TODO (#229): Proper conformance to the requirements specified by the interface. This implementation only works as

expected if being called either a. the first time or b. on a store with the same config. See the issue
for details.

TODO (#229): In this implementation, tag names are case-insensitive. For other storage provider implementations,

they are case-sensitive. Either this implementation should allow them to be case-sensitive or the
interface should specify that they should be case-insensitive in order to ensure consistency among
implementations.

TODO (#229): SetStoreConfig is supposed to be optional for querying.

Jump to

Keyboard shortcuts

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