File postgres_store.go
has 671 lines of code (exceeds 500 allowed). Consider refactoring.
package postgresstore
import (
"context"
"database/sql"
postgresStore
has 24 methods (exceeds 20 allowed). Consider refactoring.
type postgresStore struct {
config *Config
db *sql.DB
clock clock.Clock
uuidGenerator shortuuid.Generator
Method postgresStore.readResultRecords
has 72 lines of code (exceeds 50 allowed). Consider refactoring.
func (s *postgresStore) readResultRecords(ctx context.Context, rows *sql.Rows, resultRecords chan rangedb.ResultRecord) (int, error) {
recordsRead := 0
for rows.Next() {
var (
streamName string
Method postgresStore.OptimisticDeleteStream
has 7 return statements (exceeds 4 allowed).
func (s *postgresStore) OptimisticDeleteStream(ctx context.Context, expectedStreamSequenceNumber uint64, streamName string) error {
transaction, err := s.db.BeginTx(ctx, nil)
if err != nil {
return err
}
Method postgresStore.readResultRecords
has 6 return statements (exceeds 4 allowed).
func (s *postgresStore) readResultRecords(ctx context.Context, rows *sql.Rows, resultRecords chan rangedb.ResultRecord) (int, error) {
recordsRead := 0
for rows.Next() {
var (
streamName string
Method postgresStore.saveEvents
has 6 return statements (exceeds 4 allowed).
func (s *postgresStore) saveEvents(
ctx context.Context,
transaction *sql.Tx,
expectedStreamSequenceNumber *uint64,
streamName string,
Method postgresStore.saveEvents
has 5 arguments (exceeds 4 allowed). Consider refactoring.
ctx context.Context,
transaction *sql.Tx,
expectedStreamSequenceNumber *uint64,
streamName string,
eventRecords []*rangedb.EventRecord,
Method postgresStore.eventRecordsToBatchRecords
has 5 return statements (exceeds 4 allowed).
func (s *postgresStore) eventRecordsToBatchRecords(eventRecords []*rangedb.EventRecord, streamName string, streamSequenceNumber uint64) ([]*batchSQLRecord, error) {
aggregateType := eventRecords[0].Event.AggregateType()
aggregateID := eventRecords[0].Event.AggregateID()
var batchEvents []*batchSQLRecord
Method postgresStore.transactionalSaveEvents
has 5 return statements (exceeds 4 allowed).
func (s *postgresStore) transactionalSaveEvents(ctx context.Context, expectedStreamSequenceNumber *uint64, streamName string, eventRecords ...*rangedb.EventRecord) (uint64, error) {
transaction, err := s.db.BeginTx(ctx, nil)
if err != nil {
return 0, err
}
Similar blocks of code found in 5 locations. Consider refactoring.
func (s *postgresStore) AggregateTypesSubscription(ctx context.Context, bufferSize int, subscriber rangedb.RecordSubscriber, aggregateTypes ...string) rangedb.RecordSubscription {
return recordsubscriber.New(
recordsubscriber.AggregateTypesConfig(ctx, s, s.broadcaster, bufferSize,
aggregateTypes,
func(record *rangedb.Record) error {
Similar blocks of code found in 5 locations. Consider refactoring.
func (s *postgresStore) AllEventsSubscription(ctx context.Context, bufferSize int, subscriber rangedb.RecordSubscriber) rangedb.RecordSubscription {
return recordsubscriber.New(
recordsubscriber.AllEventsConfig(ctx, s, s.broadcaster, bufferSize,
func(record *rangedb.Record) error {
subscriber.Accept(record)
Similar blocks of code found in 2 locations. Consider refactoring.
func (s *postgresStore) connectToDB() error {
db, err := sql.Open("postgres", s.config.DataSourceName())
if err != nil {
return fmt.Errorf("unable to open DB connection: %v", err)
}
pkg/crypto/provider/postgreskeystore/postgres_keystore.go on lines 100..114 There are no issues that match your filters.