Skip to content

Commit 82bdb22

Browse files
committed
* Added fluent modifiers for options.TimeToLiveSettings
1 parent 2eaca94 commit 82bdb22

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Added fluent modifiers for `options.TimeToLiveSettings`
2+
13
## v3.40.0
24
* Added `options.WithAddAttribute` and `options.WithDropAttribute` options for `session.AlterTable` request
35
* Added `options.WithAddIndex` and `options.WithDropIndex` options for `session.AlterTable` request
@@ -8,7 +10,6 @@
810
* Added `NestedCall` field to retry trace start infos for alarm on nested calls
911
* Added `topicoptions.WithWriterTrace` option for attach tracer into separated writer
1012
* Added `sugar.IsTableExists()` helper for check existence of table
11-
* Added `types.AlterTable` options FIXME
1213

1314
## v3.39.0
1415
* Removed message level partitioning from experimental topic API. It is unavailable on server side yet.

table/example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func Example_alterTable() {
162162
options.WithSetTimeToLiveSettings(options.TimeToLiveSettings{
163163
ColumnName: "expire_at",
164164
ExpireAfterSeconds: uint32(time.Hour.Seconds()),
165-
}),
165+
}.WithMode(options.TimeToLiveModeValueSinceUnixEpoch).WithColumnUnit(options.TimeToLiveUnitSeconds)),
166166
options.WithAddIndex("idx_series_series_id",
167167
options.WithIndexColumns("series_id"),
168168
options.WithDataColumns("title"),

table/options/models.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,26 @@ const (
442442
TimeToLiveModeValueSinceUnixEpoch
443443
)
444444

445+
func (ttl TimeToLiveSettings) WithColumnName(columnName string) TimeToLiveSettings {
446+
ttl.ColumnName = columnName
447+
return ttl
448+
}
449+
450+
func (ttl TimeToLiveSettings) WithExpireAfter(expireAfter time.Duration) TimeToLiveSettings {
451+
ttl.ExpireAfterSeconds = uint32(expireAfter.Seconds())
452+
return ttl
453+
}
454+
455+
func (ttl TimeToLiveSettings) WithMode(mode TimeToLiveMode) TimeToLiveSettings {
456+
ttl.Mode = mode
457+
return ttl
458+
}
459+
460+
func (ttl TimeToLiveSettings) WithColumnUnit(columnUnit TimeToLiveUnit) TimeToLiveSettings {
461+
ttl.ColumnUnit = &columnUnit
462+
return ttl
463+
}
464+
445465
func (ttl *TimeToLiveSettings) ToYDB() *Ydb_Table.TtlSettings {
446466
if ttl == nil {
447467
return nil

0 commit comments

Comments
 (0)