postgresql

package
v0.0.0-...-ebb33e4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright 2022 The Dapr Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgreSQLStateStore

func NewPostgreSQLStateStore(logger logger.Logger, opts Options) state.Store

NewPostgreSQLStateStore creates a new instance of PostgreSQL state store.

Types

type MigrateOptions

type MigrateOptions struct {
	Logger            logger.Logger
	StateTableName    string
	MetadataTableName string
}

type Options

type Options struct {
	MigrateFn  func(context.Context, PGXPoolConn, MigrateOptions) error
	SetQueryFn func(*state.SetRequest, SetQueryOptions) string
	ETagColumn string
}

type PGXPoolConn

type PGXPoolConn interface {
	Begin(context.Context) (pgx.Tx, error)
	BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	Ping(context.Context) error
	Close()
}

Interface that applies to *pgxpool.Pool. We need this to be able to mock the connection in tests.

type PostgreSQL

type PostgreSQL struct {
	state.BulkStore
	// contains filtered or unexported fields
}

PostgreSQL state store.

func (*PostgreSQL) BulkDelete

func (p *PostgreSQL) BulkDelete(ctx context.Context, req []state.DeleteRequest) error

BulkDelete removes multiple entries from the store.

func (*PostgreSQL) BulkGet

BulkGet performs a bulks get operations. Options are ignored because this component requests all values in a single query.

func (*PostgreSQL) BulkSet

func (p *PostgreSQL) BulkSet(ctx context.Context, req []state.SetRequest) error

BulkSet adds/updates multiple entities on store.

func (*PostgreSQL) Close

func (p *PostgreSQL) Close() error

Close implements io.Closer.

func (*PostgreSQL) Delete

func (p *PostgreSQL) Delete(ctx context.Context, req *state.DeleteRequest) error

Delete removes an entity from the store.

func (*PostgreSQL) Features

func (p *PostgreSQL) Features() []state.Feature

Features returns the features available in this state store.

func (*PostgreSQL) Get

Get returns an entity from store.

func (*PostgreSQL) GetComponentMetadata

func (p *PostgreSQL) GetComponentMetadata() map[string]string

func (*PostgreSQL) GetDBAccess

func (p *PostgreSQL) GetDBAccess() dbAccess

Returns the dbaccess property. This method is used in tests.

func (*PostgreSQL) Init

func (p *PostgreSQL) Init(ctx context.Context, metadata state.Metadata) error

Init initializes the SQL server state store.

func (*PostgreSQL) Multi

Multi handles multiple transactions. Implements TransactionalStore.

func (*PostgreSQL) Query

Query executes a query against store.

func (*PostgreSQL) Set

func (p *PostgreSQL) Set(ctx context.Context, req *state.SetRequest) error

Set adds/updates an entity on store.

type PostgresDBAccess

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

PostgresDBAccess implements dbaccess.

func (*PostgresDBAccess) BulkDelete

func (p *PostgresDBAccess) BulkDelete(parentCtx context.Context, req []state.DeleteRequest) error

func (*PostgresDBAccess) BulkGet

func (p *PostgresDBAccess) BulkGet(parentCtx context.Context, req []state.GetRequest) ([]state.BulkGetResponse, error)

func (*PostgresDBAccess) BulkSet

func (p *PostgresDBAccess) BulkSet(parentCtx context.Context, req []state.SetRequest) error

func (*PostgresDBAccess) CleanupExpired

func (p *PostgresDBAccess) CleanupExpired() error

func (*PostgresDBAccess) Close

func (p *PostgresDBAccess) Close() error

Close implements io.Close.

func (*PostgresDBAccess) Delete

func (p *PostgresDBAccess) Delete(ctx context.Context, req *state.DeleteRequest) (err error)

Delete removes an item from the state store.

func (*PostgresDBAccess) ExecuteMulti

func (p *PostgresDBAccess) ExecuteMulti(parentCtx context.Context, request *state.TransactionalStateRequest) error

func (*PostgresDBAccess) Get

func (p *PostgresDBAccess) Get(parentCtx context.Context, req *state.GetRequest) (*state.GetResponse, error)

Get returns data from the database. If data does not exist for the key an empty state.GetResponse will be returned.

func (*PostgresDBAccess) GetCleanupInterval

func (p *PostgresDBAccess) GetCleanupInterval() *time.Duration

GetCleanupInterval returns the cleanupInterval property. This is primarily used for tests.

func (*PostgresDBAccess) GetDB

func (p *PostgresDBAccess) GetDB() *pgxpool.Pool

func (*PostgresDBAccess) Init

func (p *PostgresDBAccess) Init(ctx context.Context, meta state.Metadata) error

Init sets up Postgres connection and ensures that the state table exists.

func (*PostgresDBAccess) Query

Query executes a query against store.

func (*PostgresDBAccess) Set

Set makes an insert or update to the database.

type Query

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

func (*Query) Finalize

func (q *Query) Finalize(filters string, qq *query.Query) error

func (*Query) VisitAND

func (q *Query) VisitAND(f *query.AND) (string, error)

func (*Query) VisitEQ

func (q *Query) VisitEQ(f *query.EQ) (string, error)

func (*Query) VisitIN

func (q *Query) VisitIN(f *query.IN) (string, error)

func (*Query) VisitOR

func (q *Query) VisitOR(f *query.OR) (string, error)

type SetQueryOptions

type SetQueryOptions struct {
	TableName       string
	ExpireDateValue string
}

Jump to

Keyboard shortcuts

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