Documentation ¶
Index ¶
- Variables
- func CreateTables(ctx context.Context, conn Database, models ...any) error
- func MakeComments(ctx context.Context, sc SchemeCommenter, models ...interface{}) error
- func Wait(ctx context.Context, db driver.Pinger, checkPeriod time.Duration)
- type Bun
- func (db *Bun) Close() error
- func (db *Bun) Connect(ctx context.Context, cfg config.Database) error
- func (db *Bun) CreateState(ctx context.Context, s *State) error
- func (db *Bun) CreateTable(ctx context.Context, model any, opts ...CreateTableOption) error
- func (db *Bun) DB() *bun.DB
- func (db *Bun) DeleteState(ctx context.Context, s *State) error
- func (db *Bun) Exec(ctx context.Context, query string, args ...any) (int64, error)
- func (db *Bun) MakeColumnComment(ctx context.Context, tableName string, columnName string, comment string) error
- func (db *Bun) MakeTableComment(ctx context.Context, name string, comment string) error
- func (db *Bun) Ping(ctx context.Context) error
- func (db *Bun) State(ctx context.Context, indexName string) (*State, error)
- func (db *Bun) UpdateState(ctx context.Context, s *State) error
- type CreateTableOption
- type CreateTableOptions
- type Database
- type PartitionBy
- type PostgreSQLContainer
- type PostgreSQLContainerConfig
- type RangePartitionManager
- type SchemeCommenter
- type State
- type StateRepository
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrConnectionIsNotInitialized = errors.New("connection is not initialized") ErrUnsupportedDatabaseType = errors.New("unsupported database type") )
errors
Functions ¶
func CreateTables ¶ added in v0.3.0
CreateTables - creates tables by passed models. If partition tag is present table will be partitioned
func MakeComments ¶ added in v0.2.36
func MakeComments(ctx context.Context, sc SchemeCommenter, models ...interface{}) error
MakeComments -
Types ¶
type Bun ¶ added in v0.3.0
type Bun struct {
// contains filtered or unexported fields
}
Bun -
func (*Bun) CreateState ¶ added in v0.3.0
CreateState -
func (*Bun) CreateTable ¶ added in v0.3.0
CreateTable -
func (*Bun) DeleteState ¶ added in v0.3.0
DeleteState -
func (*Bun) MakeColumnComment ¶ added in v0.3.0
func (db *Bun) MakeColumnComment(ctx context.Context, tableName string, columnName string, comment string) error
MakeColumnComment -
func (*Bun) MakeTableComment ¶ added in v0.3.0
MakeTableComment -
type CreateTableOption ¶ added in v0.3.0
type CreateTableOption func(opts *CreateTableOptions)
CreateTableOption -
func WithPartitioning ¶ added in v0.3.0
func WithPartitioning(by string) CreateTableOption
WithPartitioning -
type CreateTableOptions ¶ added in v0.3.0
type CreateTableOptions struct {
// contains filtered or unexported fields
}
CreateTableOptions -
type Database ¶
type Database interface { Connect(ctx context.Context, cfg config.Database) error Exec(ctx context.Context, query string, args ...any) (int64, error) CreateTable(ctx context.Context, model any, opts ...CreateTableOption) error StateRepository SchemeCommenter driver.Pinger io.Closer }
Database -
type PartitionBy ¶ added in v0.3.0
type PartitionBy int
PartitionBy -
const ( PartitionByMonth PartitionBy = iota + 1 PartitionByYear )
type PostgreSQLContainer ¶ added in v0.3.0
type PostgreSQLContainer struct { testcontainers.Container Config PostgreSQLContainerConfig // contains filtered or unexported fields }
func NewPostgreSQLContainer ¶ added in v0.3.0
func NewPostgreSQLContainer(ctx context.Context, cfg PostgreSQLContainerConfig) (*PostgreSQLContainer, error)
NewPostgreSQLContainer -
func (PostgreSQLContainer) GetDSN ¶ added in v0.3.0
func (c PostgreSQLContainer) GetDSN() string
GetDSN -
func (PostgreSQLContainer) MappedPort ¶ added in v0.3.0
func (c PostgreSQLContainer) MappedPort() nat.Port
MappedPort -
type PostgreSQLContainerConfig ¶ added in v0.3.0
type RangePartitionManager ¶ added in v0.3.0
type RangePartitionManager struct {
// contains filtered or unexported fields
}
RangePartitionManager -
func NewPartitionManager ¶ added in v0.3.0
func NewPartitionManager(conn Database, by PartitionBy) RangePartitionManager
NewPartitionManager -
func (*RangePartitionManager) CreatePartition ¶ added in v0.3.0
func (pm *RangePartitionManager) CreatePartition(ctx context.Context, currentTime time.Time, tableName string) error
CreatePartition -
func (*RangePartitionManager) CreatePartitions ¶ added in v0.3.0
func (pm *RangePartitionManager) CreatePartitions(ctx context.Context, currentTime time.Time, tableNames ...string) error
CreatePartitions -
type SchemeCommenter ¶ added in v0.2.35
type SchemeCommenter interface { MakeTableComment(ctx context.Context, name string, comment string) error MakeColumnComment(ctx context.Context, tableName string, columnName string, comment string) error }
SchemeCommenter -
type State ¶
type State struct { bun.BaseModel `gorm:"-" pg:"-" bun:"dipdup_state" json:"-" comment:"Indexer state table"` IndexName string `gorm:"primaryKey" pg:",pk" bun:",pk" json:"index_name" comment:"Index name"` IndexType string `json:"index_type" comment:"Index type"` Hash string `json:"hash" comment:"Current hash"` Timestamp time.Time `json:"timestamp" comment:"Current timestamp"` Level uint64 `json:"level" comment:"Index level"` UpdatedAt int `gorm:"autoUpdateTime" comment:"Last updated timestamp"` CreatedAt int `gorm:"autoCreateTime" comment:"Created timestamp"` // contains filtered or unexported fields }
State -
func (*State) BeforeAppendModel ¶ added in v0.4.4
Click to show internal directories.
Click to hide internal directories.