Added automatic pruning for configured Postgres sinks
This commit is contained in:
13
sinks/doc.go
13
sinks/doc.go
@@ -29,7 +29,7 @@
|
||||
// and feedkit ownership:
|
||||
// - downstream code registers table schema + event mapping functions
|
||||
// - feedkit manages DB connection, create-if-missing DDL, transactional
|
||||
// inserts, and prune helpers
|
||||
// inserts, optional automatic retention pruning, and manual prune helpers
|
||||
//
|
||||
// Example config:
|
||||
//
|
||||
@@ -40,6 +40,13 @@
|
||||
// uri: postgres://localhost:5432/feedkit?sslmode=disable
|
||||
// username: feedkit_user
|
||||
// password: feedkit_pass
|
||||
// prune: 3d # optional: prune rows older than now-3d on each write tx
|
||||
//
|
||||
// params.prune supports:
|
||||
// - Go duration strings (72h, 90m, 30s, ...)
|
||||
// - day/week suffixes (3d, 2w)
|
||||
//
|
||||
// If params.prune is omitted, automatic pruning is disabled.
|
||||
//
|
||||
// Example downstream wiring:
|
||||
//
|
||||
@@ -53,7 +60,7 @@
|
||||
// {Name: "payload_json", Type: "JSONB", Nullable: false},
|
||||
// },
|
||||
// PrimaryKey: []string{"event_id"},
|
||||
// PruneColumn: "emitted_at",
|
||||
// PruneColumn: "emitted_at", // required for retention pruning
|
||||
// },
|
||||
// },
|
||||
// MapEvent: func(ctx context.Context, e event.Event) ([]sinks.PostgresWrite, error) {
|
||||
@@ -74,7 +81,7 @@
|
||||
// },
|
||||
// })
|
||||
//
|
||||
// Pruning via type assertion:
|
||||
// Manual pruning via type assertion (administrative helpers):
|
||||
//
|
||||
// if p, ok := sink.(sinks.PostgresPruner); ok {
|
||||
// _, _ = p.PruneKeepLatest(ctx, "events", 10000)
|
||||
|
||||
Reference in New Issue
Block a user