switchpart #62
3 changed files with 7 additions and 12 deletions
|
@ -11,7 +11,6 @@ import (
|
||||||
"dynatron.me/x/stillbox/pkg/database/partman"
|
"dynatron.me/x/stillbox/pkg/database/partman"
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5"
|
"github.com/jackc/pgx/v5"
|
||||||
"github.com/jackc/pgx/v5/pgconn"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -54,11 +53,6 @@ func partitioningCommand(cfg *config.Config) *cli.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Repartition(ctx context.Context, db database.Store, cfg config.Partition) error {
|
func Repartition(ctx context.Context, db database.Store, cfg config.Partition) error {
|
||||||
cfgIntv := partman.Interval(cfg.Interval)
|
|
||||||
if !cfgIntv.IsValid() {
|
|
||||||
return fmt.Errorf("invalid partitioning interval '%s'", string(cfgIntv))
|
|
||||||
}
|
|
||||||
|
|
||||||
pm, err := partman.New(db, cfg)
|
pm, err := partman.New(db, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -86,14 +80,12 @@ func Repartition(ctx context.Context, db database.Store, cfg config.Partition) e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfgIntv == intv {
|
if pm.Interval() == intv {
|
||||||
fmt.Fprintf(os.Stderr, "config interval '%s' and all extant, attached partitions agree; doing nothing\n", string(cfgIntv))
|
fmt.Fprintf(os.Stderr, "config interval '%s' and all extant, attached partitions agree; doing nothing\n", string(pm.Interval()))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
panic("not implemented")
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}, pgx.TxOptions{})
|
}, pgx.TxOptions{})
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ func (p Interval) IsValid() bool {
|
||||||
type PartitionManager interface {
|
type PartitionManager interface {
|
||||||
Go(ctx context.Context)
|
Go(ctx context.Context)
|
||||||
Check(ctx context.Context, now time.Time) error
|
Check(ctx context.Context, now time.Time) error
|
||||||
|
Interval() Interval
|
||||||
ExistingPartitions(parts []database.PartitionResult) ([]Partition, error)
|
ExistingPartitions(parts []database.PartitionResult) ([]Partition, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +103,10 @@ type partman struct {
|
||||||
intv Interval
|
intv Interval
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pm *partman) Interval() Interval {
|
||||||
|
return pm.intv
|
||||||
|
}
|
||||||
|
|
||||||
type Partition struct {
|
type Partition struct {
|
||||||
ParentTable string
|
ParentTable string
|
||||||
Schema string
|
Schema string
|
||||||
|
|
|
@ -161,5 +161,3 @@ CREATE TABLE IF NOT EXISTS incidents_calls(
|
||||||
FOREIGN KEY (calls_tbl_id, call_date) REFERENCES calls(id, call_date),
|
FOREIGN KEY (calls_tbl_id, call_date) REFERENCES calls(id, call_date),
|
||||||
PRIMARY KEY (incident_id, call_id)
|
PRIMARY KEY (incident_id, call_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue